private ActionsPerControl getOrCreateActionContainer(Control cont) { ActionsPerControl o = null; if (!_actionPerControl.TryGetValue(cont, out o)) { o = new ActionsPerControl(); _actionPerControl.Add(cont, o); cont.MouseDoubleClick += Cont_MouseDoubleClickAction; cont.MouseClick += Cont_MouseClickAction; } return(o); }
public void Bind(ICommandWrapper cmd, Control cont, Mouse mouseBtn, ModifierKeys key = ModifierKeys.None) { ActionsPerControl o = getOrCreateActionContainer(cont); CommandToKeyBindingItem kbi; if (key == ModifierKeys.Control) { kbi = new CommandToKeyBindingItem(cmd, Keys.ControlKey); } else if (key == ModifierKeys.Shift) { kbi = new CommandToKeyBindingItem(cmd, Keys.ShiftKey); } else if (key == ModifierKeys.ControlShift) { kbi = new CommandToKeyBindingItem(cmd, Keys.ControlKey, Keys.ShiftKey); } else { kbi = new CommandToKeyBindingItem(cmd); } if (mouseBtn == Mouse.LeftDoubleclick) { o.AddOnDoubleClickAction(MouseButtons.Left, kbi, key); } else if (mouseBtn == Mouse.LeftDown) { o.AddOnClickAction(MouseButtons.Left, kbi, key); } else if (mouseBtn == Mouse.RightDown) { o.AddOnClickAction(MouseButtons.Right, kbi, key); } }