@@ -285,35 +285,51 @@ 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
-
296
293
if ( hasChildren ) {
297
- if ( files . Count == 1 )
298
- question = GettextCatalog . GetString ( "Are you sure you want to delete the file {0} and " +
294
+ if ( files . Count == 1 ) {
295
+ if ( fileExists )
296
+ question = GettextCatalog . GetString ( "Are you sure you want to delete the file {0} and " +
297
+ "its code-behind children from project {1}?" ,
298
+ Path . GetFileName ( files [ 0 ] . Name ) , files [ 0 ] . Project . Name ) ;
299
+ else
300
+ question = GettextCatalog . GetString ( "Are you sure you want to remove the file {0} and " +
299
301
"its code-behind children from project {1}?" ,
300
302
Path . GetFileName ( files [ 0 ] . Name ) , files [ 0 ] . Project . Name ) ;
301
- else
302
- question = GettextCatalog . GetString ( "Are you sure you want to delete the selected files and " +
303
+ } else {
304
+ if ( fileExists )
305
+ question = GettextCatalog . GetString ( "Are you sure you want to delete the selected files and " +
303
306
"their code-behind children from the project?" ) ;
307
+ else
308
+ question = GettextCatalog . GetString ( "Are you sure you want to remove the selected files and " +
309
+ "their code-behind children from the project?" ) ;
310
+ }
304
311
} else {
305
- if ( files . Count == 1 )
306
- question = GettextCatalog . GetString ( "Are you sure you want to delete file {0} from project {1}?" ,
312
+ if ( files . Count == 1 ) {
313
+ if ( fileExists )
314
+ question = GettextCatalog . GetString ( "Are you sure you want to delete file {0} from project {1}?" ,
307
315
Path . GetFileName ( files [ 0 ] . Name ) , files [ 0 ] . Project . Name ) ;
308
- else
309
- question = GettextCatalog . GetString ( "Are you sure you want to delete the selected files from the project?" ) ;
316
+ else
317
+ question = GettextCatalog . GetString ( "Are you sure you want to remove file {0} from project {1}?" ,
318
+ Path . GetFileName ( files [ 0 ] . Name ) , files [ 0 ] . Project . Name ) ;
319
+
320
+ } else {
321
+ if ( fileExists )
322
+ question = GettextCatalog . GetString ( "Are you sure you want to delete the selected files from the project?" ) ;
323
+ else
324
+ question = GettextCatalog . GetString ( "Are you sure you want to remove the selected files from the project?" ) ;
325
+ }
310
326
}
311
-
312
- var result = MessageService . AskQuestion ( question , GetDeleteConfirmationButtons ( filesExist ) ) ;
313
- if ( result != AlertButton . Delete )
314
- return ;
315
327
316
- RemoveFilesFromProject ( true , files ) ;
328
+ var result = MessageService . AskQuestion ( question , new [ ] { AlertButton . Cancel , fileExists ? AlertButton . Delete : AlertButton . Remove } ) ;
329
+ if ( result == AlertButton . Cancel )
330
+ return ;
331
+ else
332
+ RemoveFilesFromProject ( fileExists , files ) ;
317
333
}
318
334
319
335
IdeApp . ProjectOperations . SaveAsync ( projects ) ;
@@ -323,18 +339,13 @@ public override void DeleteMultipleItems ()
323
339
[ AllowMultiSelection ]
324
340
void OnUpdateDeleteMultipleItems ( CommandInfo info )
325
341
{
342
+ var files = new List < ProjectFile > ( ) ;
326
343
foreach ( var node in CurrentNodes ) {
327
344
var pf = ( ProjectFile ) node . DataItem ;
328
- if ( pf . IsLink )
329
- info . Text = GettextCatalog . GetString ( "Remove" ) ;
345
+ files . Add ( pf ) ;
330
346
}
331
- }
332
-
333
- static AlertButton [ ] GetDeleteConfirmationButtons ( bool includeDelete )
334
- {
335
- if ( includeDelete )
336
- return new [ ] { AlertButton . Cancel , AlertButton . Delete } ;
337
- return new [ ] { AlertButton . Cancel } ;
347
+ if ( ! CheckAnyFileExists ( files ) )
348
+ info . Text = GettextCatalog . GetString ( "Remove" ) ;
338
349
}
339
350
340
351
[ CommandHandler ( ProjectCommands . ExcludeFromProject ) ]
@@ -379,7 +390,7 @@ public void RemoveFilesFromProject (bool delete, List<ProjectFile> files)
379
390
380
391
// Delete file before removing them from the project to avoid Remove items being added
381
392
// if the project is currently being saved in memory or to disk.
382
- if ( delete && ! file . IsLink )
393
+ if ( delete && ! file . IsLink && File . Exists ( file . Name ) )
383
394
FileService . DeleteFile ( file . Name ) ;
384
395
project . Files . Remove ( file ) ;
385
396
}
0 commit comments