Table of Contents

Class ActionStack

Namespace
CADability
Assembly
CADability.dll

A stack of actions. The top entry is the active action, the bottom entry usually is the SelectObjectsAction.

public class ActionStack
Inheritance
ActionStack
Inherited Members

Constructors

ActionStack(IFrame)

Creates an empty action stack for the given frame. The frame creates its own action stack, so there is usually no need to create one.

public ActionStack(IFrame Frame)

Parameters

Frame IFrame

The frame in which the actions run

Properties

ActiveAction

The action on top of the stack, which receives the mouse input, or null when the stack is empty.

public Action ActiveAction { get; }

Property Value

Action

Frame

The frame this action stack belongs to.

public IFrame Frame { get; }

Property Value

IFrame

Methods

FindAction(Type)

Searches the stack from top to bottom for an action of exactly the given type (derived types do not match).

public Action FindAction(Type typeOfAction)

Parameters

typeOfAction Type

The type of the action to look for, e.g. typeof(SelectObjectsAction)

Returns

Action

The topmost action of that type, or null if there is none

GetInfoProviderIndex(Point, IView)

Asks the active action which tooltip (info text) it wants to display for the given cursor position. Views may use it to show tooltips while the mouse rests over the view.

public int GetInfoProviderIndex(Point ScreenCursorPosition, IView View)

Parameters

ScreenCursorPosition Point

The cursor position

View IView

The view the cursor is in

Returns

int

An index identifying the info text, to be passed to GetInfoProviderText(int, InfoLevelMode, IView), or -1 if there is no active action or no info for that position

GetInfoProviderText(int, InfoLevelMode, IView)

Returns the tooltip text of the active action for an index returned by GetInfoProviderIndex(Point, IView).

public string GetInfoProviderText(int Index, InfoLevelMode Level, IView View)

Parameters

Index int

The index from GetInfoProviderIndex(Point, IView)

Level InfoLevelMode

The requested level of detail

View IView

The view the cursor is in

Returns

string

The text, or null if there is no active action or no text for that index

GetInfoProviderVerticalPosition(int, IView)

Returns the vertical position at which the active action wants its tooltip for the given index to be displayed.

public int GetInfoProviderVerticalPosition(int Index, IView View)

Parameters

Index int

The index from GetInfoProviderIndex(Point, IView)

View IView

The view the cursor is in

Returns

int

The vertical position in pixels, or 0 if there is no active action

OnCommand(string)

Executes a menu command by offering it to the actions on the stack from top to bottom until one handles it (see OnCommand(string)). Called by the frame; exceptions thrown by the actions are caught and ignored.

public virtual bool OnCommand(string MenuId)

Parameters

MenuId string

The id of the menu command

Returns

bool

true if an action handled the command, false otherwise

OnMouseDown(MouseEventArgs, IView)

Forwards a mouse down event from a view to the active action, if the action accepts input from that view (actions may restrict themselves to a certain view, view type or model), and makes that view the action's current mouse view. Views call this from their mouse event handlers. Exceptions thrown by the action are caught and ignored.

public void OnMouseDown(MouseEventArgs e, IView View)

Parameters

e MouseEventArgs

The mouse event arguments

View IView

The view in which the event occurred

OnMouseEnter(EventArgs, IView)

Forwards a mouse enter event from a view to the active action, if the action accepts input from that view. Views call this from their mouse event handlers. Exceptions thrown by the action are caught and ignored.

public void OnMouseEnter(EventArgs e, IView View)

Parameters

e EventArgs

The event arguments

View IView

The view in which the event occurred

OnMouseHover(EventArgs, IView)

Forwards a mouse hover event from a view to the active action, if the action accepts input from that view. Views call this from their mouse event handlers. Exceptions thrown by the action are caught and ignored.

public void OnMouseHover(EventArgs e, IView View)

Parameters

e EventArgs

The event arguments

View IView

The view in which the event occurred

OnMouseLeave(EventArgs, IView)

Forwards a mouse leave event from a view to the active action, if the action accepts input from that view. Views call this from their mouse event handlers. Exceptions thrown by the action are caught and ignored.

public void OnMouseLeave(EventArgs e, IView View)

Parameters

e EventArgs

The event arguments

View IView

The view in which the event occurred

OnMouseMove(MouseEventArgs, IView)

Forwards a mouse move event from a view to the active action, if the action accepts input from that view, and makes that view the action's current mouse view. When there is no active action or the action does not accept the view, the cursor of the view is set to "No". Views call this from their mouse event handlers. Exceptions thrown by the action are caught and ignored.

public void OnMouseMove(MouseEventArgs e, IView View)

Parameters

e MouseEventArgs

The mouse event arguments

View IView

The view in which the event occurred

OnMouseUp(MouseEventArgs, IView)

Forwards a mouse up event from a view to the active action, if the action accepts input from that view, and makes that view the action's current mouse view. Views call this from their mouse event handlers. Exceptions thrown by the action are caught and ignored.

public void OnMouseUp(MouseEventArgs e, IView View)

Parameters

e MouseEventArgs

The mouse event arguments

View IView

The view in which the event occurred

OnMouseWheel(MouseEventArgs, IView)

Forwards a mouse wheel event from a view to the active action, if the action accepts input from that view. Views call this from their mouse event handlers. Exceptions thrown by the action are caught and ignored.

public void OnMouseWheel(MouseEventArgs e, IView View)

Parameters

e MouseEventArgs

The mouse event arguments

View IView

The view in which the event occurred

OnUpdateCommand(string, CommandState)

Determines the state (enabled, checked) of a menu command by asking the actions on the stack from top to bottom until one handles it (see OnUpdateCommand(string, CommandState)). Actions lower on the stack are asked too, because e.g. the SelectObjectsAction at the bottom controls many commands while another action runs on top of it. Called by the frame; exceptions thrown by the actions are caught and ignored.

public virtual bool OnUpdateCommand(string MenuId, CommandState CommandState)

Parameters

MenuId string

The id of the menu command

CommandState CommandState

The state to fill in

Returns

bool

true if an action determined the state, false otherwise

OnViewsChanged()

Notifies all actions on the stack, the active action first, that views have been added or removed, by calling OnViewsChanged(). Called by the frame when its views change or a project is opened.

public void OnViewsChanged()

RemoveActiveAction()

Terminates the active action and removes it from the stack: calls its OnInactivate(Action, bool), pops it, activates the action below it (if any) with OnActivate(Action, bool), calls OnRemoveAction() and raises ActionTerminatedEvent. When the removed action returns true from AutoRepeat(), a new instance of it is created (with its parameterless constructor or a constructor taking the old action as the only parameter) and started. Actions usually terminate themselves with RemoveThisAction().

public void RemoveActiveAction()

Exceptions

ActionException

When there is no action on the stack

SetAction(Action)

Starts an action and makes it the active action: calls OnSetAction(), raises ActionStartedEvent, inactivates the previously active action (which may remove itself in OnInactivate(Action, bool)), pushes the new action onto the stack and calls its OnActivate(Action, bool). If the action wants to change the tab of the control center (ChangeTabInControlCenter), the "Action" page is brought to front and the previous page is restored when the action is removed. Usually called via SetAction(Action).

public void SetAction(Action Action)

Parameters

Action Action

The action to start