Table of Contents

Class Action

Namespace
CADability.Actions
Assembly
CADability.dll

Base class for all "Actions". An Action is an object, that receives various MouseInput events once it has been "Set" by a call to SetAction(Action). After performing the required tasks, the Action is removed from the ActionStack and the previous active action is resumed. The action on the bottom of the action stack is the SelectObjectsAction. Use the ConstructAction for typical drawing purposes, because it provides a convenient set of methods. If an action object is set by a call to SetAction(Action) the following sequence of calls to the new and the old action is executed:

public abstract class Action : ICommandHandler
Inheritance
Action
Implements
Derived
Inherited Members

Constructors

Action()

Creates a new Action and sets some default.

protected Action()

Fields

IgnoreForSnap

a list of objects that are not considered when snapping is resolved. Usually the object currently under construction (if any) is in this list.

protected GeoObjectList IgnoreForSnap

Field Value

GeoObjectList

MenuId

Contains the menu id of the command that invoked this action. used in OnUpdateCommand(string, CommandState).

protected string MenuId

Field Value

string

OnlyThisModel

If OnlyThisModel is not null, only those mouseevents are forwarded which come from a view that presents this model.

protected Model OnlyThisModel

Field Value

Model

OnlyThisView

If OnlyThisView is not null, only those mouseevents are forwarded which come from this view.

protected IView OnlyThisView

Field Value

IView

UseFilter

Use the active filter objects of the project for adjusting the mouse position (snap etc.)

public bool UseFilter

Field Value

bool

ViewType

If ViewType is not null, only those mouseevents are forwarded which come from a view of that type.

protected Type ViewType

Field Value

Type

Properties

ActiveDrawingPlane

Returns the active drawing plane, that is the drawing plane of the active view.

public Plane ActiveDrawingPlane { get; }

Property Value

Plane

AutoCursor

true: this class takes responsibility for setting the cursor, false: the derived class manages the cursor.

public bool AutoCursor { get; set; }

Property Value

bool

ChangeTabInControlCenter

true: this class may change the selection in the control center false: this class may not change the selection in the control center

public bool ChangeTabInControlCenter { get; set; }

Property Value

bool

CurrentMousePosition

Returns the current mouse position.

public Point CurrentMousePosition { get; }

Property Value

Point

CurrentMouseView

The view from which the last OnMouseMove/Up/Down was evoked

protected IView CurrentMouseView { get; set; }

Property Value

IView

FeedBack

Provides access to the "feedback" object, which is used to define visual feedback of the action. When objects in a model are modified, you will immediately see the feedback (if this model is visible in a ModelView). But sometimes you need more feedback, like arrows or imtermediate objects that change while the mousinput (or controlcenter input or some other conditions) change. Add those objects to the feedback and they will be displayed immediately.

public ActionFeedBack FeedBack { get; }

Property Value

ActionFeedBack

Frame

Returns the frame (IFrame) of the context of this action. The frame also gives access to the project.

public IFrame Frame { get; }

Property Value

IFrame

IsActive

Checks, whether this action is the currently active action

protected bool IsActive { get; }

Property Value

bool

PreviousAction

The action below this one on the action stack, i.e. the action that was active before this one was set and becomes active again when this one is removed. Null if there is none or this action is not on the stack.

public Action PreviousAction { get; }

Property Value

Action

WorksOnLayoutView

Determins, wether this action can work on a LayoutView. Default implementation returns false. Override, if your Action can work on a LayoutView.

public virtual bool WorksOnLayoutView { get; }

Property Value

bool

Methods

AutoRepeat()

Defines, whether this Action should be repeated after it was removed. The default implementation returns false, override it if you want a different behaviour.

public virtual bool AutoRepeat()

Returns

bool

true to repeat, false otherwise

AutoRepeated()

Called before OnSetAction() is called, if the action is created by the "autorepeat" machanism.

public virtual void AutoRepeated()

CurveHitTest(ICurve, Point)

Detects whether a given curve (ICurve) is touched by the cursor position given in mousePoint in respect to the active view. The setting "Select.Pick" gives the maximum pixel distance for the test.

public bool CurveHitTest(ICurve curve, Point mousePoint)

Parameters

curve ICurve

the curve to test

mousePoint Point

the mouse position

Returns

bool

true if the mouse position is close to the curve

GetID()

Must be implemented by derived class. Returns an identification string. All CADability actions return the unique strings like "Draw.Line.TwoPoints" or "Zoom"

public abstract string GetID()

Returns

string

the identification of the action

