Skip to content

Commit 63cb26c

Browse files
committed
updated presenters
1 parent cb28b88 commit 63cb26c

54 files changed

Lines changed: 1375 additions & 263 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace ImageProcessing.App.PresentationLayer.DomainEvents.RotationArgs
2+
{
3+
/// <summary>
4+
/// Press a button to rotate.
5+
/// </summary>
6+
public sealed class RotateEventArgs : BaseEventArgs
7+
{
8+
9+
}
10+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace ImageProcessing.App.PresentationLayer.DomainEvents.ScalingArgs
2+
{
3+
/// <summary>
4+
/// Press a button to scale.
5+
/// </summary>
6+
public sealed class ScaleEventArgs : BaseEventArgs
7+
{
8+
public ScaleEventArgs((string, string) parms)
9+
{
10+
Parameters = parms;
11+
}
12+
13+
public (string X, string Y) Parameters { get; }
14+
}
15+
}

Source/ImageProcessing.App.PresentationLayer/Presenters/ColorMatrixPresenter.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
namespace ImageProcessing.App.PresentationLayer.Presenters
2222
{
23-
internal sealed class ColorMatrixPresenter : BasePresenter<IColorMatrixView, ColorMatrixViewModel>,
23+
internal sealed class ColorMatrixPresenter : BasePresenter<IColorMatrixView, BitmapViewModel>,
2424
ISubscriber<ApplyColorMatrixEventArgs>,
2525
ISubscriber<ContainerUpdatedEventArgs>,
2626
ISubscriber<CustomColorMatrixEventArgs>,
@@ -101,7 +101,7 @@ public async Task OnEventHandler(object publisher, ApplyCustomColorMatrixEventAr
101101
}
102102

103103
/// <inheritdoc cref="CustomColorMatrixEventArgs"/>
104-
public async Task OnEventHandler(object publisher, CustomColorMatrixEventArgs e)
104+
public Task OnEventHandler(object publisher, CustomColorMatrixEventArgs e)
105105
{
106106
try
107107
{
@@ -116,10 +116,12 @@ public async Task OnEventHandler(object publisher, CustomColorMatrixEventArgs e)
116116
View.Tooltip(Errors.CustomColorMatrix);
117117
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
118118
}
119+
120+
return Task.CompletedTask;
119121
}
120122

121123
/// <inheritdoc cref="ChangeColorMatrixEventArgs"/>
122-
public async Task OnEventHandler(object publisher, ChangeColorMatrixEventArgs e)
124+
public Task OnEventHandler(object publisher, ChangeColorMatrixEventArgs e)
123125
{
124126
try
125127
{
@@ -130,6 +132,8 @@ public async Task OnEventHandler(object publisher, ChangeColorMatrixEventArgs e)
130132
View.Tooltip(Errors.UpdateColorMatrix);
131133
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
132134
}
135+
136+
return Task.CompletedTask;
133137
}
134138

135139
/// <inheritdoc cref="ContainerUpdatedEventArgs"/>
@@ -156,9 +160,18 @@ await _locker.LockOperationAsync(() =>
156160
}
157161

158162
/// <inheritdoc cref="RestoreFocusEventArgs"/>
159-
public async Task OnEventHandler(object publisher, RestoreFocusEventArgs e)
163+
public Task OnEventHandler(object publisher, RestoreFocusEventArgs e)
160164
{
161-
View.Focus();
165+
try
166+
{
167+
View.Focus();
168+
}
169+
catch(Exception ex)
170+
{
171+
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
172+
}
173+
174+
return Task.CompletedTask;
162175
}
163176
}
164177
}

Source/ImageProcessing.App.PresentationLayer/Presenters/ConvolutionPresenter.cs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
namespace ImageProcessing.App.PresentationLayer.Presenters
2121
{
22-
internal sealed class ConvolutionPresenter : BasePresenter<IConvolutionView, ConvolutionViewModel>,
22+
internal sealed class ConvolutionPresenter : BasePresenter<IConvolutionView, BitmapViewModel>,
2323
ISubscriber<ApplyConvolutionKernelEventArgs>,
2424
ISubscriber<ShowTooltipOnErrorEventArgs>,
2525
ISubscriber<ContainerUpdatedEventArgs>,
@@ -93,15 +93,33 @@ await _locker.LockOperationAsync(() =>
9393
}
9494

9595
/// <inheritdoc cref="ShowTooltipOnErrorEventArgs"/>
96-
public async Task OnEventHandler(object publisher, ShowTooltipOnErrorEventArgs e)
96+
public Task OnEventHandler(object publisher, ShowTooltipOnErrorEventArgs e)
9797
{
98-
View.Tooltip(e.Message);
98+
try
99+
{
100+
View.Tooltip(e.Message);
101+
}
102+
catch(Exception ex)
103+
{
104+
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
105+
}
106+
107+
return Task.CompletedTask;
99108
}
100109

101110
/// <inheritdoc cref="RestoreFocusEventArgs"/>
102-
public async Task OnEventHandler(object publisher, RestoreFocusEventArgs e)
111+
public Task OnEventHandler(object publisher, RestoreFocusEventArgs e)
103112
{
104-
View.Focus();
113+
try
114+
{
115+
View.Focus();
116+
}
117+
catch(Exception ex)
118+
{
119+
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
120+
}
121+
122+
return Task.CompletedTask;
105123
}
106124
}
107125
}

