Exemplo n.º 1
0
 public void Connect(MetroToolStripButton item, DrawPadAction action)
 {
     item.MouseDown += Item_MouseDown;
     if (item.IsDropDownButton)
         ((MetroToolStripDropDownButton)item).DropDownItemClicked += Item_DropDownItemClicked;
     _actionList.Add(item, action);
 }
Exemplo n.º 2
0
        public void Select(MetroToolStripButton item)
        {
            // Get command from control
            var command = item.Tag as CommandObject;
            if (command == null) return;

            var action = _actionList[item];
            if (action != null)
                action(command);

            // Toggle proccessing
            if (_lastItem != null)
                _lastItem.Checked = false;

            _lastItem = item;
            if (_lastItem != null) _lastItem.Checked = true;
        }
Exemplo n.º 3
0
 public void Connect(MetroToolStripButton item, CommandObject command, DrawPadAction action)
 {
     item.Tag = command;
     Connect(item, action);
 }
Exemplo n.º 4
0
 public ToolStripMananer()
 {
     _actionList = new Dictionary<MetroToolStripButton, DrawPadAction>();
     _lastItem = null;
     _isToggle = false;
 }
Exemplo n.º 5
0
        private void Item_MouseDown(object sender, EventArgs e)
        {
            // Get MetroToolStripButton
            var ctrl = sender as MetroToolStripButton;
            if (ctrl == null) return;

            // Get command from control
            var command = ctrl.Tag as CommandObject;
            if (command == null) return;

            // Do action
            var action = _actionList[ctrl];
            if (action != null)
                action(command);

            if (!_isToggle)
                return;

            // Toggle proccessing
            if (_lastItem != null)
                _lastItem.Checked = false;

            _lastItem = sender as MetroToolStripButton;
            if (_lastItem != null) _lastItem.Checked = true;
        }