コード例 #1
0
ファイル: xMenuToolsFiles.cs プロジェクト: yoeria/xMenuTools
        private void MenuDeveloper()
        {
            // Main Menu
            Menu.Items.Add(xMenuToolsMenu);
            xMenuToolsMenu.Text = Resources.xMenuToolsName;

            // Icons
            xMenuToolsMenu.Image = Resources.MAIN_ICON.ToBitmap();
            OpenNotepad.Image    = Resources.notepad.ToBitmap();
            BlockFirewall.Image  = Resources.Firewall.ToBitmap();
            CopyPath.Image       = Resources.CopyPath.ToBitmap();
            CopyName.Image       = Resources.CopyName.ToBitmap();
            Attributes.Image     = Resources.FileAttributes.ToBitmap();
            AttributesMenu.Image = Resources.MAIN_ICON.ToBitmap();

            SymLink.Image       = Resources.SymLink.ToBitmap();
            TakeOwnership.Image = Resources.TakeOwnership.ToBitmap();

            string[] array = SelectedItemPaths.Cast <string>().ToArray();
            AddMenuItems(array);

            // Subscriptions
            OpenNotepad.Click    += (sender, args) => OpenNotepadMethod();
            BlockFirewall.Click  += (sender, args) => BlockFirewallMethod();
            CopyPath.Click       += (sender, args) => CopyPathMethod();
            CopyName.Click       += (sender, args) => CopyNameMethod();
            AttributesMenu.Click += (sender, args) => AttributesMenuMethod();

            HiddenAttributes.Click   += (sender, args) => HiddenAttributesMethod();
            SystemAttributes.Click   += (sender, args) => SystemAttributesMethod();
            ReadOnlyAttributes.Click += (sender, args) => ReadOnlyAttributesMethod();
            SymLink.Click            += (sender, args) => SymLinkMethod();
            TakeOwnership.Click      += (sender, args) => TakeOwnershipMethod();
        }
コード例 #2
0
 private void CopyPathURLMethod()
 {
     Clipboard.Clear();
     string[] array = SelectedItemPaths.Cast <string>().ToArray();
     try
     {
         Clipboard.SetText(new Uri(array.ToStringArray(false)).AbsoluteUri);
     }
     catch (Exception ex)
     {
         EasyLogger.Error(ex);
     }
 }
