@@ -285,35 +285,34 @@ public override void DeleteMultipleItems ()
285
285
}
286
286
287
287
string question ;
288
- bool allLinkedFiles = CheckAllLinkedFile ( files ) ;
288
+ bool fileExists = CheckAnyFileExists ( files ) ;
289
289
290
- if ( allLinkedFiles ) {
290
+ if ( CheckAllLinkedFile ( files ) ) {
291
291
RemoveFilesFromProject ( false , files ) ;
292
292
} else {
293
-
294
- bool filesExist = CheckAnyFileExists ( files ) ;
295
-
293
+ string behavior = fileExists ? "delete" : "remove" ;
296
294
if ( hasChildren ) {
297
295
if ( files . Count == 1 )
298
- question = GettextCatalog . GetString ( "Are you sure you want to delete the file {0 } and " +
299
- "its code-behind children from project {1 }?" ,
300
- Path . GetFileName ( files [ 0 ] . Name ) , files [ 0 ] . Project . Name ) ;
296
+ question = GettextCatalog . GetString ( "Are you sure you want to {0} the file {1 } and " +
297
+ "its code-behind children from project {2 }?" ,
298
+ behavior , Path . GetFileName ( files [ 0 ] . Name ) , files [ 0 ] . Project . Name ) ;
301
299
else
302
- question = GettextCatalog . GetString ( "Are you sure you want to delete the selected files and " +
303
- "their code-behind children from the project?" ) ;
300
+ question = GettextCatalog . GetString ( "Are you sure you want to {0} the selected files and " +
301
+ "their code-behind children from the project?" , behavior ) ;
304
302
} else {
305
303
if ( files . Count == 1 )
306
- question = GettextCatalog . GetString ( "Are you sure you want to delete file {0 } from project {1 }?" ,
307
- Path . GetFileName ( files [ 0 ] . Name ) , files [ 0 ] . Project . Name ) ;
304
+ question = GettextCatalog . GetString ( "Are you sure you want to {0} file {1 } from project {2 }?" ,
305
+ behavior , Path . GetFileName ( files [ 0 ] . Name ) , files [ 0 ] . Project . Name ) ;
308
306
else
309
- question = GettextCatalog . GetString ( "Are you sure you want to delete the selected files from the project?" ) ;
307
+ question = GettextCatalog . GetString ( "Are you sure you want to {0} the selected files from the project?" , behavior ) ;
310
308
}
311
-
312
- var result = MessageService . AskQuestion ( question , GetDeleteConfirmationButtons ( filesExist ) ) ;
313
- if ( result != AlertButton . Delete )
314
- return ;
315
309
316
- RemoveFilesFromProject ( true , files ) ;
310
+ var result = MessageService . AskQuestion ( question , new [ ] { AlertButton . Cancel , fileExists ? AlertButton . Delete : AlertButton . Remove } ) ;
311
+
312
+ if ( result == AlertButton . Cancel )
313
+ return ;
314
+ else
315
+ RemoveFilesFromProject ( fileExists , files ) ;
317
316
}
318
317
319
318
IdeApp . ProjectOperations . SaveAsync ( projects ) ;
@@ -323,18 +322,13 @@ public override void DeleteMultipleItems ()
323
322
[ AllowMultiSelection ]
324
323
void OnUpdateDeleteMultipleItems ( CommandInfo info )
325
324
{
325
+ var files = new List < ProjectFile > ( ) ;
326
326
foreach ( var node in CurrentNodes ) {
327
327
var pf = ( ProjectFile ) node . DataItem ;
328
- if ( pf . IsLink )
329
- info . Text = GettextCatalog . GetString ( "Remove" ) ;
328
+ files . Add ( pf ) ;
330
329
}
331
- }
332
-
333
- static AlertButton [ ] GetDeleteConfirmationButtons ( bool includeDelete )
334
- {
335
- if ( includeDelete )
336
- return new [ ] { AlertButton . Cancel , AlertButton . Delete } ;
337
- return new [ ] { AlertButton . Cancel } ;
330
+ if ( ! CheckAnyFileExists ( files ) )
331
+ info . Text = GettextCatalog . GetString ( "Remove" ) ;
338
332
}
339
333
340
334
[ CommandHandler ( ProjectCommands . ExcludeFromProject ) ]
@@ -379,7 +373,7 @@ public void RemoveFilesFromProject (bool delete, List<ProjectFile> files)
379
373
380
374
// Delete file before removing them from the project to avoid Remove items being added
381
375
// if the project is currently being saved in memory or to disk.
382
- if ( delete && ! file . IsLink )
376
+ if ( delete && ! file . IsLink && File . Exists ( file . Name ) )
383
377
FileService . DeleteFile ( file . Name ) ;
384
378
project . Files . Remove ( file ) ;
385
379
}
0 commit comments