/// <inheritdoc /> protected override void OnClick(EventArgs e) { base.OnClick(e); IActionHandler actionHandler = ((IButton)this).ActionHandler; actionHandler?.Run(); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { IActionHandler actionHandler = value as IActionHandler; if (actionHandler == null) { return(null); } ICommand command = new RelayCommand(o => actionHandler.Run(), o => actionHandler.IsEnabled); return(command); }
public void DelegateAction(DelegationImpl delegation, ExecutionContextImpl executionContext) { try { executionContext.CreateLog(EventType.ACTION); executionContext.AddLogDetail(new DelegateCallImpl(delegation, typeof(IAction))); IActionHandler actionHandler = (IActionHandler)GetDelegate(delegation); executionContext.SetConfiguration(ParseConfiguration(delegation)); actionHandler.Run(executionContext); } catch (Exception t) { HandleException(delegation, executionContext, t); } }
private void RunAction(object sender, EventArgs e) { #region debug msg if (Log.IsDebugEnabled) { Log.Debug("RunAction called."); //NON-NLS-1 } #endregion IActionHandler aH = ((ToolStripItem)sender).Tag as IActionHandler; #region debug assertions Debug.Assert(aH != null, "ToolStripItem's Tag must be an ActionHandler!"); Debug.Assert(aH.Enabled, "ActionHandler must be enabled to run."); #endregion if (aH.Enabled) { aH.Run(e); } }
public void DelegateScheduledAction(DelegationImpl delegation, ExecutionContextImpl executionContext) { try { /* can't add logs because of a integritiy constraint violation... * can you find why ? */ if (executionContext.GetFlow() != null) { executionContext.CreateLog(EventType.ACTION); executionContext.AddLogDetail(new DelegateCallImpl(delegation, typeof(IAction))); } IActionHandler actionHandler = (IActionHandler)GetDelegate(delegation); executionContext.SetConfiguration(ParseConfiguration(delegation)); actionHandler.Run(executionContext); } catch (Exception t) { HandleException(delegation, executionContext, t); } }
/// <summary> /// Adds a button to the tool bar with the given <paramref name="label"/> and the given <paramref name="image"/>. /// If the button is clicked, the given <paramref name="actionHandler"/> is invoked. /// </summary> /// <param name="label">Label of the button</param> /// <param name="image">Stream of the image to use for the button</param> /// <param name="actionHandler">Action handler</param> /// <param name="toolTipText">Additional tooltip text. When NULL <paramref name="label"/> is used as tooltip text</param> public void AddButton(string label, Stream image, IActionHandler actionHandler, string toolTipText = null) { ToolStripButton toolStripButton = new ToolStripButton(); actionHandler.PropertyChanged += (sender, args) => toolStripButton.Enabled = actionHandler.IsEnabled; if (image != null) { using (image) { toolStripButton.Image = new Bitmap(image); } } toolStripButton.Text = label; toolStripButton.AutoToolTip = false; toolStripButton.ToolTipText = toolTipText ?? label; toolStripButton.Click += (sender, args) => actionHandler.Run(); toolStripButton.Enabled = actionHandler.IsEnabled; Items.Add(toolStripButton); }