/ src / modules / cmdpal / ext / Microsoft.CmdPal.Ext.System / EmptyRecycleBinConfirmation.cs
EmptyRecycleBinConfirmation.cs
 1  // Copyright (c) Microsoft Corporation
 2  // The Microsoft Corporation licenses this file to you under the MIT license.
 3  // See the LICENSE file in the project root for more information.
 4  
 5  using Microsoft.CmdPal.Ext.System.Helpers;
 6  using Microsoft.CommandPalette.Extensions.Toolkit;
 7  
 8  namespace Microsoft.CmdPal.Ext.System;
 9  
10  public sealed partial class EmptyRecycleBinConfirmation : InvokableCommand
11  {
12      public EmptyRecycleBinConfirmation(bool settingEmptyRBSuccesMsg)
13      {
14          Name = Resources.Microsoft_plugin_command_name_empty;
15          _settingEmptyRBSuccesMsg = settingEmptyRBSuccesMsg;
16      }
17  
18      public override CommandResult Invoke()
19      {
20          if (ResultHelper.ExecutingEmptyRecycleBinTask)
21          {
22              return CommandResult.ShowToast(new ToastArgs() { Message = Resources.Microsoft_plugin_sys_RecycleBin_EmptyTaskRunning });
23          }
24  
25          var confirmArgs = new ConfirmationArgs()
26          {
27              Title = Resources.Microsoft_plugin_sys_confirmation,
28              Description = Resources.EmptyRecycleBin_ConfirmationDialog_Description,
29              PrimaryCommand = new EmptyRecycleBinCommand(_settingEmptyRBSuccesMsg),
30              IsPrimaryCommandCritical = true,
31          };
32  
33          return CommandResult.Confirm(confirmArgs);
34      }
35  
36      private bool _settingEmptyRBSuccesMsg;
37  }