Пример #1
0
        private void shortcutCombobox_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.executableTextBox.Text    = "";
            this.argumentsTextBox.Text     = "";
            this.workingFolderTextBox.Text = "";
            this.iconPicturebox.Image      = null;
            this.IconImageList.Images.Clear();
            this.toolStrip1.Items.Clear();

            string name = this.shortcutCombobox.Text;

            if (name.Trim() != "" && name.Trim() != "<New...>")
            {
                SpecialCommandConfigurationElement shortcut = this.shortucts[name];
                if (shortcut != null)
                {
                    this.executableTextBox.Text    = shortcut.Executable;
                    this.argumentsTextBox.Text     = shortcut.Arguments;
                    this.workingFolderTextBox.Text = shortcut.WorkingFolder;
                    this.LoadIconsFromExe();
                }
            }
            else if (name.Trim() == "<New...>")
            {
                this.shortcutCombobox.SelectedIndex = -1;
                this.shortcutCombobox.Focus();
            }
        }
Пример #2
0
        private static void specialItem_Click(object sender, EventArgs e)
        {
            ToolStripItem specialItem = sender as ToolStripItem;
            SpecialCommandConfigurationElement elm = specialItem.Tag as SpecialCommandConfigurationElement;

            elm.Launch();
        }
Пример #3
0
        private static SpecialCommandConfigurationElement CreateCmdCommand()
        {
            var command = new SpecialCommandConfigurationElement("Command Shell");

            command.Executable = @"%systemroot%\system32\cmd.exe";
            return(command);
        }
Пример #4
0
        private static void AddControlPanelApplets(SpecialCommandConfigurationElementCollection commands)
        {
            string controlPanelImage = FileLocations.ControlPanelImage;

            if (!File.Exists(controlPanelImage))
            {
                SaveBitmap(Properties.Resources.ControlPanel, controlPanelImage);
            }

            foreach (FileInfo file in SystemRoot.GetFiles("*.cpl"))
            {
                var command = new SpecialCommandConfigurationElement(file.Name);
                command.Thumbnail = controlPanelImage;
                string thumbName = FileLocations.FormatThumbFileName(file.Name);

                Icon[] fileIcons = IconHandler.IconHandler.IconsFromFile(file.FullName, IconHandler.IconSize.Small);
                if (fileIcons != null && fileIcons.Length > 0)
                {
                    SaveIcon(fileIcons[0], thumbName);
                }

                if (File.Exists(thumbName))
                {
                    command.Thumbnail = thumbName;
                }

                command.Name       = EnsureAppletName(file);
                command.Executable = @"%systemroot%\system32\" + file.Name;
                commands.Add(command);
            }
        }
Пример #5
0
        private static void AddMmcCommands(SpecialCommandConfigurationElementCollection cmdList)
        {
            Icon[] IconsList = IconHandler.IconsFromFile(Path.Combine(SystemRoot.FullName, "mmc.exe"),
                                                         IconSize.Small);
            Random rnd = new Random();

            foreach (FileInfo file in SystemRoot.GetFiles("*.msc"))
            {
                MMCFile fileMMC = new MMCFile(file);

                SpecialCommandConfigurationElement elm1 = new SpecialCommandConfigurationElement(file.Name);

                if (IconsList != null && IconsList.Length > 0)
                {
                    if (fileMMC.SmallIcon != null)
                    {
                        elm1.Thumbnail = fileMMC.SmallIcon.ToBitmap().ImageToBase64(System.Drawing.Imaging.ImageFormat.Png);
                    }
                    else
                    {
                        elm1.Thumbnail = IconsList[rnd.Next(IconsList.Length - 1)].ToBitmap().ImageToBase64(System.Drawing.Imaging.ImageFormat.Png);
                    }

                    elm1.Name = fileMMC.Parsed ? fileMMC.Name : file.Name.Replace(file.Extension, "");
                }

                elm1.Executable = @"%systemroot%\system32\" + file.Name;
                cmdList.Add(elm1);
            }
        }
Пример #6
0
        private void AddSpecialMenuItem(SpecialCommandConfigurationElement commad)
        {
            ToolStripItem specialItem = this.CreateSpecialItem(commad);

            specialItem.Image = ConnectionImageHandler.LoadImage(commad.Thumbnail, Resources.server_administrator_icon);
            specialItem.ImageTransparentColor = Color.Magenta;
            specialItem.Tag    = commad;
            specialItem.Click += specialItem_Click;
        }
Пример #7
0
 internal static void Launch(SpecialCommandConfigurationElement command)
 {
     try
     {
         TryLaunch(command);
     }
     catch (Exception ex)
     {
         string message = String.Format("Could not Launch the shortcut application: '{0}'", command.Name);
         MessageBox.Show(message);
         Logging.Error(message, ex);
     }
 }
