private void AddNewItem() { NewItem newItem = new NewItem(); this.AddItem(newItem); newItem.NewItemAdd += (sender, e) => { using (FileExtensionDialog dlg = new FileExtensionDialog()) { if (dlg.ShowDialog() != DialogResult.OK) { return; } string extension = dlg.Extension; string typeName = FileExtensionDialog.GetTypeName(extension, false); using (RegistryKey exKey = Registry.ClassesRoot.OpenSubKey(extension, true)) { exKey.SetValue("", typeName); using (RegistryKey snKey = exKey.CreateSubKey("ShellNew", true)) { snKey.SetValue("NullFile", string.Empty); this.InsertItem(new ShellNewItem(snKey.Name), GetItemIndex(newItem) + 1); } } } }; }
private void AddNewItem() { NewItem newItem = new NewItem(); this.InsertItem(newItem, 0); newItem.AddNewItem += (sender, e) => { using (NewLnkFileDialog dlg = new NewLnkFileDialog()) { dlg.FileFilter = $"{AppString.Dialog.Program}|*.exe;*.bat;*.cmd;*.vbs;*.vbe;*.js;*.jse;*.wsf"; if (dlg.ShowDialog() != DialogResult.OK) { return; } string lnkPath = $@"{SendToPath}\{ObjectPath.RemoveIllegalChars(dlg.ItemText)}.lnk"; lnkPath = ObjectPath.GetNewPathWithIndex(lnkPath, ObjectPath.PathType.File); using (ShellLink shellLink = new ShellLink(lnkPath)) { shellLink.TargetPath = dlg.ItemFilePath; shellLink.WorkingDirectory = Path.GetDirectoryName(dlg.ItemFilePath); shellLink.Arguments = dlg.Arguments; shellLink.Save(); } DesktopIni.SetLocalizedFileNames(lnkPath, dlg.ItemText); this.InsertItem(new SendToItem(lnkPath), 2); } }; }
private void AddNewItem() { NewItem newItem = new NewItem(); this.AddItem(newItem); newItem.AddNewItem += (sender, e) => { using (FileExtensionDialog dlg = new FileExtensionDialog()) { if (dlg.ShowDialog() != DialogResult.OK) { return; } string extension = dlg.Extension; string openMode = FileExtension.GetOpenMode(extension); if (string.IsNullOrEmpty(openMode)) { MessageBoxEx.Show(AppString.MessageBox.NoOpenModeExtension); return; } foreach (Control ctr in this.Controls) { if (ctr is ShellNewItem item) { if (item.Extension.Equals(extension, StringComparison.OrdinalIgnoreCase)) { MessageBoxEx.Show(AppString.MessageBox.HasBeenAdded); return; } } } using (RegistryKey exKey = Registry.ClassesRoot.OpenSubKey(extension, true)) using (RegistryKey snKey = exKey.CreateSubKey("ShellNew", true)) { string defaultOpenMode = exKey.GetValue("")?.ToString(); if (string.IsNullOrEmpty(defaultOpenMode)) { exKey.SetValue("", openMode); } snKey.SetValue("NullFile", string.Empty); ShellNewItem item = new ShellNewItem(this, snKey.Name); this.AddItem(item); item.Focus(); if (item.ItemText.IsNullOrWhiteSpace()) { item.ItemText = $"{extension.Substring(1)} file"; } if (ShellNewLockItem.IsLocked) { this.SaveSorting(); } } } }; }
private void AddNewItem() { NewItem newItem = new NewItem(); this.InsertItem(newItem, 0); newItem.AddNewItem += () => { using (NewOpenWithDialog dlg = new NewOpenWithDialog()) { if (dlg.ShowDialog() == DialogResult.OK) { this.InsertItem(new OpenWithItem(dlg.RegPath), 2); } } }; }
private void AddNewItem() { NewItem newItem = new NewItem(); this.InsertItem(newItem, 0); newItem.AddNewItem += (sender, e) => { using (NewSendToDialog dlg = new NewSendToDialog()) { if (dlg.ShowDialog() == DialogResult.OK) { this.InsertItem(new SendToItem(dlg.FilePath), 2); } } }; }
private void AddNewItem() { NewItem newItem = new NewItem(); this.AddItem(newItem); newItem.AddNewItem += () => { using (NewIEDialog dlg = new NewIEDialog()) { if (dlg.ShowDialog() != DialogResult.OK) { return; } this.InsertItem(new IEItem(dlg.RegPath), 1); } }; }
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 AddNewItem(string scenePath) { NewItem newItem = new NewItem { Visible = scenePath != null }; this.AddItem(newItem); newItem.AddNewItem += (sender, e) => { bool isShell; if (Scene == Scenes.CommandStore) { isShell = true; } else if (Scene == Scenes.DragDrop) { isShell = false; } else { using (SelectDialog dlg = new SelectDialog()) { dlg.Items = new[] { "Shell", "ShellEx" }; dlg.Title = AppString.Dialog.SelectNewItemType; dlg.Selected = dlg.Items[0]; if (dlg.ShowDialog() != DialogResult.OK) { return; } isShell = dlg.SelectedIndex == 0; } } if (isShell) { this.AddNewShellItem(scenePath); } else { this.AddNewShellExItem(scenePath); } }; }
private void AddNewItem() { NewItem newItem = new NewItem(); this.AddItem(newItem); newItem.AddNewItem += (sender, e) => { using (FileExtensionDialog dlg = new FileExtensionDialog()) { if (dlg.ShowDialog() != DialogResult.OK) { return; } string extension = dlg.Extension; foreach (Control ctr in this.Controls) { if (ctr.GetType() == typeof(ShellNewItem)) { if (((ShellNewItem)ctr).Extension.Equals(extension, StringComparison.OrdinalIgnoreCase)) { MessageBoxEx.Show(AppString.MessageBox.HasBeenAdded); return; } } } string typeName = FileExtensionDialog.GetTypeName(extension, false); using (RegistryKey exKey = Registry.ClassesRoot.OpenSubKey(extension, true)) { exKey.SetValue("", typeName); using (RegistryKey snKey = exKey.CreateSubKey("ShellNew", true)) { snKey.SetValue("NullFile", string.Empty); this.AddItem(new ShellNewItem(this, snKey.Name)); if (LockNewItem.IsLocked()) { this.WriteRegistry(); } } } } }; }
private void AddNewItem() { NewItem newItem = new NewItem(); this.AddItem(newItem); newItem.AddNewItem += () => { using (FileExtensionDialog dlg = new FileExtensionDialog()) { if (dlg.ShowDialog() != DialogResult.OK) { return; } string extension = dlg.Extension; if (extension == ".") { return; } string openMode = FileExtension.GetOpenMode(extension); if (string.IsNullOrEmpty(openMode)) { if (AppMessageBox.Show(AppString.Message.NoOpenModeExtension, MessageBoxButtons.OKCancel) == DialogResult.OK) { ExternalProgram.ShowOpenWithDialog(extension); } return; } foreach (Control ctr in this.Controls) { if (ctr is ShellNewItem item) { if (item.Extension.Equals(extension, StringComparison.OrdinalIgnoreCase)) { AppMessageBox.Show(AppString.Message.HasBeenAdded); return; } } } using (RegistryKey root = Registry.ClassesRoot) using (RegistryKey exKey = root.OpenSubKey(extension, true)) using (RegistryKey snKey = exKey.CreateSubKey("ShellNew", true)) { string defaultOpenMode = exKey.GetValue("")?.ToString(); if (string.IsNullOrEmpty(defaultOpenMode)) { exKey.SetValue("", openMode); } byte[] bytes = GetWebShellNewData(extension); if (bytes != null) { snKey.SetValue("Data", bytes, RegistryValueKind.Binary); } else { snKey.SetValue("NullFile", "", RegistryValueKind.String); } ShellNewItem item = new ShellNewItem(this, snKey.Name); this.AddItem(item); item.Focus(); if (item.ItemText.IsNullOrWhiteSpace()) { item.ItemText = FileExtension.GetExtentionInfo(FileExtension.AssocStr.FriendlyDocName, extension); } if (ShellNewLockItem.IsLocked) { this.SaveSorting(); } } } }; }
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(); } } }; }