@@ -16,18 +16,12 @@ namespace Files.App.ViewModels
16
16
{
17
17
public class OngoingTasksViewModel : ObservableObject , IOngoingTasksActions
18
18
{
19
- #region Public Properties
19
+ // Public Properties
20
20
21
21
public ObservableCollection < StatusBanner > StatusBannersSource { get ; private set ; } = new ObservableCollection < StatusBanner > ( ) ;
22
22
23
- private float medianOperationProgressValue = 0.0f ;
24
-
25
- public OngoingTasksViewModel ( )
26
- {
27
- StatusBannersSource . CollectionChanged += ( s , e ) => OnPropertyChanged ( nameof ( AnyBannersPresent ) ) ;
28
- }
29
-
30
- public float MedianOperationProgressValue
23
+ private int medianOperationProgressValue = 0 ;
24
+ public int MedianOperationProgressValue
31
25
{
32
26
get => medianOperationProgressValue ;
33
27
private set => SetProperty ( ref medianOperationProgressValue , value ) ;
@@ -82,17 +76,20 @@ public int InfoBadgeValue
82
76
get => OngoingOperationsCount > 0 ? OngoingOperationsCount : - 1 ;
83
77
}
84
78
85
- #endregion Public Properties
86
-
87
- #region Events
79
+ // Events
88
80
89
81
public event EventHandler < PostedStatusBanner > ProgressBannerPosted ;
90
82
91
- #endregion Events
83
+ // Constructors
84
+
85
+ public OngoingTasksViewModel ( )
86
+ {
87
+ StatusBannersSource . CollectionChanged += ( s , e ) => OnPropertyChanged ( nameof ( AnyBannersPresent ) ) ;
88
+ }
92
89
93
- #region IOngoingTasksActions
90
+ // IOngoingTasksActions
94
91
95
- public PostedStatusBanner PostBanner ( string title , string message , float initialProgress , ReturnResult status , FileOperationType operation )
92
+ public PostedStatusBanner PostBanner ( string title , string message , int initialProgress , ReturnResult status , FileOperationType operation )
96
93
{
97
94
StatusBanner banner = new StatusBanner ( message , title , initialProgress , status , operation ) ;
98
95
PostedStatusBanner postedBanner = new PostedStatusBanner ( banner , this ) ;
@@ -105,7 +102,7 @@ public PostedStatusBanner PostBanner(string title, string message, float initial
105
102
return postedBanner ;
106
103
}
107
104
108
- public PostedStatusBanner PostOperationBanner ( string title , string message , float initialProgress , ReturnResult status , FileOperationType operation , CancellationTokenSource cancellationTokenSource )
105
+ public PostedStatusBanner PostOperationBanner ( string title , string message , int initialProgress , ReturnResult status , FileOperationType operation , CancellationTokenSource cancellationTokenSource )
109
106
{
110
107
StatusBanner banner = new StatusBanner ( message , title , initialProgress , status , operation )
111
108
{
@@ -161,36 +158,31 @@ public void UpdateMedianProgress()
161
158
{
162
159
if ( AnyOperationsOngoing )
163
160
{
164
- MedianOperationProgressValue = StatusBannersSource . Where ( ( item ) => item . IsProgressing ) . Average ( x => x . Progress ) ;
161
+ MedianOperationProgressValue = ( int ) StatusBannersSource . Where ( ( item ) => item . IsProgressing ) . Average ( x => x . Progress ) ;
165
162
}
166
163
}
167
-
168
- #endregion IOngoingTasksActions
169
164
}
170
165
171
166
public class PostedStatusBanner
172
167
{
173
- #region Private Members
168
+ // Private Members
174
169
175
170
private readonly IOngoingTasksActions OngoingTasksActions ;
176
171
177
172
private readonly StatusBanner Banner ;
178
173
179
174
private readonly CancellationTokenSource cancellationTokenSource ;
180
175
181
- #endregion Private Members
182
176
183
- #region Public Members
177
+ // Public Members
184
178
185
179
public readonly FileSystemProgress Progress ;
186
180
187
181
public readonly Progress < FileSystemProgress > ProgressEventSource ;
188
182
189
183
public CancellationToken CancellationToken => cancellationTokenSource ? . Token ?? default ;
190
184
191
- #endregion Public Members
192
-
193
- #region Constructor
185
+ // Constructor
194
186
195
187
public PostedStatusBanner ( StatusBanner banner , IOngoingTasksActions OngoingTasksActions )
196
188
{
@@ -211,9 +203,7 @@ public PostedStatusBanner(StatusBanner banner, IOngoingTasksActions OngoingTasks
211
203
Progress = new ( ProgressEventSource , status : FileSystemStatusCode . InProgress ) ;
212
204
}
213
205
214
- #endregion Constructor
215
-
216
- #region Private Helpers
206
+ // Private Helpers
217
207
218
208
private void ReportProgressToBanner ( FileSystemProgress value )
219
209
{
@@ -226,10 +216,10 @@ private void ReportProgressToBanner(FileSystemProgress value)
226
216
227
217
Banner . IsProgressing = ( value . Status & FileSystemStatusCode . InProgress ) != 0 ;
228
218
229
- if ( value . Percentage is float f )
219
+ if ( value . Percentage is int p )
230
220
{
231
- Banner . Progress = f ;
232
- Banner . FullTitle = $ "{ Banner . Title } ({ Banner . Progress : 0.00 } %)";
221
+ Banner . Progress = p ;
222
+ Banner . FullTitle = $ "{ Banner . Title } ({ Banner . Progress } %)";
233
223
234
224
// TODO: Show detailed progress if Size/Count information available
235
225
}
@@ -238,18 +228,18 @@ private void ReportProgressToBanner(FileSystemProgress value)
238
228
switch ( value . TotalSize , value . ItemsCount )
239
229
{
240
230
case ( not 0 , not 0 ) :
241
- Banner . Progress = value . ProcessedSize * 100f / value . TotalSize ;
242
- Banner . FullTitle = $ "{ Banner . Title } ({ value . ProcessedItemsCount } ({ value . ProcessedSize . ToSizeString ( ) } ) / { value . ItemsCount } ({ value . TotalSize . ToSizeString ( ) } ): { Banner . Progress : 0.00 } %)";
231
+ Banner . Progress = ( int ) ( value . ProcessedSize * 100f / value . TotalSize ) ;
232
+ Banner . FullTitle = $ "{ Banner . Title } ({ value . ProcessedItemsCount } ({ value . ProcessedSize . ToSizeString ( ) } ) / { value . ItemsCount } ({ value . TotalSize . ToSizeString ( ) } ): { Banner . Progress } %)";
243
233
break ;
244
234
245
235
case ( not 0 , _) :
246
- Banner . Progress = value . ProcessedSize * 100f / value . TotalSize ;
247
- Banner . FullTitle = $ "{ Banner . Title } ({ value . ProcessedSize . ToSizeString ( ) } / { value . TotalSize . ToSizeString ( ) } : { Banner . Progress : 0.00 } %)";
236
+ Banner . Progress = ( int ) ( value . ProcessedSize * 100 / value . TotalSize ) ;
237
+ Banner . FullTitle = $ "{ Banner . Title } ({ value . ProcessedSize . ToSizeString ( ) } / { value . TotalSize . ToSizeString ( ) } : { Banner . Progress } %)";
248
238
break ;
249
239
250
240
case ( _, not 0 ) :
251
- Banner . Progress = value . ProcessedItemsCount * 100f / value . ItemsCount ;
252
- Banner . FullTitle = $ "{ Banner . Title } ({ value . ProcessedItemsCount } / { value . ItemsCount } : { Banner . Progress : 0.00 } %)";
241
+ Banner . Progress = ( int ) ( value . ProcessedItemsCount * 100 / value . ItemsCount ) ;
242
+ Banner . FullTitle = $ "{ Banner . Title } ({ value . ProcessedItemsCount } / { value . ItemsCount } : { Banner . Progress } %)";
253
243
break ;
254
244
255
245
default :
@@ -272,9 +262,7 @@ private void ReportProgressToBanner(FileSystemProgress value)
272
262
OngoingTasksActions . UpdateMedianProgress ( ) ;
273
263
}
274
264
275
- #endregion Private Helpers
276
-
277
- #region Public Helpers
265
+ // Public Helpers
278
266
279
267
public void Remove ( )
280
268
{
@@ -285,8 +273,6 @@ public void RequestCancellation()
285
273
{
286
274
cancellationTokenSource ? . Cancel ( ) ;
287
275
}
288
-
289
- #endregion Public Helpers
290
276
}
291
277
292
278
public class StatusBanner : ObservableObject
@@ -303,9 +289,8 @@ public class StatusBanner : ObservableObject
303
289
304
290
#region Public Properties
305
291
306
- private float progress = 0.0f ;
307
-
308
- public float Progress
292
+ private int progress = 0 ;
293
+ public int Progress
309
294
{
310
295
get => progress ;
311
296
set => SetProperty ( ref progress , value ) ;
0 commit comments