/// <summary> /// Выбор кнопки /// </summary> /// <param name="buttonID"></param> public void SelectButton(int buttonID) { if (buttonID < 0 || buttonID > _buttons.Count - 1) return; int pressedButton = -1; for (int i = 0; i < _buttons.Count; i++) { _buttons[i].Instance.Pressed = i == buttonID; if (i == buttonID) { pressedButton = i; } } foreach (ToolbarButton toolbarButton in _buttons) { OnInvalidate(toolbarButton.Instance); } if (pressedButton > -1) { _selected = _buttons[pressedButton]; _buttons[pressedButton].Instance.OnClick(EventArgs.Empty); } }
public void RemoveButton(ToolbarButton button) { if (_buttons.Contains(button)) _buttons.Remove(button); button.Instance.Invalidate -= element_Invalidate; RecalcButtonLayout(); }
/// <summary> /// Выбор кнопки /// </summary> /// <param name="button"></param> public void SelectButton(ToolbarButton button) { if (!_buttons.Contains(button) || _selected == button) return; int selectedButton = -1; for (int i = 0; i < _buttons.Count; i++) { _buttons[i].Instance.Selected = false; _buttons[i].Instance.Pressed = _buttons[i] == button; if (_buttons[i] == button) { selectedButton = i; } } foreach (ToolbarButton toolbarButton in _buttons) { OnInvalidate(toolbarButton.Instance); } if (selectedButton > -1) { _selected = button; _buttons[selectedButton].Instance.OnClick(EventArgs.Empty); } }
public ToolbarButton AddButton(ButtonStyle style) { ToolbarButton b = new ToolbarButton(); b.Instance.Size = _buttonsSize; b.Instance.Style = style; _buttons.Add(b); b.Instance.Invalidate += element_Invalidate; RecalcButtonLayout(); return b; }