private void btnSave_Click(object sender, EventArgs e) { bool isURL = IsURL(txbItem.Text); Item = new StartupItem(0, txbItem.Text, (int)numOffset.Value, isURL ? "" : txbWorkingDirectory.Text, isURL ? "" : txbArguments.Text, stateChoices[cmbState.SelectedIndex]); }
public void EditStartupItem(StartupItem oldItem, StartupItem newItem) { if (!items.Contains(oldItem)) { Debug.WriteLine("Manager items does not contain " + oldItem.ToString()); return; } items.Remove(oldItem); items.Add(newItem); SortItems(); IsSaveRequired = true; }
private void Remove() { if (listViewItems.SelectedIndices.Count == 0) { return; } // Get the selected index - first is fine as multi-select is off int index = listViewItems.SelectedIndices[0]; StartupItem item = manager.GetItems().ElementAt(index); manager.RemoveStartupItem(item); PopulateListView(new List <StartupItem>(manager.GetItems())); UpdateUI(); }
private void SetupDialog(StartupItem item) { try { numOffset.Maximum = Convert.ToInt32(ConfigurationManager.AppSettings["UpperTimeLimit"]); } catch (FormatException) { numOffset.Maximum = DefaultUpperTimeLimit; } foreach (ProcessWindowStyle style in stateChoices) { cmbState.Items.Add(style.ToString()); } // Populate Fields txbItem.Text = item.Item; numOffset.Value = item.Offset; txbWorkingDirectory.Text = item.WorkingDirectory; txbArguments.Text = item.Arguments; cmbState.SelectedIndex = stateChoices.IndexOf(item.WindowState); // Validate input and update UI appropriately bool isURL = IsURL(txbItem.Text); btnChooseWorkingDir.Enabled = !isURL; ckbParentDir.Enabled = !isURL; txbArguments.Enabled = !isURL; Height -= grpAdvanced.Height; grpAdvanced.Visible = false; if (txbItem.Text == "") { ckbParentDir.Enabled = false; } txbItem.Focus(); }
private void Edit() { if (listViewItems.SelectedIndices.Count == 0) { return; } // Get the selected index - first is fine as multi-select is off int index = listViewItems.SelectedIndices[0]; StartupItem item = manager.GetItems().ElementAt(index); using (ItemDialog dialog = new ItemDialog(item)) { DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK) { manager.EditStartupItem(item, dialog.Item); PopulateListView(new List <StartupItem>(manager.GetItems())); UpdateUI(); } } }
public void RemoveStartupItem(StartupItem item) { items.Remove(item); IsSaveRequired = true; }
public void AddStartupItem(StartupItem item) { items.Add(item); SortItems(); IsSaveRequired = true; }
public int CompareTo(object obj) { StartupItem other = obj as StartupItem; return(Offset.CompareTo(other.Offset)); }
public ItemDialog(StartupItem item = null) { InitializeComponent(); Item = item == null ? new StartupItem(0, "", 0, "", "") : item; SetupDialog(Item); }