11// Copyright (c) 2023 Files Community
22// Licensed under the MIT License. See the LICENSE.
33
4- using CommunityToolkit . Mvvm . DependencyInjection ;
54using Files . App . Dialogs ;
6- using Files . App . Extensions ;
7- using Files . App . Filesystem ;
85using Files . App . Filesystem . StorageItems ;
9- using Files . App . Interacts ;
10- using Files . App . ViewModels ;
116using Files . App . ViewModels . Dialogs ;
127using Files . Backend . Enums ;
138using Files . Backend . Extensions ;
149using Files . Backend . Services ;
15- using Files . Shared ;
16- using Files . Shared . Enums ;
17- using Files . Shared . Extensions ;
1810using Microsoft . Extensions . Logging ;
19- using Microsoft . UI . Xaml . Controls ;
20- using System ;
2111using System . Collections . Concurrent ;
2212using System . IO ;
23- using System . Linq ;
24- using System . Threading ;
25- using System . Threading . Tasks ;
2613using Windows . ApplicationModel . DataTransfer ;
2714using Windows . Storage ;
2815using Windows . System ;
@@ -35,19 +22,19 @@ public static class UIFilesystemHelpers
3522
3623 public static async Task CutItem ( IShellPage associatedInstance )
3724 {
38- DataPackage dataPackage = new DataPackage ( )
25+ var dataPackage = new DataPackage ( )
3926 {
4027 RequestedOperation = DataPackageOperation . Move
4128 } ;
42- ConcurrentBag < IStorageItem > items = new ConcurrentBag < IStorageItem > ( ) ;
29+ ConcurrentBag < IStorageItem > items = new ( ) ;
4330
4431 if ( associatedInstance . SlimContentPage . IsItemSelected )
4532 {
4633 // First, reset DataGrid Rows that may be in "cut" command mode
4734 associatedInstance . SlimContentPage . ItemManipulationModel . RefreshItemsOpacity ( ) ;
4835
49- var itemsCount = associatedInstance . SlimContentPage . SelectedItems . Count ;
50- PostedStatusBanner banner = itemsCount > 50 ? ongoingTasksViewModel . PostOperationBanner (
36+ var itemsCount = associatedInstance . SlimContentPage . SelectedItems ! . Count ;
37+ var banner = itemsCount > 50 ? ongoingTasksViewModel . PostOperationBanner (
5138 string . Empty ,
5239 string . Format ( "StatusPreparingItemsDetails_Plural" . GetLocalizedResource ( ) , itemsCount ) ,
5340 0 ,
@@ -144,16 +131,18 @@ await associatedInstance.SlimContentPage.SelectedItems.ToList().ParallelForEachA
144131
145132 public static async Task CopyItem ( IShellPage associatedInstance )
146133 {
147- DataPackage dataPackage = new DataPackage ( )
134+ var dataPackage = new DataPackage ( )
148135 {
149136 RequestedOperation = DataPackageOperation . Copy
150137 } ;
151- ConcurrentBag < IStorageItem > items = new ConcurrentBag < IStorageItem > ( ) ;
138+ ConcurrentBag < IStorageItem > items = new ( ) ;
152139
153140 if ( associatedInstance . SlimContentPage . IsItemSelected )
154141 {
155- var itemsCount = associatedInstance . SlimContentPage . SelectedItems . Count ;
156- PostedStatusBanner banner = itemsCount > 50 ? ongoingTasksViewModel . PostOperationBanner (
142+ associatedInstance . SlimContentPage . ItemManipulationModel . RefreshItemsOpacity ( ) ;
143+
144+ var itemsCount = associatedInstance . SlimContentPage . SelectedItems ! . Count ;
145+ var banner = itemsCount > 50 ? ongoingTasksViewModel . PostOperationBanner (
157146 string . Empty ,
158147 string . Format ( "StatusPreparingItemsDetails_Plural" . GetLocalizedResource ( ) , itemsCount ) ,
159148 0 ,
@@ -271,8 +260,7 @@ public static async Task<bool> RenameFileItemAsync(ListedItem item, string newNa
271260
272261 FilesystemItemType itemType = ( item . PrimaryItemAttribute == StorageItemTypes . Folder ) ? FilesystemItemType . Directory : FilesystemItemType . File ;
273262
274- ReturnResult renamed = ReturnResult . InProgress ;
275- renamed = await associatedInstance . FilesystemHelpers . RenameAsync ( StorageHelpers . FromPathAndType ( item . ItemPath , itemType ) , newName , NameCollisionOption . FailIfExists , true , showExtensionDialog ) ;
263+ ReturnResult renamed = await associatedInstance . FilesystemHelpers . RenameAsync ( StorageHelpers . FromPathAndType ( item . ItemPath , itemType ) , newName , NameCollisionOption . FailIfExists , true , showExtensionDialog ) ;
276264
277265 if ( renamed == ReturnResult . Success )
278266 {
@@ -283,14 +271,14 @@ public static async Task<bool> RenameFileItemAsync(ListedItem item, string newNa
283271 return false ;
284272 }
285273
286- public static async Task CreateFileFromDialogResultType ( AddItemDialogItemType itemType , ShellNewEntry itemInfo , IShellPage associatedInstance )
274+ public static async Task CreateFileFromDialogResultType ( AddItemDialogItemType itemType , ShellNewEntry ? itemInfo , IShellPage associatedInstance )
287275 {
288276 await CreateFileFromDialogResultTypeForResult ( itemType , itemInfo , associatedInstance ) ;
289277 }
290278
291- public static async Task < IStorageItem > CreateFileFromDialogResultTypeForResult ( AddItemDialogItemType itemType , ShellNewEntry itemInfo , IShellPage associatedInstance )
279+ public static async Task < IStorageItem ? > CreateFileFromDialogResultTypeForResult ( AddItemDialogItemType itemType , ShellNewEntry ? itemInfo , IShellPage associatedInstance )
292280 {
293- string currentPath = null ;
281+ string ? currentPath = null ;
294282
295283 if ( associatedInstance . SlimContentPage is not null )
296284 {
@@ -304,7 +292,7 @@ public static async Task<IStorageItem> CreateFileFromDialogResultTypeForResult(A
304292 }
305293
306294 // Skip rename dialog when ShellNewEntry has a Command (e.g. ".accdb", ".gdoc")
307- string userInput = null ;
295+ string ? userInput = null ;
308296 if ( itemType != AddItemDialogItemType . File || itemInfo ? . Command is null )
309297 {
310298 DynamicDialog dialog = DynamicDialogFactory . GetFor_RenameDialog ( ) ;
0 commit comments