public void DeleteMe() { Array.ForEach(GuidBlockedList.BlockedPaths, path => RegistryEx.DeleteValue(path, this.Value)); if (!this.Guid.Equals(Guid.Empty)) { ExplorerRestarter.Show(); } this.Dispose(); }
public void DeleteMe() { if (AppMessageBox.Show(AppString.Message.ConfirmDelete, MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } Array.ForEach(GuidBlockedList.BlockedPaths, path => RegistryEx.DeleteValue(path, this.Value)); if (!this.Guid.Equals(Guid.Empty)) { ExplorerRestarter.Show(); } int index = this.Parent.Controls.GetChildIndex(this); index -= (index < this.Parent.Controls.Count - 1) ? 0 : 1; this.Parent.Controls[index].Focus(); this.Dispose(); }
private void AddNewItem() { NewItem newItem = new NewItem(AppString.Item.AddGuidBlockedItem); this.AddItem(newItem); newItem.AddNewItem += (sender, e) => { using (InputDialog dlg = new InputDialog { Title = AppString.Dialog.InputGuid }) { if (GuidEx.TryParse(Clipboard.GetText(), out Guid guid)) { dlg.Text = guid.ToString(); } if (dlg.ShowDialog() != DialogResult.OK) { return; } if (GuidEx.TryParse(dlg.Text, out guid)) { Array.ForEach(GuidBlockedItem.BlockedPaths, path => { Registry.SetValue(path, guid.ToString("B"), string.Empty); }); for (int i = 1; i < Controls.Count; i++) { if (((GuidBlockedItem)Controls[i]).Guid.Equals(guid)) { MessageBoxEx.Show(AppString.MessageBox.HasBeenAdded); return; } } this.InsertItem(new GuidBlockedItem(dlg.Text), 1); ExplorerRestarter.Show(); } else { MessageBoxEx.Show(AppString.MessageBox.MalformedGuid); } } }; }
private void LoadWinXItems() { string[] dirPaths = Directory.GetDirectories(WinXPath); Array.Reverse(dirPaths); bool sortable = AppConfig.WinXSortable; bool sorted = false; foreach (string dirPath in dirPaths) { WinXGroupItem groupItem = new WinXGroupItem(dirPath); this.AddItem(groupItem); string[] lnkPaths; if (sortable) { lnkPaths = GetSortedPaths(dirPath, out bool flag); if (flag) { sorted = true; } } else { lnkPaths = Directory.GetFiles(dirPath, "*.lnk"); Array.Reverse(lnkPaths); } foreach (string path in lnkPaths) { WinXItem winXItem = new WinXItem(path, groupItem); winXItem.BtnMoveDown.Visible = winXItem.BtnMoveUp.Visible = sortable; this.AddItem(winXItem); } groupItem.IsFold = true; } if (sorted) { ExplorerRestarter.Show(); MessageBoxEx.Show(AppString.Message.WinXSorted); } }
private void AddNewItem() { NewItem newItem = new NewItem(); this.AddItem(newItem); PictureButton btnCreateDir = new PictureButton(AppImage.NewFolder); MyToolTip.SetToolTip(btnCreateDir, AppString.Tip.CreateGroup); newItem.AddCtr(btnCreateDir); btnCreateDir.MouseDown += (sender, e) => CreateNewGroup(); newItem.AddNewItem += (sender, e) => { using (NewLnkFileDialog dlg1 = new NewLnkFileDialog()) { if (dlg1.ShowDialog() != DialogResult.OK) { return; } using (SelectDialog dlg2 = new SelectDialog()) { dlg2.Title = AppString.Dialog.SelectGroup; dlg2.Items = GetGroupNames(); if (dlg2.ShowDialog() != DialogResult.OK) { return; } string dirName = dlg2.Selected; string dirPath = $@"{WinXPath}\{dirName}"; string itemText = dlg1.ItemText; string targetPath = dlg1.ItemFilePath; string arguments = dlg1.Arguments; string workDir = Path.GetDirectoryName(targetPath); string extension = Path.GetExtension(targetPath).ToLower(); string fileName = Path.GetFileNameWithoutExtension(targetPath); int count = Directory.GetFiles(dirPath, "*.lnk").Length; string index = (count + 1).ToString().PadLeft(2, '0'); string lnkName = $"{index} - {fileName}.lnk"; string lnkPath = $@"{dirPath}\{lnkName}"; using (ShellLink shellLink = new ShellLink(lnkPath)) { if (extension == ".lnk") { File.Copy(targetPath, lnkPath); shellLink.Load(); } else { shellLink.TargetPath = targetPath; shellLink.Arguments = arguments; shellLink.WorkingDirectory = workDir; } shellLink.Description = itemText; shellLink.Save(); } DesktopIni.SetLocalizedFileNames(lnkPath, itemText); foreach (MyListItem ctr in this.Controls) { if (ctr is WinXGroupItem groupItem && groupItem.Text == dirName) { WinXItem item = new WinXItem(lnkPath, groupItem) { Visible = !groupItem.IsFold }; item.BtnMoveDown.Visible = item.BtnMoveUp.Visible = AppConfig.WinXSortable; this.InsertItem(item, this.GetItemIndex(groupItem) + 1); break; } } WinXHasher.HashLnk(lnkPath); ExplorerRestarter.Show(); } } }; }