public ExternalToolsOptionControl() { EventHandler handler = null; this.CurrentLink = new NamedShellLink(); this.components = null; this.InitializeComponent(); this.Validator.TooltipTitle = Resources.sInvalidName; this.InitializeEnvironmentKeys(); this.btnSaveAs.Image = IconSet.GetImage("SaveAs"); if (this.lvTools.ExplorerTheme) { this.imgTools.ImageSize = new Size(ImageHelper.DefaultSmallIconSize.Width, ImageHelper.DefaultSmallIconSize.Height + 3); } else { this.imgTools.ImageSize = ImageHelper.DefaultSmallIconSize; } if (!Application.RenderWithVisualStyles) { this.btnSaveAs.BackColor = SystemColors.Control; this.btnAppendArgument.BackColor = SystemColors.Control; this.btnAppendWorkDir.BackColor = SystemColors.Control; } this.txtHotKey.KeysConverter = new SettingsManager.LocalizedEnumConverter(typeof(Keys)); this.cmbWindowState.DataSource = Enum.GetValues(typeof(FormWindowState)); this.chkRunAsAdmin.Enabled = !Settings.Default.DirectToolStart; if (handler == null) { handler = delegate (object sender, EventArgs e) { foreach (ListViewItem item in this.lvTools.Items) { IDisposable tag = item.Tag as IDisposable; if (tag != null) { tag.Dispose(); } } this.CurrentLink.Dispose(); }; } base.Disposed += handler; }
private ListViewItem CreateToolItem(NamedShellLink tool, TypeConverter keysConverter) { ListViewItem item = new ListViewItem(tool.Name) { Tag = tool }; ListViewItem.ListViewSubItem item2 = item.SubItems.Add(keysConverter.ConvertToString(tool.Hotkey)); if (tool.Hotkey == Keys.None) { item.UseItemStyleForSubItems = false; item2.ForeColor = SystemColors.GrayText; } return item; }
private void lvTools_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { if (e.Item.Focused) { e.Item.Selected = true; if ((this.CurrentItem == null) || (this.CurrentItem != e.Item)) { this.CurrentItem = e.Item; this.CurrentLink = (NamedShellLink) ((NamedShellLink) this.CurrentItem.Tag).Clone(); this.txtTitle.Text = this.CurrentLink.Name; this.txtPath.Text = this.CurrentLink.Path; this.txtArguments.Text = this.CurrentLink.Arguments; this.txtWorkingDirectory.Text = this.CurrentLink.WorkingDirectory; this.txtPath.ResetBackColor(); this.txtPath.ResetForeColor(); this.txtHotKey.HotKey = this.CurrentLink.Hotkey; this.cmbWindowState.SelectedItem = this.CurrentLink.WindowState; this.chkRunAsAdmin.Checked = this.chkRunAsAdmin.Enabled && ((this.CurrentLink.Flags & SHELL_LINK_DATA_FLAGS.SLDF_RUNAS_USER) > ((SHELL_LINK_DATA_FLAGS) 0)); } } base.BeginInvoke(new MethodInvoker(this.UpdateButtons)); }
private void btnSaveAs_Click(object sender, EventArgs e) { if (this.ValidateChildren(ValidationConstraints.Enabled)) { TypeConverter keysConverter = TypeDescriptor.GetConverter(typeof(Keys)); this.lvTools.BeginUpdate(); try { ListViewItem item = null; foreach (ListViewItem item2 in this.lvTools.Items) { if (string.Equals(item2.Text, this.CurrentLink.Name)) { item = item2; break; } } Image img = null; if (item == null) { item = this.CreateToolItem(this.CurrentLink, keysConverter); img = ImageProvider.Default.GetFileIcon(this.CurrentLink.Path, ImageHelper.DefaultSmallIconSize); this.lvTools.Items.Add(item); } else { if (!string.Equals(((NamedShellLink) item.Tag).Path, this.CurrentLink.Path)) { img = ImageProvider.Default.GetFileIcon(this.CurrentLink.Path, ImageHelper.DefaultSmallIconSize); } item.SubItems[1].Text = keysConverter.ConvertToString(this.CurrentLink.Hotkey); item.Tag = this.CurrentLink; } if (img != null) { item.ImageIndex = this.imgTools.AddNormalized(img, this.lvTools.BackColor); } item.Focus(true, true); } finally { this.lvTools.EndUpdate(); } this.CurrentLink = (NamedShellLink) this.CurrentLink.Clone(); this.UpdateButtons(); this.ListView_SizeChanged(this.lvTools); } }