private void replaceSelectedButton_Click(object sender, EventArgs e) { if (!updatingModes) { updatingModes = true; modeListEditor_Click(sender, e); //Create lists of the modes we need to add to the list, as well as all of the mode buttons currently in the list List <ModeControl> modeControlsToAdd = MainClientForm.instance.runModesLists.SelectedModeButtons; List <Button> buttons = OrderButtons(ModeButtons, ListModes.Modes); //For each selected button currently in the list, either replace it with one of the //modes we need to add to the list, or delete the button Button button; for (int ind = 0; ind < buttons.Count; ind++) { button = buttons[ind]; if (ModeButtons[button].Selected) { //If there are more modes to add, replace the current button's mode if (modeControlsToAdd.Count > 0) { ModeButtons[button] = new ModeControl(modeControlsToAdd[0]); button.Text = ModeButtons[button].Mode.ModeName; ColorBox(button); ModeButtons[button].ListPosition = ind; ListModes.Modes[ind] = ModeButtons[button]; modeControlsToAdd.RemoveAt(0); } else //Otherwise delete the button entirely { ListModes.Modes.Remove(ModeButtons[button]); DeleteDelayEditor(button); modesFlowPanel.Controls.Remove(button); ModeButtons.Remove(button); ListModes.UpdateListPositions(); } } } //If there are still modes left to add, do so now by creating new buttons for them foreach (ModeControl newMode in modeControlsToAdd) { ListModes.Modes.Add(new ModeControl(newMode)); ListModes.Modes.Last().ListPosition = ListModes.Modes.Count - 1; button = CreateButton(ListModes.Modes.Last()); modesFlowPanel.Controls.Add(button); CreateDelayEditor(newMode); } EnableAndDisableControls(); updatingModes = false; } }
public bool DeleteInputButton(Button button) { if (ModeButtons.Keys.Contains(button)) { ListModes.Modes.Remove(ModeButtons[button]); DeleteDelayEditor(button); modesFlowPanel.Controls.Remove(button); ModeButtons.Remove(button); ListModes.UpdateListPositions(); return(true); } return(false); }
public ListEditor(string settingName, string title) { InitializeComponent(); this.Title = title; this.mode = ListModes.Setting; this.settingName = settingName; string value = (string)(Properties.Settings.Default.GetType().GetProperty(settingName).GetValue(Properties.Settings.Default, null)); this.list = new SortedObservableCollection <string>(); this.list.DeSerialize(value); addTextStr = "Enter text here.."; AddToListTB.Text = addTextStr; MyListView.ItemsSource = this.list; }
} // Never used, but visual stdio throws an error if not exists public ListEditor(SortedObservableCollection <string> list, string title, ListModes mode = ListModes.Users) { InitializeComponent(); this.Title = title; this.list = list; this.mode = mode; if (mode == ListModes.Users) { addTextStr = "Add a new user to the list.."; AddToListTB.Text = addTextStr; nickRegex = new Regex(@"^[a-z`]", RegexOptions.IgnoreCase); nickRegex2 = new Regex(@"^[a-z`][a-z0-9`\-]*$", RegexOptions.IgnoreCase); } else { addTextStr = "Enter text here.."; AddToListTB.Text = addTextStr; } MyListView.ItemsSource = this.list; }