1
1
// Copyright (c) 2023 Files Community
2
2
// Licensed under the MIT License. See the LICENSE.
3
3
4
- using CommunityToolkit . Mvvm . DependencyInjection ;
5
4
using Files . App . Dialogs ;
6
- using Files . App . Extensions ;
7
- using Files . App . Filesystem ;
8
5
using Files . App . Filesystem . StorageItems ;
9
- using Files . App . Interacts ;
10
- using Files . App . ViewModels ;
11
6
using Files . App . ViewModels . Dialogs ;
12
7
using Files . Backend . Enums ;
13
8
using Files . Backend . Extensions ;
14
9
using Files . Backend . Services ;
15
- using Files . Shared ;
16
- using Files . Shared . Enums ;
17
- using Files . Shared . Extensions ;
18
10
using Microsoft . Extensions . Logging ;
19
- using Microsoft . UI . Xaml . Controls ;
20
- using System ;
21
11
using System . Collections . Concurrent ;
22
12
using System . IO ;
23
- using System . Linq ;
24
- using System . Threading ;
25
- using System . Threading . Tasks ;
26
13
using Windows . ApplicationModel . DataTransfer ;
27
14
using Windows . Storage ;
28
15
using Windows . System ;
@@ -35,19 +22,19 @@ public static class UIFilesystemHelpers
35
22
36
23
public static async Task CutItem ( IShellPage associatedInstance )
37
24
{
38
- DataPackage dataPackage = new DataPackage ( )
25
+ var dataPackage = new DataPackage ( )
39
26
{
40
27
RequestedOperation = DataPackageOperation . Move
41
28
} ;
42
- ConcurrentBag < IStorageItem > items = new ConcurrentBag < IStorageItem > ( ) ;
29
+ ConcurrentBag < IStorageItem > items = new ( ) ;
43
30
44
31
if ( associatedInstance . SlimContentPage . IsItemSelected )
45
32
{
46
33
// First, reset DataGrid Rows that may be in "cut" command mode
47
34
associatedInstance . SlimContentPage . ItemManipulationModel . RefreshItemsOpacity ( ) ;
48
35
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 (
51
38
string . Empty ,
52
39
string . Format ( "StatusPreparingItemsDetails_Plural" . GetLocalizedResource ( ) , itemsCount ) ,
53
40
0 ,
@@ -144,16 +131,18 @@ await associatedInstance.SlimContentPage.SelectedItems.ToList().ParallelForEachA
144
131
145
132
public static async Task CopyItem ( IShellPage associatedInstance )
146
133
{
147
- DataPackage dataPackage = new DataPackage ( )
134
+ var dataPackage = new DataPackage ( )
148
135
{
149
136
RequestedOperation = DataPackageOperation . Copy
150
137
} ;
151
- ConcurrentBag < IStorageItem > items = new ConcurrentBag < IStorageItem > ( ) ;
138
+ ConcurrentBag < IStorageItem > items = new ( ) ;
152
139
153
140
if ( associatedInstance . SlimContentPage . IsItemSelected )
154
141
{
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 (
157
146
string . Empty ,
158
147
string . Format ( "StatusPreparingItemsDetails_Plural" . GetLocalizedResource ( ) , itemsCount ) ,
159
148
0 ,
@@ -271,8 +260,7 @@ public static async Task<bool> RenameFileItemAsync(ListedItem item, string newNa
271
260
272
261
FilesystemItemType itemType = ( item . PrimaryItemAttribute == StorageItemTypes . Folder ) ? FilesystemItemType . Directory : FilesystemItemType . File ;
273
262
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 ) ;
276
264
277
265
if ( renamed == ReturnResult . Success )
278
266
{
@@ -283,14 +271,14 @@ public static async Task<bool> RenameFileItemAsync(ListedItem item, string newNa
283
271
return false ;
284
272
}
285
273
286
- public static async Task CreateFileFromDialogResultType ( AddItemDialogItemType itemType , ShellNewEntry itemInfo , IShellPage associatedInstance )
274
+ public static async Task CreateFileFromDialogResultType ( AddItemDialogItemType itemType , ShellNewEntry ? itemInfo , IShellPage associatedInstance )
287
275
{
288
276
await CreateFileFromDialogResultTypeForResult ( itemType , itemInfo , associatedInstance ) ;
289
277
}
290
278
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 )
292
280
{
293
- string currentPath = null ;
281
+ string ? currentPath = null ;
294
282
295
283
if ( associatedInstance . SlimContentPage is not null )
296
284
{
@@ -304,7 +292,7 @@ public static async Task<IStorageItem> CreateFileFromDialogResultTypeForResult(A
304
292
}
305
293
306
294
// Skip rename dialog when ShellNewEntry has a Command (e.g. ".accdb", ".gdoc")
307
- string userInput = null ;
295
+ string ? userInput = null ;
308
296
if ( itemType != AddItemDialogItemType . File || itemInfo ? . Command is null )
309
297
{
310
298
DynamicDialog dialog = DynamicDialogFactory . GetFor_RenameDialog ( ) ;
0 commit comments