// Add Menu Items private void AddMenuItems(string[] array) { try { // Disabler bool isShortcut = false; bool isExeDllFile = false; foreach (string path in array) { try { if (Path.GetExtension(path) == ".lnk") { isShortcut = true; } if (Path.GetExtension(path) != ".exe" && Path.GetExtension(path) != ".dll") { isExeDllFile = false; } if (Path.GetExtension(path) == ".exe" || Path.GetExtension(path) == ".dll") { isExeDllFile = true; } if (Directory.Exists(ShortcutHandler.GetShortcutTarget(path))) { } } catch (Exception ex) { EasyLogger.Error(ex.Message + " Error at ShortcutHandler.GetShortcutTarget(path)"); continue; } } object OpenNotepadFiles = xMenuToolsSettings.GetValue("OpenNotepadFiles"); if (OpenNotepadFiles != null) { if (OpenNotepadFiles.ToString() == "1") { xMenuToolsMenu.DropDownItems.Add(OpenNotepad); } } object BlockWithFirewallFiles = xMenuToolsSettings.GetValue("BlockWithFirewallFiles"); if (BlockWithFirewallFiles != null) { if (BlockWithFirewallFiles.ToString() == "1") { xMenuToolsMenu.DropDownItems.Add(BlockFirewall); } } object CopyPathFiles = xMenuToolsSettings.GetValue("CopyPathFiles"); if (CopyPathFiles != null && !isShortcut) { if (CopyPathFiles.ToString() == "1") { xMenuToolsMenu.DropDownItems.Add(CopyPath); } } object CopyNameFiles = xMenuToolsSettings.GetValue("CopyNameFiles"); if (CopyNameFiles != null && !isShortcut) { if (CopyNameFiles.ToString() == "1") { xMenuToolsMenu.DropDownItems.Add(CopyName); } } object AttributesFiles = xMenuToolsSettings.GetValue("AttributesFiles"); if (AttributesFiles != null) { if (AttributesFiles.ToString() == "1") { xMenuToolsMenu.DropDownItems.Add(Attributes); Attributes.DropDownItems.Add(AttributesMenu); Attributes.DropDownItems.Add(new ToolStripSeparator()); Attributes.DropDownItems.Add(HiddenAttributes); Attributes.DropDownItems.Add(SystemAttributes); Attributes.DropDownItems.Add(ReadOnlyAttributes); } } object SymlinkFiles = xMenuToolsSettings.GetValue("SymlinkFiles"); if (SymlinkFiles != null) { if (SymlinkFiles.ToString() == "1") { xMenuToolsMenu.DropDownItems.Add(SymLink); } } object TakeOwnershipFiles = xMenuToolsSettings.GetValue("TakeOwnershipFiles"); if (TakeOwnershipFiles != null) { if (TakeOwnershipFiles.ToString() == "1") { xMenuToolsMenu.DropDownItems.Add(TakeOwnership); } } object AttributesShortcuts = xMenuToolsSettings.GetValue("AttributesShortcuts"); if (AttributesShortcuts != null && isShortcut) { if (AttributesShortcuts.ToString() == "1") { xMenuToolsMenu.DropDownItems.Add(Attributes); } else { Attributes.Dispose(); } } object OpenNotepadShort = xMenuToolsSettings.GetValue("OpenNotepadShort"); if (OpenNotepadShort != null && isShortcut) { if (OpenNotepadShort.ToString() == "1") { xMenuToolsMenu.DropDownItems.Add(OpenNotepad); } else { OpenNotepad.Dispose(); } } object CopyPathShortFiles = xMenuToolsSettings.GetValue("CopyPathShortFiles"); if (CopyPathShortFiles != null && isShortcut) { if (CopyPathShortFiles.ToString() == "1") { xMenuToolsMenu.DropDownItems.Add(CopyPath); } } object CopyNameShortFiles = xMenuToolsSettings.GetValue("CopyNameShortFiles"); if (CopyNameShortFiles != null && isShortcut) { if (CopyNameShortFiles.ToString() == "1") { xMenuToolsMenu.DropDownItems.Add(CopyName); } } MenuItemDisabler(isShortcut, isExeDllFile); } catch (System.ComponentModel.Win32Exception ex) { StartProcess.StartInfo(AttributesInfo.GetAssembly.AssemblyInformation("directory") + @"\xMenuTools.exe", "\"" + ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine + ex.Source + Environment.NewLine + ex.GetBaseException() + Environment.NewLine + ex.TargetSite + "\"" + " -catchhandler"); } }
// Add Menu Items private void AddMenuItems(string[] array) { try { // Disabler bool isShortcut = false; bool isExeDllFile = false; bool isFile = true; foreach (string path in array) { try { if (Path.GetExtension(path) == ".lnk") { isShortcut = true; } if (Path.GetExtension(path) != ".exe" && Path.GetExtension(path) != ".dll") { isExeDllFile = false; } if (Path.GetExtension(path) == ".exe" || Path.GetExtension(path) == ".dll") { isExeDllFile = true; } if (Directory.Exists(ShortcutHandler.GetShortcutTarget(path))) { isFile = false; } } catch (Exception ex) { Console.WriteLine(ex.Message + " Error at ShortcutHandler.GetShortcutTarget(path)"); continue; } } object OpenNotepadFiles = MenuToolsSettings.GetValue("OpenNotepadFiles"); if (OpenNotepadFiles != null) { if (OpenNotepadFiles.ToString() == "1") { MenuToolsMenu.DropDownItems.Add(OpenNotepad); } } object BlockWithFirewallFiles = MenuToolsSettings.GetValue("BlockWithFirewallFiles"); if (BlockWithFirewallFiles != null) { if (BlockWithFirewallFiles.ToString() == "1") { MenuToolsMenu.DropDownItems.Add(BlockFirewall); } } object CopyPathFiles = MenuToolsSettings.GetValue("CopyPathFiles"); if (CopyPathFiles != null && !isShortcut) { if (CopyPathFiles.ToString() == "1") { MenuToolsMenu.DropDownItems.Add(CopyPath); } } object CopyNameFiles = MenuToolsSettings.GetValue("CopyNameFiles"); if (CopyNameFiles != null && !isShortcut) { if (CopyNameFiles.ToString() == "1") { MenuToolsMenu.DropDownItems.Add(CopyName); } } object AttributesFiles = MenuToolsSettings.GetValue("AttributesFiles"); if (AttributesFiles != null) { if (AttributesFiles.ToString() == "1") { MenuToolsMenu.DropDownItems.Add(Attributes); Attributes.DropDownItems.Add(AttributesMenu); Attributes.DropDownItems.Add(new ToolStripSeparator()); Attributes.DropDownItems.Add(HiddenAttributes); Attributes.DropDownItems.Add(SystemAttributes); Attributes.DropDownItems.Add(ReadOnlyAttributes); } } object SymlinkFiles = MenuToolsSettings.GetValue("SymlinkFiles"); if (SymlinkFiles != null) { if (SymlinkFiles.ToString() == "1") { MenuToolsMenu.DropDownItems.Add(SymLink); } } object TakeOwnershipFiles = MenuToolsSettings.GetValue("TakeOwnershipFiles"); if (TakeOwnershipFiles != null) { if (TakeOwnershipFiles.ToString() == "1") { MenuToolsMenu.DropDownItems.Add(TakeOwnership); } } object OpenNotepadShort = MenuToolsSettings.GetValue("OpenNotepadShort"); if (OpenNotepadShort != null && isShortcut) { MenuToolsMenu.DropDownItems.Add(OpenNotepad); } object CopyPathShortFiles = MenuToolsSettings.GetValue("CopyPathShortFiles"); if (CopyPathShortFiles != null && isShortcut) { if (CopyPathShortFiles.ToString() == "1") { MenuToolsMenu.DropDownItems.Add(CopyPath); } } object CopyNameShortFiles = MenuToolsSettings.GetValue("CopyNameShortFiles"); if (CopyNameShortFiles != null && isShortcut) { if (CopyNameShortFiles.ToString() == "1") { MenuToolsMenu.DropDownItems.Add(CopyName); } } MenuItemDisabler(isShortcut, isExeDllFile); } catch (System.ComponentModel.Win32Exception ex) { MessageBox.Show(ex.Message); } }