@@ -163,14 +163,18 @@ public StatusCenterItemProgressModel Progress
163
163
164
164
public ObservableCollection < ObservablePoint > ? SpeedGraphValues { get ; private set ; }
165
165
166
+ public ObservableCollection < ObservablePoint > ? SpeedGraphBackgroundValues { get ; private set ; }
167
+
166
168
public ObservableCollection < ISeries > ? SpeedGraphSeries { get ; private set ; }
167
169
168
- public IList < ICartesianAxis > ? SpeedGraphXAxes { get ; private set ; }
170
+ public ObservableCollection < ICartesianAxis > ? SpeedGraphXAxes { get ; private set ; }
169
171
170
- public IList < ICartesianAxis > ? SpeedGraphYAxes { get ; private set ; }
172
+ public ObservableCollection < ICartesianAxis > ? SpeedGraphYAxes { get ; private set ; }
171
173
172
174
public double IconBackgroundCircleBorderOpacity { get ; private set ; }
173
175
176
+ public double ? CurrentHighestPointValue { get ; private set ; }
177
+
174
178
public CancellationToken CancellationToken
175
179
=> _operationCancellationToken ? . Token ?? default ;
176
180
@@ -207,18 +211,17 @@ public StatusCenterItem(
207
211
IconBackgroundCircleBorderOpacity = 1 ;
208
212
AnimatedIconState = "NormalOff" ;
209
213
SpeedGraphValues = new ( ) ;
214
+ SpeedGraphBackgroundValues = new ( ) ;
210
215
CancelCommand = new RelayCommand ( ExecuteCancelCommand ) ;
211
216
Message = "ProcessingItems" . GetLocalizedResource ( ) ;
217
+ Source = source ;
218
+ Destination = destination ;
212
219
213
- if ( source is not null )
214
- Source = source ;
215
-
216
- if ( destination is not null )
217
- Destination = destination ;
218
-
220
+ // Get the graph color
219
221
if ( App . Current . Resources [ "AppThemeFillColorAttentionBrush" ] is not SolidColorBrush accentBrush )
220
222
return ;
221
223
224
+ // Initialize graph series
222
225
SpeedGraphSeries = new ( )
223
226
{
224
227
new LineSeries < ObservablePoint >
@@ -231,21 +234,42 @@ public StatusCenterItem(
231
234
// Stroke
232
235
Stroke = new SolidColorPaint (
233
236
new ( accentBrush . Color . R , accentBrush . Color . G , accentBrush . Color . B ) ,
234
- 1 ) ,
237
+ 1f ) ,
235
238
236
239
// Fill under the stroke
237
240
Fill = new LinearGradientPaint (
238
241
new SKColor [ ] {
239
242
new ( accentBrush . Color . R , accentBrush . Color . G , accentBrush . Color . B , 50 ) ,
240
243
new ( accentBrush . Color . R , accentBrush . Color . G , accentBrush . Color . B , 10 )
241
244
} ,
242
- new ( 0.5f , 0f ) ,
243
- new ( 0.5f , 1.0f ) ,
244
- new [ ] { 0.2f , 1.3f } ) ,
245
+ new ( 0f , 0f ) ,
246
+ new ( 0f , 0f ) ,
247
+ new [ ] { 0.1f , 1.0f } ) ,
248
+ } ,
249
+ new LineSeries < ObservablePoint >
250
+ {
251
+ Values = SpeedGraphBackgroundValues ,
252
+ GeometrySize = 0d ,
253
+ DataPadding = new ( 0 , 0 ) ,
254
+ IsHoverable = false ,
255
+
256
+ // Stroke
257
+ Stroke = new SolidColorPaint (
258
+ new ( accentBrush . Color . R , accentBrush . Color . G , accentBrush . Color . B , 40 ) ,
259
+ 0.1f ) ,
260
+
261
+ // Fill under the stroke
262
+ Fill = new LinearGradientPaint (
263
+ new SKColor [ ] {
264
+ new ( accentBrush . Color . R , accentBrush . Color . G , accentBrush . Color . B , 40 )
265
+ } ,
266
+ new ( 0f , 0f ) ,
267
+ new ( 0f , 0f ) ) ,
245
268
}
246
269
} ;
247
270
248
- SpeedGraphXAxes = new ICartesianAxis [ ]
271
+ // Initialize X axes of the graph
272
+ SpeedGraphXAxes = new ( )
249
273
{
250
274
new Axis
251
275
{
@@ -256,7 +280,8 @@ public StatusCenterItem(
256
280
}
257
281
} ;
258
282
259
- SpeedGraphYAxes = new ICartesianAxis [ ]
283
+ // Initialize Y axes of the graph
284
+ SpeedGraphYAxes = new ( )
260
285
{
261
286
new Axis
262
287
{
@@ -341,6 +366,7 @@ private void ReportProgress(StatusCenterItemProgressModel value)
341
366
if ( value . Status is FileSystemStatusCode status )
342
367
FileSystemOperationReturnResult = status . ToStatus ( ) ;
343
368
369
+ // Update the footer message, percentage, processing item name
344
370
if ( value . Percentage is double p )
345
371
{
346
372
if ( ProgressPercentage != value . Percentage )
@@ -428,9 +454,41 @@ private void ReportProgress(StatusCenterItemProgressModel value)
428
454
break ;
429
455
}
430
456
431
- // Remove the same point
457
+ bool isSamePoint = false ;
458
+
459
+ // Remove the point that has the same X position
432
460
if ( SpeedGraphValues ? . FirstOrDefault ( v => v . X == point . X ) is ObservablePoint existingPoint )
461
+ {
433
462
SpeedGraphValues . Remove ( existingPoint ) ;
463
+ isSamePoint = true ;
464
+ }
465
+
466
+ CurrentHighestPointValue ??= point . Y ;
467
+
468
+ if ( ! isSamePoint )
469
+ {
470
+ // NOTE: -0.4 is the value that is needs to set for the graph drawing
471
+ var maxHeight = CurrentHighestPointValue * 1.44d - 0.4 ;
472
+
473
+ if ( CurrentHighestPointValue < point . Y &&
474
+ SpeedGraphYAxes is not null &&
475
+ SpeedGraphYAxes . FirstOrDefault ( ) is var item &&
476
+ item is not null )
477
+ {
478
+ // Max height is updated
479
+ CurrentHighestPointValue = point . Y ;
480
+ maxHeight = CurrentHighestPointValue * 1.44d ;
481
+ item . MaxLimit = maxHeight ;
482
+
483
+ // NOTE: -0.1 is the value that is needs to set for the graph drawing
484
+ UpdateGraphBackgroundPoints ( point . X , maxHeight - 0.1 , true ) ;
485
+ }
486
+ else
487
+ {
488
+ // Max height is not updated
489
+ UpdateGraphBackgroundPoints ( point . X , maxHeight , false ) ;
490
+ }
491
+ }
434
492
435
493
// Add a new point
436
494
SpeedGraphValues ? . Add ( point ) ;
@@ -443,6 +501,20 @@ private void ReportProgress(StatusCenterItemProgressModel value)
443
501
_viewModel . NotifyChanges ( ) ;
444
502
}
445
503
504
+ private void UpdateGraphBackgroundPoints ( double ? x , double ? y , bool redraw )
505
+ {
506
+ if ( SpeedGraphBackgroundValues is null )
507
+ return ;
508
+
509
+ ObservablePoint newPoint = new ( x , y ) ;
510
+ SpeedGraphBackgroundValues . Add ( newPoint ) ;
511
+
512
+ if ( redraw )
513
+ {
514
+ SpeedGraphBackgroundValues . ForEach ( x => x . Y = CurrentHighestPointValue * 1.44d - 0.1 ) ;
515
+ }
516
+ }
517
+
446
518
public void ExecuteCancelCommand ( )
447
519
{
448
520
if ( IsCancelable )
0 commit comments