コード例 #3
0
ファイル: xMenuToolsFiles.cs プロジェクト: yoeria/xMenuTools
 private void ReadOnlyAttributesMethod()
 {
     string[] array = SelectedItemPaths.Cast <string>().ToArray();
     foreach (string item in array)
     {
         FileAttributes attributes = File.GetAttributes(item);
         if ((attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
         {
             attributes = AttributesInfo.RemoveAttribute(attributes, FileAttributes.ReadOnly);
             File.SetAttributes(item, attributes);
         }
         else
         {
             File.SetAttributes(item, File.GetAttributes(item) | FileAttributes.ReadOnly);
         }
     }
 }
コード例 #4
0
ファイル: xMenuToolsFiles.cs プロジェクト: yoeria/xMenuTools
 private void SystemAttributesMethod()
 {
     string[] array = SelectedItemPaths.Cast <string>().ToArray();
     foreach (string item in array)
     {
         FileAttributes attributes = File.GetAttributes(item);
         if ((attributes & FileAttributes.System) == FileAttributes.System)
         {
             attributes = AttributesInfo.RemoveAttribute(attributes, FileAttributes.System);
             File.SetAttributes(item, attributes);
         }
         else
         {
             File.SetAttributes(item, File.GetAttributes(item) | FileAttributes.System);
         }
     }
     StartProcess.StartInfo(AttributesInfo.GetAssembly.AssemblyInformation("directory") + @"\xMenuTools.exe", "-refresh");
 }
コード例 #5
0
 private void TakeOwnershipMethod()
 {
     string[] array = SelectedItemPaths.Cast <string>().ToArray();
     StartProcess.StartInfo(AttributesInfo.GetAssembly.AssemblyInformation("directory") + @"\MenuTools.exe", "\"" + array.ToStringArray(false) + "\" " + "-ownership", false, true);
 }
コード例 #6
0
 private void CopyNameMethod()
 {
     Clipboard.Clear();
     string[] array = SelectedItemPaths.Cast <string>().ToArray();
     Clipboard.SetText(array.ToStringArray(true));
 }
コード例 #7
0
        // Create the Menu
        protected override ContextMenuStrip CreateMenu()
        {
            CheckUserSettings();
            // Main Menu
            using (Menu = new ContextMenuStrip())
            {
                Menu.Name = "MenuToolsDirectory";

                using (MenuToolsMenu = new ToolStripMenuItem())
                {
                    MenuToolsMenu.Name = "MenuToolsMenu";

                    // BlockFirewall
                    using (BlockFirewall = new ToolStripMenuItem())
                    {
                        BlockFirewall.Text = Resources.BlockAllText;
                        BlockFirewall.Name = "BlockFirewall";
                    }
                    // CopyPath
                    using (CopyPath = new ToolStripMenuItem())
                    {
                        CopyPath.Text = Resources.CopyPathText;
                        CopyPath.Name = "CopyPath";
                    }
                    // CopyName
                    using (CopyName = new ToolStripMenuItem())
                    {
                        CopyName.Text = Resources.CopyNameText;
                        CopyName.Name = "CopyName";
                    }
                    // Attributes
                    using (Attributes = new ToolStripMenuItem())
                    {
                        Attributes.Text = Resources.AttributesText;
                        Attributes.Name = "Attributes";

                        // AttributesMenu
                        using (AttributesMenu = new ToolStripMenuItem())
                        {
                            AttributesMenu.Text = Resources.AttributesMenu;
                            AttributesMenu.Name = "AttributesMenu";
                        }
                        // Get : Set Attributes
                        string[] SelectedPath = SelectedItemPaths.Cast <string>().ToArray();
                        if (SelectedPath.Length > 1)
                        {
                            foreach (var item in SelectedPath)
                            {
                                AttributesInfo.GetFileAttributes(item);
                            }
                        }
                        else
                        {
                            AttributesInfo.GetFileAttributes(SelectedPath.ToStringArray(false));
                        }
                        SetFileAttributes();
                    }
                    // SymLink
                    using (SymLink = new ToolStripMenuItem())
                    {
                        SymLink.Text = Resources.CreateSymbolicLink;
                        SymLink.Name = "SymLink";
                    }
                    // TakeOwnership
                    using (TakeOwnership = new ToolStripMenuItem())
                    {
                        TakeOwnership.Text = Resources.TakeOwnershipText;
                        TakeOwnership.Name = "TakeOwnership";
                    }
                }
            }
            MenuDeveloper();

            return(Menu);
        }
コード例 #8
0
ファイル: xMenuToolsFiles.cs プロジェクト: yoeria/xMenuTools
 private void AttributesMenuMethod()
 {
     string[] array = SelectedItemPaths.Cast <string>().ToArray();
     StartProcess.StartInfo(AttributesInfo.GetAssembly.AssemblyInformation("directory") + @"\xMenuTools.exe", "\"" + array.ToStringArray(false) + "\" " + "-attributesmenu");
 }
コード例 #9
0
ファイル: xMenuToolsFiles.cs プロジェクト: yoeria/xMenuTools
 private void BlockFirewallMethod()
 {
     string[] array = SelectedItemPaths.Cast <string>().ToArray();
     StartProcess.StartInfo(AttributesInfo.GetAssembly.AssemblyInformation("directory") + @"\xMenuTools.exe", "\"" + array.ToStringArray() + "\" " + "-firewallfiles", false, true);
 }
コード例 #10
0
ファイル: xMenuToolsFiles.cs プロジェクト: yoeria/xMenuTools
        protected override ContextMenuStrip CreateMenu()
        {
            CheckUserSettings();
            // Main Menu
            using (Menu = new ContextMenuStrip())
            {
                Menu.Name = "xMenuToolsFiles";

                using (xMenuToolsMenu = new ToolStripMenuItem())
                {
                    xMenuToolsMenu.Name = "xMenuToolsMenu";

                    // OpenNotepad
                    using (OpenNotepad = new ToolStripMenuItem())
                    {
                        OpenNotepad.Text = Resources.OpenNotepad;
                        OpenNotepad.Name = "OpenNotepad";
                    }
                    // BlockFirewall
                    using (BlockFirewall = new ToolStripMenuItem())
                    {
                        BlockFirewall.Text = Resources.BlockText;
                        BlockFirewall.Name = "BlockFirewall";
                    }
                    // CopyPath
                    using (CopyPath = new ToolStripMenuItem())
                    {
                        CopyPath.Text = Resources.CopyPathText;
                        CopyPath.Name = "CopyPath";
                    }
                    // CopyName
                    using (CopyName = new ToolStripMenuItem())
                    {
                        CopyName.Text = Resources.CopyNameText;
                        CopyName.Name = "CopyName";
                    }
                    // Attributes
                    using (Attributes = new ToolStripMenuItem())
                    {
                        Attributes.Name = "Attributes";

                        Attributes.Text = Resources.AttributesText;
                        // AttributesMenu
                        using (AttributesMenu = new ToolStripMenuItem())
                        {
                            AttributesMenu.Text = Resources.AttributesMenu;
                            AttributesMenu.Name = "AttributesMenu";
                        }
                        // Get : Set Attributes
                        string[] SelectedPath = SelectedItemPaths.Cast <string>().ToArray();
                        if (SelectedPath.Length > 1)
                        {
                            foreach (string item in SelectedPath)
                            {
                                try
                                {
                                    AttributesInfo.GetFileAttributes(item);
                                }
                                catch (Exception 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");
                                }
                            }
                        }
                        else
                        {
                            try
                            {
                                AttributesInfo.GetFileAttributes(SelectedPath.ToStringArray(false));
                            }
                            catch (Exception 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");
                            }
                        }
                        SetFileAttributes();
                    }
                    // SymLink
                    using (SymLink = new ToolStripMenuItem())
                    {
                        SymLink.Text = Resources.CreateSymbolicLink;
                        SymLink.Name = "SymLink";
                    }
                    // TakeOwnership
                    using (TakeOwnership = new ToolStripMenuItem())
                    {
                        TakeOwnership.Text = Resources.TakeOwnershipText;
                        TakeOwnership.Name = "TakeOwnership";
                    }
                }
            }
            MenuDeveloper();

            return(Menu);
        }
コード例 #11
0
 private void CopyLONGPathMethod()
 {
     Clipboard.Clear();
     string[] array = SelectedItemPaths.Cast <string>().ToArray();
     Clipboard.SetText(@"\\?\" + array.ToStringArray(false));
 }