Пример #8
0
        private static void TryLaunch(SpecialCommandConfigurationElement command)
        {
            string exe = command.Executable;

            if (exe.Contains("%"))
            {
                exe = exe.Replace("%systemroot%", Environment.GetEnvironmentVariable("systemroot"));
            }

            var startInfo = new ProcessStartInfo(exe, command.Arguments);

            startInfo.WorkingDirectory = command.WorkingFolder;
            Process.Start(startInfo);
        }
Пример #9
0
        private static void AddRegEditCommand(SpecialCommandConfigurationElementCollection cmdList)
        {
            string regEditFile = Path.Combine(SystemRoot.FullName, "regedt32.exe");

            Icon[] regeditIcons = IconHandler.IconsFromFile(regEditFile, IconSize.Small);
            SpecialCommandConfigurationElement regEditElm = new SpecialCommandConfigurationElement("Registry Editor");

            if (regeditIcons != null && regeditIcons.Length > 0)
            {
                regEditElm.Thumbnail = regeditIcons[0].ToBitmap().ImageToBase64(System.Drawing.Imaging.ImageFormat.Png);
            }

            regEditElm.Executable = regEditFile;
            cmdList.Add(regEditElm);
        }
Пример #10
0
        private ToolStripItem CreateSpecialItem(SpecialCommandConfigurationElement commad)
        {
            string commandExeName = commad.Executable.ToLower();

            if (commandExeName.EndsWith("cpl"))
            {
                return(this.cpl.DropDown.Items.Add(commad.Name));
            }
            if (commandExeName.EndsWith("msc"))
            {
                return(this.mgmt.DropDown.Items.Add(commad.Name));
            }

            return(this.other.DropDown.Items.Add(commad.Name));
        }
Пример #11
0
        private void deleteButton_Click(object sender, EventArgs e)
        {
            string name = this.shortcutCombobox.Text;

            if (name.Trim() != "" && name.Trim() != "<New...>")
            {
                SpecialCommandConfigurationElement shortcut = this.shortucts[name];
                if (shortcut != null)
                {
                    this.shortucts.Remove(shortcut);
                    Settings.SpecialCommands = this.shortucts;
                    this.shortucts           = Settings.SpecialCommands;
                }
            }
            this.LoadShortcuts();
        }
Пример #12
0
        private static void AddControlPanelApplets(SpecialCommandConfigurationElementCollection cmdList)
        {
            foreach (FileInfo file in SystemRoot.GetFiles("*.cpl"))
            {
                SpecialCommandConfigurationElement elm1 = new SpecialCommandConfigurationElement(file.Name);

                Icon[] fileIcons = IconHandler.IconsFromFile(file.FullName, IconSize.Small);

                if (fileIcons != null && fileIcons.Length > 0)
                {
                    elm1.Thumbnail  = fileIcons[0].ToBitmap().ImageToBase64(System.Drawing.Imaging.ImageFormat.Png);
                    elm1.Name       = file.Name;
                    elm1.Executable = @"%systemroot%\system32\" + file.Name;
                    cmdList.Add(elm1);
                }
            }
        }
Пример #13
0
        private static SpecialCommandConfigurationElement CreateRegEditCommand()
        {
            const string REG_EDIT_EXE = "regedt32.exe";
            string       regEditFile  = Path.Combine(SystemRoot.FullName, REG_EDIT_EXE);

            Icon[] regeditIcons = IconHandler.IconHandler.IconsFromFile(regEditFile, IconHandler.IconSize.Small);
            var    command      = new SpecialCommandConfigurationElement("Registry Editor");

            if (regeditIcons != null && regeditIcons.Length > 0)
            {
                FileLocations.EnsureImagesDirectory();
                string thumbName = FileLocations.FormatThumbFileName(REG_EDIT_EXE);
                SaveIcon(regeditIcons[0], thumbName);
                command.Thumbnail = thumbName;
            }

            command.Executable = regEditFile;
            return(command);
        }
Пример #14
0
        private static void AddMmcCommands(SpecialCommandConfigurationElementCollection commands)
        {
            Icon[] iconsList = IconHandler.IconHandler.IconsFromFile(Path.Combine(SystemRoot.FullName, "mmc.exe"),
                                                                     IconHandler.IconSize.Small);
            Random rnd = new Random();

            FileLocations.EnsureImagesDirectory();

            foreach (FileInfo file in SystemRoot.GetFiles("*.msc"))
            {
                MMC.MMCFile fileMMC = new MMC.MMCFile(file);
                var         command = new SpecialCommandConfigurationElement(file.Name);

                if (iconsList != null && iconsList.Length > 0)
                {
                    string thumbName = FileLocations.FormatThumbFileName(file.Name);
                    command.Thumbnail = thumbName;

                    if (fileMMC.SmallIcon != null)
                    {
                        SaveIcon(fileMMC.SmallIcon, thumbName);
                    }
                    else
                    {
                        SaveIcon(iconsList[rnd.Next(iconsList.Length - 1)], thumbName);
                    }

                    if (fileMMC.Parsed)
                    {
                        command.Name = fileMMC.Name;
                    }
                    else
                    {
                        command.Name = file.Name.Replace(file.Extension, "");
                    }
                }

                command.Executable = @"%systemroot%\system32\" + file.Name;
                commands.Add(command);
            }
        }
