示例#1
0
 public DeleteMeMenuItem(ITsiDeleteItem item) : base(AppString.Menu.Delete)
 {
     this.Click += (sender, e) =>
     {
         if (MessageBoxEx.Show(AppString.MessageBox.ConfirmDeletePermanently,
                               MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             item.DeleteMe();
         }
     };
 }
 public DeleteMeMenuItem(ITsiDeleteItem item) : base(AppString.Menu.Delete)
 {
     this.Click += (sender, e) =>
     {
         if (item is ITsiRegDeleteItem regItem && AppConfig.AutoBackup)
         {
             if (MessageBoxEx.Show(AppString.Message.DeleteButCanRestore,
                                   MessageBoxButtons.YesNo) != DialogResult.Yes)
             {
                 return;
             }
             string date     = DateTime.Today.ToString("yyyy-MM-dd");
             string time     = DateTime.Now.ToString("HH.mm.ss");
             string filePath = $@"{AppConfig.BackupDir}\{date}\{regItem.Text} - {time}.reg";
             Directory.CreateDirectory(Path.GetDirectoryName(filePath));
             RegistryEx.Export(regItem.RegPath, filePath);
         }
 public DeleteMeMenuItem(ITsiDeleteItem item) : base(AppString.Menu.Delete)
 {
     this.Click += (sender, e) =>
     {
         if (MessageBoxEx.Show(AppString.MessageBox.ConfirmDeletePermanently,
                               MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             if (item is ITsiRegDeleteItem regItem && AppConfig.AutoBackup)
             {
                 string date     = DateTime.Today.ToString("yyyy-MM-dd");
                 string fileName = ObjectPath.RemoveIllegalChars(regItem.ItemText);
                 string filePath = $@"{AppConfig.BackupDir}\{date}\{fileName}.reg";
                 filePath = ObjectPath.GetNewPathWithIndex(filePath, ObjectPath.PathType.File);
                 Directory.CreateDirectory(Path.GetDirectoryName(filePath));
                 RegistryEx.Export(regItem.RegPath, filePath);
             }
             item.DeleteMe();
         }
     };
 }