Source/ImageProcessing.App.PresentationLayer/Presenters/DistributionPresenter.cs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
namespace ImageProcessing.App.PresentationLayer.Presenters
2323
{
24-
internal sealed class DistributionPresenter : BasePresenter<IDistributionView, DistributionViewModel>,
24+
internal sealed class DistributionPresenter : BasePresenter<IDistributionView, BitmapViewModel>,
2525
ISubscriber<TransformHistogramEventArgs>,
2626
ISubscriber<ShuffleEventArgs>,
2727
ISubscriber<BuildRandomVariableFunctionEventArgs>,
@@ -124,7 +124,7 @@ public async Task OnEventHandler(object publisher, BuildRandomVariableFunctionEv
124124
}
125125

126126
/// <inheritdoc cref="ShowQualityMeasureMenuEventArgs"/>
127-
public async Task OnEventHandler(object publisher, ShowQualityMeasureMenuEventArgs e)
127+
public Task OnEventHandler(object publisher, ShowQualityMeasureMenuEventArgs e)
128128
{
129129
try
130130
{
@@ -138,6 +138,8 @@ public async Task OnEventHandler(object publisher, ShowQualityMeasureMenuEventAr
138138
View.Tooltip(Errors.QualityHistogram);
139139
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
140140
}
141+
142+
return Task.CompletedTask;
141143
}
142144

143145
/// <inheritdoc cref="GetRandomVariableInfoEventArgs"/>
@@ -188,15 +190,33 @@ await _locker.LockOperationAsync(() =>
188190
}
189191

190192
/// <inheritdoc cref="ShowTooltipOnErrorEventArgs"/>
191-
public async Task OnEventHandler(object publisher, ShowTooltipOnErrorEventArgs e)
193+
public Task OnEventHandler(object publisher, ShowTooltipOnErrorEventArgs e)
192194
{
193-
View.Tooltip(e.Message);
195+
try
196+
{
197+
View.Tooltip(e.Message);
198+
}
199+
catch(Exception ex)
200+
{
201+
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
202+
}
203+
204+
return Task.CompletedTask;
194205
}
195206

196207
/// <inheritdoc cref="RestoreFocusEventArgs"/>
197-
public async Task OnEventHandler(object publisher, RestoreFocusEventArgs e)
208+
public Task OnEventHandler(object publisher, RestoreFocusEventArgs e)
198209
{
199-
View.Focus();
210+
try
211+
{
212+
View.Focus();
213+
}
214+
catch(Exception ex)
215+
{
216+
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
217+
}
218+
219+
return Task.CompletedTask;
200220
}
201221
}
202222
}

Source/ImageProcessing.App.PresentationLayer/Presenters/MainPresenter.cs

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ public async Task OnEventHandler(object publisher, ShowRgbMenuEventArgs e)
157157
ImageContainer.Source
158158
).ConfigureAwait(true);
159159

160-
Controller.Run<RgbPresenter, RgbViewModel>(
161-
new RgbViewModel(copy));
160+
Controller.Run<RgbPresenter, BitmapViewModel>(
161+
new BitmapViewModel(copy));
162162
}
163163
}
164164
catch (Exception ex)
@@ -179,8 +179,8 @@ public async Task OnEventHandler(object publisher, ShowDistributionMenuEventArgs
179179
ImageContainer.Source
180180
).ConfigureAwait(true);
181181

182-
Controller.Run<DistributionPresenter, DistributionViewModel>(
183-
new DistributionViewModel(copy));
182+
Controller.Run<DistributionPresenter, BitmapViewModel>(
183+
new BitmapViewModel(copy));
184184
}
185185
}
186186
catch (Exception ex)
@@ -201,8 +201,8 @@ public async Task OnEventHandler(object publisher, ShowConvolutionMenuEventArgs
201201
ImageContainer.Source
202202
).ConfigureAwait(true);
203203

204-
Controller.Run<ConvolutionPresenter, ConvolutionViewModel>(
205-
new ConvolutionViewModel(copy));
204+
Controller.Run<ConvolutionPresenter, BitmapViewModel>(
205+
new BitmapViewModel(copy));
206206
}
207207
}
208208
catch (Exception ex)
@@ -223,8 +223,8 @@ public async Task OnEventHandler(object publisher, ShowTransformationMenuEventAr
223223
ImageContainer.Source
224224
).ConfigureAwait(true);
225225