Пример #15
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            string name = this.shortcutCombobox.Text;

            if (name.Trim() != "" && name.Trim() != "<New...>")
            {
                SpecialCommandConfigurationElement shortcut = this.shortucts[name] ??
                                                              new SpecialCommandConfigurationElement();

                shortcut.Name          = name.Trim();
                shortcut.Executable    = this.executableTextBox.Text;
                shortcut.WorkingFolder = this.workingFolderTextBox.Text;
                shortcut.Arguments     = this.argumentsTextBox.Text;
                string imageName = Path.GetFileName(shortcut.Executable) + ".ico";

                string imageFullName = Path.Combine(AssemblyInfo.DirectoryConfigFiles, imageName);
                if (this.iconPicturebox.Image != null)
                {
                    try
                    {
                        this.iconPicturebox.Image.Save(imageFullName);
                    }
                    catch (Exception exc)
                    {
                        Log.Error("Saving icon picture box failed", exc);
                        imageFullName = "";
                    }
                }
                else
                {
                    imageFullName = "";
                }
                shortcut.Thumbnail = imageFullName;
                this.shortucts.Remove(shortcut);
                this.shortucts.Add(shortcut);

                Settings.SpecialCommands = this.shortucts;
                this.shortucts           = Settings.SpecialCommands;
            }
        }
        private static void AddMmcCommands(SpecialCommandConfigurationElementCollection commands)
        {
            Icon[] iconsList = IconHandler.IconHandler.IconsFromFile(Path.Combine(SystemRoot.FullName, "mmc.exe"),
                IconHandler.IconSize.Small);
            Random rnd = new Random();
            FileLocations.EnsureImagesDirectory();

            foreach (FileInfo file in SystemRoot.GetFiles("*.msc"))
            {
                MMC.MMCFile fileMMC = new MMC.MMCFile(file);
                var command = new SpecialCommandConfigurationElement(file.Name);

                if (iconsList != null && iconsList.Length > 0)
                {
                    string thumbName = FileLocations.FormatThumbFileName(file.Name);
                    command.Thumbnail = thumbName;

                    if (fileMMC.SmallIcon != null)
                    {
                        SaveIcon(fileMMC.SmallIcon, thumbName);
                    }
                    else
                    {
                        SaveIcon(iconsList[rnd.Next(iconsList.Length - 1)], thumbName);
                    }

                    if (fileMMC.Parsed)
                    {
                        command.Name = fileMMC.Name;
                    }
                    else
                    {
                        command.Name = file.Name.Replace(file.Extension, "");
                    }
                }

                command.Executable = @"%systemroot%\system32\" + file.Name;
                commands.Add(command);
            }
        }
        private static SpecialCommandConfigurationElement CreateRegEditCommand()
        {
            const string REG_EDIT_EXE = "regedt32.exe";
            string regEditFile = Path.Combine(SystemRoot.FullName, REG_EDIT_EXE);
            Icon[] regeditIcons = IconHandler.IconHandler.IconsFromFile(regEditFile, IconHandler.IconSize.Small);
            var command = new SpecialCommandConfigurationElement("Registry Editor");

            if (regeditIcons != null && regeditIcons.Length > 0)
            {
                FileLocations.EnsureImagesDirectory();
                string thumbName = FileLocations.FormatThumbFileName(REG_EDIT_EXE);
                SaveIcon(regeditIcons[0], thumbName);
                command.Thumbnail = thumbName;
            }

            command.Executable = regEditFile;
            return command;
        }
        private static void AddControlPanelApplets(SpecialCommandConfigurationElementCollection commands)
        {
            string controlPanelImage = FileLocations.ControlPanelImage;
            if (!File.Exists(controlPanelImage))
            {
                SaveBitmap(Properties.Resources.ControlPanel, controlPanelImage);
            }

            foreach (FileInfo file in SystemRoot.GetFiles("*.cpl"))
            {
                var command = new SpecialCommandConfigurationElement(file.Name);
                command.Thumbnail = controlPanelImage;
                string thumbName = FileLocations.FormatThumbFileName(file.Name);

                Icon[] fileIcons = IconHandler.IconHandler.IconsFromFile(file.FullName, IconHandler.IconSize.Small);
                if (fileIcons != null && fileIcons.Length > 0)
                {
                    SaveIcon(fileIcons[0], thumbName);
                }

                if (File.Exists(thumbName))
                    command.Thumbnail = thumbName;

                command.Name = EnsureAppletName(file);
                command.Executable = @"%systemroot%\system32\" + file.Name;
                commands.Add(command);
            }
        }
 private static SpecialCommandConfigurationElement CreateCmdCommand()
 {
     var command = new SpecialCommandConfigurationElement("Command Shell");
     command.Executable = @"%systemroot%\system32\cmd.exe";
     return command;
 }