@@ -16,18 +16,12 @@ namespace Files.App.ViewModels
1616{
1717 public class OngoingTasksViewModel : ObservableObject , IOngoingTasksActions
1818 {
19- #region Public Properties
19+ // Public Properties
2020
2121 public ObservableCollection < StatusBanner > StatusBannersSource { get ; private set ; } = new ObservableCollection < StatusBanner > ( ) ;
2222
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
3125 {
3226 get => medianOperationProgressValue ;
3327 private set => SetProperty ( ref medianOperationProgressValue , value ) ;
@@ -82,17 +76,20 @@ public int InfoBadgeValue
8276 get => OngoingOperationsCount > 0 ? OngoingOperationsCount : - 1 ;
8377 }
8478
85- #endregion Public Properties
86-
87- #region Events
79+ // Events
8880
8981 public event EventHandler < PostedStatusBanner > ProgressBannerPosted ;
9082
91- #endregion Events
83+ // Constructors
84+
85+ public OngoingTasksViewModel ( )
86+ {
87+ StatusBannersSource . CollectionChanged += ( s , e ) => OnPropertyChanged ( nameof ( AnyBannersPresent ) ) ;
88+ }
9289
93- #region IOngoingTasksActions
90+ // IOngoingTasksActions
9491
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 )
9693 {
9794 StatusBanner banner = new StatusBanner ( message , title , initialProgress , status , operation ) ;
9895 PostedStatusBanner postedBanner = new PostedStatusBanner ( banner , this ) ;
@@ -105,7 +102,7 @@ public PostedStatusBanner PostBanner(string title, string message, float initial
105102 return postedBanner ;
106103 }
107104
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 )
109106 {
110107 StatusBanner banner = new StatusBanner ( message , title , initialProgress , status , operation )
111108 {
@@ -161,36 +158,31 @@ public void UpdateMedianProgress()
161158 {
162159 if ( AnyOperationsOngoing )
163160 {
164- MedianOperationProgressValue = StatusBannersSource . Where ( ( item ) => item . IsProgressing ) . Average ( x => x . Progress ) ;
161+ MedianOperationProgressValue = ( int ) StatusBannersSource . Where ( ( item ) => item . IsProgressing ) . Average ( x => x . Progress ) ;
165162 }
166163 }
167-
168- #endregion IOngoingTasksActions
169164 }
170165
171166 public class PostedStatusBanner
172167 {
173- #region Private Members
168+ // Private Members
174169
175170 private readonly IOngoingTasksActions OngoingTasksActions ;
176171
177172 private readonly StatusBanner Banner ;
178173
179174 private readonly CancellationTokenSource cancellationTokenSource ;
180175
181- #endregion Private Members
182176
183- #region Public Members
177+ // Public Members
184178
185179 public readonly FileSystemProgress Progress ;
186180
187181 public readonly Progress < FileSystemProgress > ProgressEventSource ;
188182
189183 public CancellationToken CancellationToken => cancellationTokenSource ? . Token ?? default ;
190184
191- #endregion Public Members
192-
193- #region Constructor
185+ // Constructor
194186
195187 public PostedStatusBanner ( StatusBanner banner , IOngoingTasksActions OngoingTasksActions )
196188 {
@@ -211,9 +203,7 @@ public PostedStatusBanner(StatusBanner banner, IOngoingTasksActions OngoingTasks
211203 Progress = new ( ProgressEventSource , status : FileSystemStatusCode . InProgress ) ;
212204 }
213205
214- #endregion Constructor
215-
216- #region Private Helpers
206+ // Private Helpers
217207
218208 private void ReportProgressToBanner ( FileSystemProgress value )
219209 {
@@ -226,10 +216,10 @@ private void ReportProgressToBanner(FileSystemProgress value)
226216
227217 Banner . IsProgressing = ( value . Status & FileSystemStatusCode . InProgress ) != 0 ;
228218
229- if ( value . Percentage is float f )
219+ if ( value . Percentage is int p )
230220 {
231- Banner . Progress = f ;
232- Banner . FullTitle = $ "{ Banner . Title } ({ Banner . Progress : 0.00 } %)";
221+ Banner . Progress = p ;
222+ Banner . FullTitle = $ "{ Banner . Title } ({ Banner . Progress } %)";
233223
234224 // TODO: Show detailed progress if Size/Count information available
235225 }
@@ -238,18 +228,18 @@ private void ReportProgressToBanner(FileSystemProgress value)
238228 switch ( value . TotalSize , value . ItemsCount )
239229 {
240230 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 } %)";
243233 break ;
244234
245235 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 } %)";
248238 break ;
249239
250240 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 } %)";
253243 break ;
254244
255245 default :
@@ -272,9 +262,7 @@ private void ReportProgressToBanner(FileSystemProgress value)
272262 OngoingTasksActions . UpdateMedianProgress ( ) ;
273263 }
274264
275- #endregion Private Helpers
276-
277- #region Public Helpers
265+ // Public Helpers
278266
279267 public void Remove ( )
280268 {
@@ -285,8 +273,6 @@ public void RequestCancellation()
285273 {
286274 cancellationTokenSource ? . Cancel ( ) ;
287275 }
288-
289- #endregion Public Helpers
290276 }
291277
292278 public class StatusBanner : ObservableObject
@@ -303,9 +289,8 @@ public class StatusBanner : ObservableObject
303289
304290 #region Public Properties
305291
306- private float progress = 0.0f ;
307-
308- public float Progress
292+ private int progress = 0 ;
293+ public int Progress
309294 {
310295 get => progress ;
311296 set => SetProperty ( ref progress , value ) ;
0 commit comments