226-
Controller.Run<TransformationPresenter, TransformationViewModel>(
227-
new TransformationViewModel(copy));
226+
Controller.Run<TransformationPresenter, BitmapViewModel>(
227+
new BitmapViewModel(copy));
228228
}
229229
}
230230
catch (Exception ex)
@@ -235,7 +235,7 @@ public async Task OnEventHandler(object publisher, ShowTransformationMenuEventAr
235235
}
236236

237237
/// <inheritdoc cref="ShowSettingsMenuEventArgs"/>
238-
public async Task OnEventHandler(object publisher, ShowSettingsMenuEventArgs e)
238+
public Task OnEventHandler(object publisher, ShowSettingsMenuEventArgs e)
239239
{
240240
try
241241
{
@@ -246,6 +246,8 @@ public async Task OnEventHandler(object publisher, ShowSettingsMenuEventArgs e)
246246
OnError(publisher, Errors.ShowSettingsMenu);
247247
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
248248
}
249+
250+
return Task.CompletedTask;
249251
}
250252

251253
/// <inheritdoc cref="AttachBlockToRendererEventArgs"/>
@@ -323,8 +325,7 @@ public async Task OnEventHandler(object publisher, TrackBarEventArgs e)
323325
var scale = View.GetZoomFactor(container);
324326
var rad = View.GetRotationFactor(container);
325327

326-
var copy = await GetImageCopy(container)
327-
.ConfigureAwait(true);
328+
var copy = await GetImageCopy(container).ConfigureAwait(true);
328329

329330
await Paint(
330331
new PipelineBlock(copy)
@@ -372,15 +373,25 @@ await Render(
372373
}
373374

374375
/// <inheritdoc cref="ShowTooltipOnErrorEventArgs"/>
375-
public async Task OnEventHandler(object publisher, ShowTooltipOnErrorEventArgs e)
376+
public Task OnEventHandler(object publisher, ShowTooltipOnErrorEventArgs e)
376377
{
377-
View.Tooltip(e.Message);
378+
try
379+
{
380+
View.Tooltip(e.Message);
381+
}
382+
catch(Exception ex)
383+
{
384+
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
385+
}
386+
387+
return Task.CompletedTask;
378388
}
379389

380390
public async Task OnEventHandler(object publisher, FormIsClosedEventArgs e)
381391
{
382392
Controller.Dispose();
383393
}
394+
384395
private void RenderBlock(Bitmap bmp, ImageContainer to, UndoRedoAction action)
385396
{
386397
lock (_cache)

Source/ImageProcessing.App.PresentationLayer/Presenters/RgbPresenter.cs

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
namespace ImageProcessing.App.PresentationLayer.Presenters
2222
{
23-
internal sealed class RgbPresenter : BasePresenter<IRgbView, RgbViewModel>,
23+
internal sealed class RgbPresenter : BasePresenter<IRgbView, BitmapViewModel>,
2424
ISubscriber<ApplyRgbFilterEventArgs>,
2525
ISubscriber<ApplyRgbChannelFilterEventArgs>,
2626
ISubscriber<ContainerUpdatedEventArgs>,
@@ -136,8 +136,8 @@ public async Task OnEventHandler(object publisher, ShowColorMatrixMenuEventArgs
136136
() => new Bitmap(ViewModel.Source)
137137
).ConfigureAwait(true);
138138

139-
Controller.Run<ColorMatrixPresenter, ColorMatrixViewModel>(
140-
new ColorMatrixViewModel(copy));
139+
Controller.Run<ColorMatrixPresenter, BitmapViewModel>(
140+
new BitmapViewModel(copy));
141141
}
142142
catch(Exception ex)
143143
{
@@ -147,15 +147,33 @@ public async Task OnEventHandler(object publisher, ShowColorMatrixMenuEventArgs
147147
}
148148

149149
/// <inheritdoc cref="ShowTooltipOnErrorEventArgs"/>
150-
public async Task OnEventHandler(object publisher, ShowTooltipOnErrorEventArgs e)
150+
public Task OnEventHandler(object publisher, ShowTooltipOnErrorEventArgs e)
151151
{
152-
View.Tooltip(e.Message);
152+
try
153+
{
154+
View.Tooltip(e.Message);
155+
}
156+
catch(Exception ex)
157+
{
158+
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
159+
}
160+
161+
return Task.CompletedTask;
153162
}
154163

155164
/// <inheritdoc cref="RestoreFocusEventArgs"/>
156-
public async Task OnEventHandler(object publisher, RestoreFocusEventArgs e)
165+
public Task OnEventHandler(object publisher, RestoreFocusEventArgs e)
157166
{
158-
View.Focus();
167+
try
168+
{
169+
View.Focus();
170+
}
171+
catch(Exception ex)
172+
{
173+
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
174+
}
175+
176+
return Task.CompletedTask;
159177
}
160178
}
161179
}

0 commit comments

Comments
 (0)