/// <summary> /// A simple constructor that intializes the object with the given values. /// </summary> /// <param name="p_butButton">The button to bind to the command.</param> /// <param name="p_cmdCommand">The command to bind to the trigger.</param> /// <param name="p_dlgGetArgument">The method that returns the command argument.</param> public ButtonCommandBinding(Button p_butButton, Command <T> p_cmdCommand, GetCommandArgument p_dlgGetArgument) : base(p_butButton, p_cmdCommand, p_dlgGetArgument) { p_butButton.Text = p_cmdCommand.Name; p_butButton.Enabled = Command.CanExecute; p_butButton.Click += Button_Click; }
/// <summary> /// A simple constructor that intializes the object with the given values. /// </summary> /// <param name="p_tsiMenuItem">The menu item to bind to the command.</param> /// <param name="p_cmdCommand">The command to bind to the trigger.</param> /// <param name="p_dlgGetArgument">The method that returns the command argument.</param> public ToolStripMenuItemCommandBinding(ToolStripMenuItem p_tsiMenuItem, Command <T> p_cmdCommand, GetCommandArgument p_dlgGetArgument) : base(p_tsiMenuItem, p_cmdCommand, p_dlgGetArgument) { p_tsiMenuItem.Text = p_cmdCommand.Name; p_tsiMenuItem.Enabled = Command.CanExecute; if (Command is CheckedCommand <T> ) { p_tsiMenuItem.Checked = ((CheckedCommand <T>)Command).IsChecked; } p_tsiMenuItem.Click += ToolStripMenuItem_Click; }
/// <summary> /// A simple constructor that initializes the object with the given values. /// </summary> /// <param name="p_objTrigger">The object that can trigger the command.</param> /// <param name="p_cmdCommand">The command that can be triggered.</param> /// <param name="p_dlgGetArgument">The method that returns the command argument.</param> protected CommandBinding(object p_objTrigger, Command <T> p_cmdCommand, GetCommandArgument p_dlgGetArgument) { m_dlgGetArgument = p_dlgGetArgument; if (p_objTrigger == null) { throw new ArgumentNullException("p_objTrigger"); } if (p_cmdCommand == null) { throw new ArgumentNullException("p_cmdCommand"); } m_objTrigger = p_objTrigger; m_cmdCommand = p_cmdCommand; m_cmdCommand.PropertyChanged += CommandPropertyChanged; }
/// <summary> /// A simple constructor that intializes the object with the given values. /// </summary> /// <param name="p_objTrigger">The object whose event will be bound to the command.</param> /// <param name="p_strEventName">The name of the event to bind to the command.</param> /// <param name="p_cmdCommand">The command to bind to the trigger.</param> /// <param name="p_dlgGetArgument">The method that returns the command argument.</param> public EventCommandBinding(object p_objTrigger, string p_strEventName, Command <T> p_cmdCommand, GetCommandArgument p_dlgGetArgument) : base(p_objTrigger, p_cmdCommand, p_dlgGetArgument) { m_strEventName = p_strEventName; EventInfo evtEvent = p_objTrigger.GetType().GetEvent(p_strEventName); if (evtEvent == null) { throw new ArgumentException("Invalid event name (" + p_strEventName + ") for object of type " + p_objTrigger.GetType().FullName, "p_strEventName"); } evtEvent.AddEventHandler(p_objTrigger, new EventHandler(Event_Called)); }
/// <summary> /// A simple constructor that initializes the object with the given values. /// </summary> /// <param name="p_objTrigger">The object that can trigger the command.</param> /// <param name="p_cmdCommand">The command that can be triggered.</param> /// <param name="p_dlgGetArgument">The method that returns the command argument.</param> protected CommandBinding(object p_objTrigger, Command <T> p_cmdCommand, GetCommandArgument p_dlgGetArgument) : base(p_objTrigger, p_cmdCommand) { m_dlgGetArgument = p_dlgGetArgument; }
/// <summary> /// A simple constructor that intializes the object with the given values. /// </summary> /// <param name="p_ctlControl">The control to bind to the command.</param> /// <param name="p_cmdCommand">The command to bind to the trigger.</param> /// <param name="p_dlgGetArgument">The method that returns the command argument.</param> /// <param name="p_keyKeys">The keys which can trigger the command.</param> public KeyDownCommandBinding(Control p_ctlControl, Command <T> p_cmdCommand, GetCommandArgument p_dlgGetArgument, params Keys[] p_keyKeys) : base(p_ctlControl, p_cmdCommand, p_dlgGetArgument) { m_keyKeys = p_keyKeys; p_ctlControl.KeyDown += new KeyEventHandler(Control_KeyDown); }
/// <summary> /// A simple constructor that intializes the object with the given values. /// </summary> /// <param name="p_tsiMenuItem">The menu item to bind to the command.</param> /// <param name="p_cmdCommand">The command to bind to the trigger.</param> /// <param name="p_dlgGetArgument">The method that returns the command argument.</param> public ToolStripItemCommandBinding(ToolStripItem p_tsiMenuItem, Command <T> p_cmdCommand, GetCommandArgument p_dlgGetArgument) : base(p_tsiMenuItem, p_cmdCommand, p_dlgGetArgument) { p_tsiMenuItem.Text = p_cmdCommand.Name; p_tsiMenuItem.ToolTipText = p_cmdCommand.Description; p_tsiMenuItem.Enabled = Command.CanExecute; p_tsiMenuItem.Click += new EventHandler(ToolStripItem_Click); }