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 = shortcutCombobox.Text; if (name.Trim() != "" && name.Trim() != "<New...>") { SpecialCommandConfigurationElement shortcut = shortucts[name]; if (shortcut != null) { this.executableTextBox.Text = shortcut.Executable; this.argumentsTextBox.Text = shortcut.Arguments; this.workingFolderTextBox.Text = shortcut.WorkingFolder; LoadIconsFromExe(); } } else if (name.Trim() == "<New...>") { shortcutCombobox.SelectedIndex = -1; shortcutCombobox.Focus(); } }
public void Remove(SpecialCommandConfigurationElement item) { if (BaseIndexOf(item) >= 0) { BaseRemove(item.Name); } }
private void AddSpecialMenuItem(SpecialCommandConfigurationElement commad) { ToolStripItem specialItem = CreateSpecialItem(commad); specialItem.Image = FavoriteIcons.LoadImage(commad.Thumbnail, Resources.server_administrator_icon); specialItem.ImageTransparentColor = Color.Magenta; specialItem.Tag = commad; specialItem.Click += new EventHandler(SpecialItem_Click); }
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)); }
private void deleteButton_Click(object sender, EventArgs e) { string name = shortcutCombobox.Text; if (name.Trim() != "" && name.Trim() != "<New...>") { SpecialCommandConfigurationElement shortcut = shortucts[name]; if (shortcut != null) { shortucts.Remove(shortcut); settings.SpecialCommands = shortucts; shortucts = settings.SpecialCommands; } } LoadShortcuts(); }
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 = System.IO.Path.GetFileName(shortcut.Executable) + ".ico"; string exeFolder = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string imageFullName = System.IO.Path.Combine( System.IO.Path.Combine(exeFolder, "Thumbs") , imageName ); if (this.iconPicturebox.Image != null) { try { this.iconPicturebox.Image.Save(imageFullName); } catch (Exception exc) { Terminals.Logging.Log.Debug("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 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; } }
public int IndexOf(SpecialCommandConfigurationElement item) { return(BaseIndexOf(item)); }
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 = System.IO.Path.GetFileName(shortcut.Executable) + ".ico"; string exeFolder = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string imageFullName = System.IO.Path.Combine( System.IO.Path.Combine(exeFolder, "Thumbs") , imageName ); if(this.iconPicturebox.Image != null) { try { this.iconPicturebox.Image.Save(imageFullName); } catch(Exception exc) { Terminals.Logging.Log.Debug("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 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); }
private Image LoadThumbnail(SpecialCommandConfigurationElement cmd) { Log.InsideMethod(); Image img = Resources.application_xp_terminal; try { if (!string.IsNullOrEmpty(cmd.Thumbnail)) { img = Kohl.Framework.Drawing.IconHandler.Base64ToImage(cmd.Thumbnail); } } catch (Exception exc) { Log.Error("Could not LoadThumbnail for file:" + cmd.Thumbnail, exc); } return img; }
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(); } }
public void Add(SpecialCommandConfigurationElement item) { BaseAdd(item); }
public void Remove(SpecialCommandConfigurationElement item) { if (BaseIndexOf(item) >= 0) BaseRemove(item.Name); }
public int IndexOf(SpecialCommandConfigurationElement item) { return BaseIndexOf(item); }
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(); } }