GetObjectsUnderCursor(Point)

Returns a list of IGeoObjects that are close to the mouse point with respect to the current view.

public GeoObjectList GetObjectsUnderCursor(Point mousePoint)

Parameters

mousePoint Point

the mouse position to test

Returns

GeoObjectList

list of touched IGeoObjects

OnActivate(Action, bool)

The action has been activated. From now on it will receive calls of the mouse event methods like OnMouseMove(MouseEventArgs, IView).

public virtual void OnActivate(Action OldActiveAction, bool SettingAction)

Parameters

OldActiveAction Action

the action that was active

SettingAction bool

true: if the action has bee set, false: if the action is resumed

OnCommand(string)

Override if you want to process menu commands with your action. Default implementation always returns false.

public virtual bool OnCommand(string MenuId)

Parameters

MenuId string

the menu id to process

Returns

bool

true if processed, false if not

OnDelete()

This method will be called when the user presses the delete key. The default implementation does nothing.

public virtual bool OnDelete()

Returns

bool

OnDelete(object)

This method will be called when the user presses the delete key. The default implementation does nothing.

public virtual bool OnDelete(object sender)

Parameters

sender object

Returns

bool

OnDisplayChanged(DisplayChangeArg)

Zooming or scrolling changed the visible aspect of the current view.

public virtual void OnDisplayChanged(DisplayChangeArg d)

Parameters

d DisplayChangeArg

the reason for the call

OnEnter()

This method will be called when the user presses the enter key. The default implementation does nothing.

public virtual bool OnEnter()

Returns

bool

OnEnter(object)

This method will be called when the user presses the enter key. The default implementation does nothing.

public virtual bool OnEnter(object sender)

Parameters

sender object

Returns

bool

OnEscape()

This method will be called when the user presses the escape key. The default implementation does nothing.

public virtual bool OnEscape()

Returns

bool

OnEscape(object)

This method will be called when the user presses the escape key. The default implementation does nothing.

public virtual bool OnEscape(object sender)

Parameters

sender object

Returns

bool

OnInactivate(Action, bool)

The action has been inactivated. No more calls to the mouse events will appear.

public virtual void OnInactivate(Action NewActiveAction, bool RemovingAction)

Parameters

NewActiveAction Action

the action that will become active

RemovingAction bool

true: if called because the action is removed, false: if called when a new action is set on top of this action

OnMouseDown(MouseEventArgs, IView)

Override this method to react on the MouseDown event.

public virtual void OnMouseDown(MouseEventArgs e, IView vw)

Parameters

e MouseEventArgs

MouseEventArgs of the call

vw IView

the IView which contains the mouse

OnMouseEnter(EventArgs, IView)

Override this method to react on the MouseEnter event.

public virtual void OnMouseEnter(EventArgs e, IView vw)

Parameters

e EventArgs

MouseEventArgs of the call

vw IView

the IView which contains the mouse

OnMouseHover(EventArgs, IView)

Override this method to react on the MouseHover event.

public virtual void OnMouseHover(EventArgs e, IView vw)

Parameters

e EventArgs

MouseEventArgs of the call

vw IView

the IView which contains the mouse

OnMouseLeave(EventArgs, IView)

Override this method to react on the MouseLeave event.

public virtual void OnMouseLeave(EventArgs e, IView vw)

Parameters

e EventArgs

MouseEventArgs of the call

vw IView

the IView which contains the mouse

OnMouseMove(MouseEventArgs, IView)

Override this method to react on the MouseMove event.

public virtual void OnMouseMove(MouseEventArgs e, IView vw)

Parameters

e MouseEventArgs

MouseEventArgs of the call

vw IView

the IView which contains the mouse

OnMouseUp(MouseEventArgs, IView)

Override this method to react on the MouseUp event.

public virtual void OnMouseUp(MouseEventArgs e, IView vw)

Parameters

e MouseEventArgs

MouseEventArgs of the call

vw IView

the IView which contains the mouse

OnMouseWheel(MouseEventArgs, IView)

Override this method to react on the MouseWheel event.

public virtual void OnMouseWheel(MouseEventArgs e, IView vw)

Parameters

e MouseEventArgs

MouseEventArgs of the call

vw IView

the IView which contains the mouse

OnRemoveAction()

Last event that is called when the action is removed from the action stack.

public virtual void OnRemoveAction()

OnSelected(MenuWithHandler, bool)

Override if your action needs to handle menu selection changes (very rare)

public virtual void OnSelected(MenuWithHandler selectedMenuItem, bool selected)

