/// <summary> /// Applies this attribute to an <see cref="IAction"/> instance, via the specified <see cref="IActionBuildingContext"/>, /// by binding the appropriate handler method on the target object to the action. /// </summary> public override void Apply(IActionBuildingContext builder) { // check that the method exists, etc ValidateClickHandler(builder.ActionTarget, this.HandlerMethodName); ClickHandlerDelegate clickHandler = (ClickHandlerDelegate)Delegate.CreateDelegate(typeof(ClickHandlerDelegate), builder.ActionTarget, this.HandlerMethodName); ((ClickAction)builder.Action).SetClickHandler(clickHandler); }
/// <summary> /// Applies this attribute to an <see cref="IAction"/> instance, via the specified <see cref="IActionBuildingContext"/>. /// </summary> /// <remarks> /// Because this action is an <see cref="ActionInitiatorAttribute"/>, this method actually /// creates the associated <see cref="ClickAction"/>. <see cref="ActionDecoratorAttribute"/>s /// merely modify the properties of the action. /// </remarks> public override void Apply(IActionBuildingContext builder) { // assert _action == null ActionPath path = new ActionPath(this.Path, builder.ResourceResolver); builder.Action = CreateAction(builder.ActionID, path, this.Flags, builder.ResourceResolver); builder.Action.Available = this.InitiallyAvailable; builder.Action.Persistent = true; ((ClickAction)builder.Action).KeyStroke = this.KeyStroke; builder.Action.Label = path.LastSegment.LocalizedText; if (!string.IsNullOrEmpty(_clickHandler)) { // check that the method exists, etc ValidateClickHandler(builder.ActionTarget, _clickHandler); ClickHandlerDelegate clickHandler = (ClickHandlerDelegate)Delegate.CreateDelegate(typeof(ClickHandlerDelegate), builder.ActionTarget, _clickHandler); ((ClickAction)builder.Action).SetClickHandler(clickHandler); } }
/// <summary> /// Adds an action to the action model. /// </summary> /// <param name="key">The action key, so that actions can be easily retrieve via the <see cref="SimpleActionModel.this"/> indexer.</param> /// <param name="displayName">The display name for the action.</param> /// <param name="icon">The resource name of the icon.</param> /// <param name="tooltip">The action tooltip.</param> /// <param name="clickHandler">The click handler of the action.</param> public ClickAction AddAction(object key, [param : Localizable(true)] string displayName, string icon, [param : Localizable(true)] string tooltip, ClickHandlerDelegate clickHandler) { return AddActionHelper(key, displayName, icon, tooltip, clickHandler, null); }
private ClickAction AddActionHelper(object key, string displayName, string icon, string tooltip, ClickHandlerDelegate clickHandler, ISpecification permissionSpec) { Platform.CheckForNullReference(key, "key"); var action = new ClickAction(displayName, MakePath(displayName), ClickActionFlags.None, _resolver) { Tooltip = tooltip, Label = displayName }; if (icon != null) action.IconSet = new IconSet(icon, icon, icon); if (clickHandler != null) { action.SetClickHandler(clickHandler); } if (permissionSpec != null) { action.SetPermissibility(permissionSpec); } this.InsertAction(action); _actions[key] = action; return action; }
/// <summary> /// Adds an action to the action model. /// </summary> /// <param name="key">The action key, so that actions can be easily retrieve via the <see cref="SimpleActionModel.this"/> indexer.</param> /// <param name="displayName">The display name for the action.</param> /// <param name="icon">The resource name of the icon.</param> /// <param name="tooltip">The action tooltip.</param> /// <param name="clickHandler">The click handler of the action.</param> /// <param name="permissionSpec">The permission specification for the action.</param> public ClickAction AddAction(object key, [param : Localizable(true)] string displayName, string icon, [param : Localizable(true)] string tooltip, ClickHandlerDelegate clickHandler, ISpecification permissionSpec) { return AddActionHelper(key, displayName, icon, tooltip, clickHandler, permissionSpec); }
/// <summary> /// Adds an action to the action model. /// </summary> /// <param name="key">The action key, so that actions can be easily retrieve via the <see cref="SimpleActionModel.this"/> indexer.</param> /// <param name="displayName">The display name for the action.</param> /// <param name="icon">The resource name of the icon.</param> /// <param name="tooltip">The action tooltip.</param> /// <param name="clickHandler">The click handler of the action.</param> /// <param name="authorityToken">The authority token for the action.</param> public ClickAction AddAction(object key, [param : Localizable(true)] string displayName, string icon, [param : Localizable(true)] string tooltip, ClickHandlerDelegate clickHandler, string authorityToken) { return AddActionHelper(key, displayName, icon, tooltip, clickHandler, new PrincipalPermissionSpecification(authorityToken)); }
/// <summary> /// Sets the delegate that will respond when this action is clicked. /// </summary> public void SetClickHandler(ClickHandlerDelegate clickHandler) { _clickHandler = clickHandler; }
internal ExceptionDialogControl(Exception exception, string message, ExceptionDialogActions buttonActions, ClickHandlerDelegate ok, ClickHandlerDelegate quit) { const string errorOk = "Ok method must be supplied"; const string errorQuit = "Quit method must be supplied"; _exception = exception; InitializeComponent(); _description.Text = message; AcceptButton = _okButton; CancelButton = _okButton; EventHandler okClick = delegate { Result = ExceptionDialogAction.Ok; ok(); }; EventHandler quitClick = delegate { Result = ExceptionDialogAction.Quit; quit(); }; if (buttonActions == ExceptionDialogActions.Ok) { if (ok == null) throw new ArgumentException(errorOk, "ok"); _okButton.Click += okClick; _quitButton.Dispose(); } else { if (buttonActions == ExceptionDialogActions.Quit) { if (quit == null) throw new ArgumentException(errorQuit, "quit"); _quitButton.Click += quitClick; AcceptButton = _quitButton; CancelButton = _quitButton; _okButton.Dispose(); } else { if (ok == null) throw new ArgumentException(errorOk, "ok"); if (quit == null) throw new ArgumentException(errorQuit, "quit"); _okButton.Click += okClick; _okButton.Text = SR.MenuContinue; _quitButton.Click += quitClick; } } if (_exception != null) { // Update Exceptions detail tree _detailTree.BeginUpdate(); BuildTreeFromException(null, _exception); _detailTree.ExpandAll(); _detailTree.EndUpdate(); } else { _detailButton.Dispose(); } // Hide the details when dialog first startup HideDetails(); }
/// <summary> /// Adds an action to the action model. /// </summary> /// <param name="key">The action key, so that actions can be easily retrieve via the <see cref="SimpleActionModel.this"/> indexer.</param> /// <param name="displayName">The display name for the action.</param> /// <param name="icon">The resource name of the icon.</param> /// <param name="tooltip">The action tooltip.</param> /// <param name="clickHandler">The click handler of the action.</param> public ClickAction AddAction(object key, string displayName, string icon, string tooltip, ClickHandlerDelegate clickHandler) { return(AddActionHelper(key, displayName, icon, tooltip, clickHandler, null)); }
private ClickAction AddActionHelper(object key, string displayName, string icon, string tooltip, ClickHandlerDelegate clickHandler, ISpecification permissionSpec) { Platform.CheckForNullReference(key, "key"); var action = new ClickAction(displayName, MakePath(displayName), ClickActionFlags.None, _resolver) { Tooltip = tooltip, Label = displayName }; if (icon != null) { action.IconSet = new IconSet(icon, icon, icon); } if (clickHandler != null) { action.SetClickHandler(clickHandler); } if (permissionSpec != null) { action.SetPermissibility(permissionSpec); } this.InsertAction(action); _actions[key] = action; return(action); }
/// <summary> /// Adds an action to the action model. /// </summary> /// <param name="key">The action key, so that actions can be easily retrieve via the <see cref="SimpleActionModel.this"/> indexer.</param> /// <param name="displayName">The display name for the action.</param> /// <param name="icon">The resource name of the icon.</param> /// <param name="tooltip">The action tooltip.</param> /// <param name="clickHandler">The click handler of the action.</param> /// <param name="permissionSpec">The permission specification for the action.</param> public ClickAction AddAction(object key, string displayName, string icon, string tooltip, ClickHandlerDelegate clickHandler, ISpecification permissionSpec) { return(AddActionHelper(key, displayName, icon, tooltip, clickHandler, permissionSpec)); }
private ButtonAction CreateToolbarAction(string id, string path, string tooltip, IconSet iconSet, ClickHandlerDelegate clickHandler) { id = String.Format("{0}:{1}", typeof(ClipboardComponent).FullName, id); ButtonAction action = new ButtonAction(id, new ActionPath(path, _resolver), ClickActionFlags.None, _resolver); action.IconSet = iconSet; action.Tooltip = tooltip; action.Label = action.Path.LastSegment.LocalizedText; action.SetClickHandler(clickHandler); return(action); }
/// <summary> /// Adds an action to the action model. /// </summary> /// <param name="key">The action key, so that actions can be easily retrieve via the <see cref="SimpleActionModel.this"/> indexer.</param> /// <param name="displayName">The display name for the action.</param> /// <param name="icon">The resource name of the icon.</param> /// <param name="tooltip">The action tooltip.</param> /// <param name="clickHandler">The click handler of the action.</param> public ClickAction AddAction(object key, string displayName, string icon, string tooltip, ClickHandlerDelegate clickHandler) { return AddActionHelper(key, displayName, icon, tooltip, clickHandler, null); }
internal ExceptionDialogControl(Exception exception, string message, ExceptionDialogActions buttonActions, ClickHandlerDelegate ok, ClickHandlerDelegate quit) { _exception = exception; InitializeComponent(); _description.Text = message; AcceptButton = _okButton; CancelButton = _okButton; EventHandler okClick = delegate { Result = ExceptionDialogAction.Ok; ok(); }; EventHandler quitClick = delegate { Result = ExceptionDialogAction.Quit; quit(); }; if (buttonActions == ExceptionDialogActions.Ok) { if (ok == null) { throw new ArgumentException("Ok method must be supplied", "ok"); } _okButton.Click += okClick; _quitButton.Dispose(); } else if (buttonActions == ExceptionDialogActions.Quit) { if (quit == null) { throw new ArgumentException("Quit method must be supplied", "quit"); } _quitButton.Click += quitClick; AcceptButton = _quitButton; CancelButton = _quitButton; _okButton.Dispose(); } else { if (ok == null) { throw new ArgumentException("Ok method must be supplied", "ok"); } if (quit == null) { throw new ArgumentException("Quit method must be supplied", "quit"); } _okButton.Click += okClick; _okButton.Text = SR.MenuContinue; _quitButton.Click += quitClick; } if (_exception != null) { // Update Exceptions detail tree _detailTree.BeginUpdate(); BuildTreeFromException(null, _exception); _detailTree.ExpandAll(); _detailTree.EndUpdate(); } else { _detailButton.Dispose(); } // Hide the details when dialog first startup HideDetails(); }
/// <summary> /// Adds an action to the action model. /// </summary> /// <param name="key">The action key, so that actions can be easily retrieve via the <see cref="SimpleActionModel.this"/> indexer.</param> /// <param name="displayName">The display name for the action.</param> /// <param name="icon">The resource name of the icon.</param> /// <param name="tooltip">The action tooltip.</param> /// <param name="clickHandler">The click handler of the action.</param> /// <param name="authorityToken">The authority token for the action.</param> public ClickAction AddAction(object key, string displayName, string icon, string tooltip, ClickHandlerDelegate clickHandler, string authorityToken) { return(AddActionHelper(key, displayName, icon, tooltip, clickHandler, new PrincipalPermissionSpecification(authorityToken))); }
protected MenuAction CreateMenuAction(IActionFactoryContext context, string label, ClickHandlerDelegate clickHandler) { Platform.CheckForEmptyString(label, "label"); Platform.CheckForNullReference(clickHandler, "clickHandler"); MenuAction menuAction = CreateMenuAction(context); menuAction.Label = label; menuAction.SetClickHandler(clickHandler); return(menuAction); }
/// <summary> /// Adds an action to the action model. /// </summary> /// <param name="key">The action key, so that actions can be easily retrieve via the <see cref="SimpleActionModel.this"/> indexer.</param> /// <param name="displayName">The display name for the action.</param> /// <param name="icon">The resource name of the icon.</param> /// <param name="tooltip">The action tooltip.</param> /// <param name="clickHandler">The click handler of the action.</param> public ClickAction AddAction(object key, [param: Localizable(true)] string displayName, string icon, [param: Localizable(true)] string tooltip, ClickHandlerDelegate clickHandler) { return(AddActionHelper(key, displayName, icon, tooltip, clickHandler, null)); }