private void saveButton_Click(object sender, EventArgs e) { string name = shortcutCombobox.Text; if (name.Trim() != "" && name.Trim() != "<New...>") { SpecialCommandConfigurationElement shortcut = shortucts[name]; if (shortcut == null) { shortcut = new SpecialCommandConfigurationElement(); } shortcut.Name = name.Trim(); shortcut.Executable = executableTextBox.Text; shortcut.WorkingFolder = workingFolderTextBox.Text; shortcut.Arguments = argumentsTextBox.Text; string imageName = Path.GetFileName(shortcut.Executable) + ".ico"; string imageFullName = Path.Combine(FileLocations.ThumbsDirectoryFullPath, imageName); if (this.iconPicturebox.Image != null) { try { this.iconPicturebox.Image.Save(imageFullName); } catch (Exception exc) { Logging.Error("Saving icon picture box failed", exc); imageFullName = ""; } } else { imageFullName = ""; } shortcut.Thumbnail = imageFullName; shortucts.Remove(shortcut); shortucts.Add(shortcut); settings.SpecialCommands = shortucts; shortucts = settings.SpecialCommands; } }
private void nextButton_Click(object sender, EventArgs e) { if (SelectedForm == WizardForms.Intro) { nextButton.Enabled = true; this.panel1.Controls.Clear(); this.panel1.Controls.Add(mp); this.SelectedForm = WizardForms.MasterPassword; } else if (SelectedForm == WizardForms.MasterPassword) { if (mp.StorePassword) { Settings.TerminalsPassword = mp.Password; nextButton.Enabled = true; this.panel1.Controls.Clear(); this.panel1.Controls.Add(dc); this.SelectedForm = WizardForms.DefaultCredentials; } else { nextButton.Enabled = true; this.panel1.Controls.Clear(); this.panel1.Controls.Add(co); this.SelectedForm = WizardForms.Options; } } else if (SelectedForm == WizardForms.DefaultCredentials) { Settings.DefaultDomain = dc.DefaultDomain; Settings.DefaultPassword = dc.DefaultPassword; Settings.DefaultUsername = dc.DefaultUsername; nextButton.Enabled = true; this.panel1.Controls.Clear(); this.panel1.Controls.Add(co); this.SelectedForm = WizardForms.Options; } else if (SelectedForm == WizardForms.Options) { Settings.MinimizeToTray = co.MinimizeToTray; Settings.SingleInstance = co.AllowOnlySingleInstance; Settings.ShowConfirmDialog = co.WarnOnDisconnect; Settings.AutoSwitchOnCapture = co.AutoSwitchOnCapture; try { if (co.LoadDefaultShortcuts) { SpecialCommandConfigurationElementCollection cmdList = Settings.SpecialCommands; //add the command prompt SpecialCommandConfigurationElement elm = new SpecialCommandConfigurationElement("Command Shell"); elm.Executable = @"%systemroot%\system32\cmd.exe"; cmdList.Add(elm); System.IO.DirectoryInfo systemroot = new System.IO.DirectoryInfo(System.Environment.GetFolderPath(System.Environment.SpecialFolder.System)); string regEditFile = System.IO.Path.Combine(systemroot.FullName, "regedt32.exe"); Icon[] regeditIcons = IconHandler.IconHandler.IconsFromFile(regEditFile, IconHandler.IconSize.Small); SpecialCommandConfigurationElement regEditElm = new SpecialCommandConfigurationElement(regEditFile); if (regeditIcons != null && regeditIcons.Length > 0) { if (!System.IO.Directory.Exists("Thumbs")) { System.IO.Directory.CreateDirectory("Thumbs"); } string thumbName = string.Format(@"Thumbs\regedt32.exe.jpg", regEditFile); if (!System.IO.File.Exists(thumbName)) { regeditIcons[0].ToBitmap().Save(thumbName); } regEditElm.Thumbnail = thumbName; } //elm1.Thumbnail = ""; regEditElm.Executable = regEditFile; cmdList.Add(regEditElm); Icon[] IconsList = IconHandler.IconHandler.IconsFromFile(System.IO.Path.Combine(systemroot.FullName, "mmc.exe"), IconHandler.IconSize.Small); System.Random rnd = new Random(); foreach (System.IO.FileInfo file in systemroot.GetFiles("*.msc")) { SpecialCommandConfigurationElement elm1 = new SpecialCommandConfigurationElement(file.Name); if (IconsList != null && IconsList.Length > 0) { if (!System.IO.Directory.Exists("Thumbs")) { System.IO.Directory.CreateDirectory("Thumbs"); } string thumbName = string.Format(@"Thumbs\{0}.jpg", file.Name); if (!System.IO.File.Exists(thumbName)) { IconsList[rnd.Next(IconsList.Length - 1)].ToBitmap().Save(thumbName); } elm1.Thumbnail = thumbName; } //elm1.Thumbnail = ""; elm1.Executable = @"%systemroot%\system32\" + file.Name; cmdList.Add(elm1); } Settings.SpecialCommands = cmdList; } } catch (Exception exc) { Terminals.Logging.Log.Error("Loading default shortcuts in the wizard.", exc); } nextButton.Enabled = false; nextButton.Text = "Finished!"; this.panel1.Controls.Clear(); rdp.Dock = DockStyle.Fill; this.panel1.Controls.Add(rdp); rdp.StartImport(); this.SelectedForm = WizardForms.Scanner; } else if (SelectedForm == WizardForms.Scanner) { this.Hide(); } }