Parameters

selectedMenuItem MenuWithHandler

the menu item that was selected or deselected

selected bool

true, if selected, false if deselected

OnSetAction()

First event that is called when the action is set via SetAction(Action)

public virtual void OnSetAction()

OnTab(object)

This method will be called when the user presses the tab key. The default implementation does nothing.

public virtual bool OnTab(object sender)

Parameters

sender object

Returns

bool

OnUpdateCommand(string, CommandState)

Override if you also override OnCommand(string) to manipulate the appearance of the corresponding menu item or the state of the toolbar button. The default implementation checks whether the MenuId from the parameter corresponds to the menuId member variable and checks the item if appropriate

public virtual bool OnUpdateCommand(string MenuId, CommandState CommandState)

Parameters

MenuId string

menu id the command state is queried for

CommandState CommandState

the command state to manipulate

Returns

bool

OnViewsChanged()

Will be called if new views (LayoutView or ModelView) are created or removed from the project. Default implementation does nothing.

public virtual void OnViewsChanged()

RemoveThisAction()

Removes this action from the action stack if this action is on top of the action stack

public void RemoveThisAction()

SetCursor(DidSnapModes, IView)

Sets the cursor int hte provided view according to the provided snap mode. The cursors may be redefined by calling SetCursor(DidSnapModes, string)

protected void SetCursor(SnapPointFinder.DidSnapModes DidSnap, IView vw)

Parameters

DidSnap SnapPointFinder.DidSnapModes
vw IView

SetCursor(DidSnapModes, string)

Sets the cursor name for different snap situation. The CursorTable contains the resources of the named cursors.

public void SetCursor(SnapPointFinder.DidSnapModes DidSnap, string CursorName)

Parameters

DidSnap SnapPointFinder.DidSnapModes

the snap situation

CursorName string

the name of the cursor

SnapPoint(MouseEventArgs, GeoPoint, IView, out DidSnapModes)

Returns a snap point according to the current snap settings in the given IView with respect to a basepoint. Sets the cursor if AutoCursor is true.

public GeoPoint SnapPoint(MouseEventArgs e, GeoPoint BasePoint, IView vw, out SnapPointFinder.DidSnapModes DidSnap)

Parameters

e MouseEventArgs

point in the view

BasePoint GeoPoint

the base point

vw IView

the view

DidSnap SnapPointFinder.DidSnapModes

kind of snap operation that was used

Returns

GeoPoint

the best snapping point found

SnapPoint(MouseEventArgs, IView, out DidSnapModes)

Returns a snap point according to the current snap settings in the given IView. Sets the cursor if AutoCursor is true.

public GeoPoint SnapPoint(MouseEventArgs e, IView vw, out SnapPointFinder.DidSnapModes DidSnap)

Parameters

e MouseEventArgs

point in the view

vw IView

the view

DidSnap SnapPointFinder.DidSnapModes

kind of snap operation that was used

Returns

GeoPoint

the best snapping point found

WorldDirection(Angle)

Returns a 3D vector in the world coordinate system corresponding to the given angle in the active drawing plane.

public GeoVector WorldDirection(Angle a)

Parameters

a Angle

Angle of the requested direction

Returns

GeoVector

Direction vector of the angle a

WorldLength(double)

Coverts the given length in pixel (screen) coordinates to w length in the model coordinate system of the active view

public double WorldLength(double ViewLength)

Parameters

ViewLength double

Returns

double

WorldPoint(GeoPoint2D)

Returns a 3D point in the world coordinate system corresponding to the given 2D point in the active drawing plane.

public GeoPoint WorldPoint(GeoPoint2D p)

Parameters

p GeoPoint2D

2D point in the drawing plane

Returns

GeoPoint

3D point in the world coordinate system

WorldPoint(MouseEventArgs, IView)

Returns a GeoPoint in the model coordinate system that corresponds to the MouseEventArgs point. No snapping is performed. The drawing plane of the projection is used

public GeoPoint WorldPoint(MouseEventArgs e, IView vw)

Parameters

e MouseEventArgs

a MouseEventArgs object, that contains the window coordinate

vw IView

the IView of the MouseEventArgs

Returns

GeoPoint

the model coordinate

WorldPoint(Point)

Returns a GeoPoint in the model coordinate system that corresponds to the Client point. No snapping is performed. The drawing plane of the projection is used

public GeoPoint WorldPoint(Point p)

Parameters

p Point

Point in the client coordinate system of the active view

Returns

GeoPoint

the model coordinate