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); }
private void InsertModesIntoList(bool before) { int off = 1; if (before) { off = 0; } //Find the first selected mode in the list List <Button> buttons = OrderButtons(ModeButtons, ListModes.Modes); Button firstSelectedButton = buttons[0]; int ind = 0; bool notFound = true; while (ind < buttons.Count && notFound) { if (ModeButtons[buttons[ind]].Selected) { firstSelectedButton = buttons[ind]; notFound = false; } ind++; } //Now insert all of the selected modes into the list in front of the first selected button List <ModeControl> modeControlsToAdd = MainClientForm.instance.runModesLists.SelectedModeButtons; ind = ListModes.Modes.IndexOf(ModeButtons[firstSelectedButton]); //Insert the new mode controls ModeControl newMode; for (int ind2 = 0; ind2 < modeControlsToAdd.Count; ind2++) { newMode = new ModeControl(modeControlsToAdd[ind2]); newMode.ListPosition = ind + ind2 + off; ListModes.Modes.Insert(ind + ind2 + off, newMode); } //Now re-do all the buttons in the editor modesFlowPanel.Controls.Clear(); ModeButtons.Clear(); for (int ind2 = 0; ind2 < ListModes.Modes.Count; ind2++) { Button button = CreateButton(ListModes.Modes[ind2]); modesFlowPanel.Controls.Add(button); CreateDelayEditor(ListModes.Modes[ind2]); ListModes.Modes[ind].ListPosition = ind2; } }
public void ModeButtonsVisibilitySetter(ModeButtons modeButton) { switch (modeButton) { case ModeButtons.TimerPicker: this.TimerVisibility.Value = Visibility.Visible; this.DateVisibility.Value = Visibility.Collapsed; break; case ModeButtons.DatePicker: this.TimerVisibility.Value = Visibility.Collapsed; this.DateVisibility.Value = Visibility.Visible; break; } }
// UI private void ModeButtonsUISetter(ModeButtons modeButton) { switch (modeButton) { case ModeButtons.TimerPicker: this.btnTimerPicker.Background = new SolidColorBrush(Colors.Orange); this.btnDatePicker.Background = SystemColors.ControlLightBrush; this.AppData.ModeButtonsVisibilitySetter(ModeButtons.TimerPicker); break; case ModeButtons.DatePicker: this.btnDatePicker.Background = new SolidColorBrush(Colors.Orange); this.btnTimerPicker.Background = SystemColors.ControlLightBrush; this.AppData.ModeButtonsVisibilitySetter(ModeButtons.DatePicker); break; } }
/// <summary> /// Creates a new button for the input mode control (does not add the button to the mode list). /// </summary> /// <param name="modeControl">Mode control of the new button.</param> /// <returns>The newly created button.</returns> public Button CreateButton(ModeControl modeControl) { Button modeButton = new Button(); if (modeControl.Mode != null) { modeButton.Text = modeControl.Mode.ModeName; } modeButton.Size = new Size(110, 25); modeButton.Font = DeepCopy(ModeFont); modeButton.Click += new EventHandler(this.modeButton_Click); ModeButtons.Add(modeButton, modeControl); ColorBox(modeButton); return(modeButton); }