Class Action
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:
- new action: OnSetAction() (as a reaction to SetAction(Action))
- old action: OnInactivate(Action, Boolean) (may call RemoveActiveAction() if desired)
- new action: OnActivate(Action, Boolean) (from now on the new action may receive mouse events).
- After the new action calls RemoveThisAction() or someone calls RemoveActiveAction() the new action will receive OnInactivate(Action, Boolean).
- The old action (if still on the stack) will receive a call to OnActivate(Action, Boolean) and finally
- the new action will receive a call to OnRemoveAction() as a last call.
Inheritance
Implements
Inherited Members
Namespace: CADability.Actions
Assembly: CADability.dll
Syntax
public abstract class Action : ICommandHandler
Constructors
| Improve this Doc View SourceAction()
Creates a new Action and sets some default.
Declaration
protected Action()
Fields
| Improve this Doc View SourceIgnoreForSnap
a list of objects that are not considered when snapping is resolved. Usually the object currently under construction (if any) is in this list.
Declaration
protected GeoObjectList IgnoreForSnap
Field Value
| Type | Description |
|---|---|
| GeoObjectList |
MenuId
Contains the menu id of the command that invoked this action. used in OnUpdateCommand(String, CommandState).
Declaration
protected string MenuId
Field Value
| Type | Description |
|---|---|
| System.String |
OnlyThisModel
If OnlyThisModel is not null, only those mouseevents are forwarded which come from a view that presents this model.
Declaration
protected Model OnlyThisModel
Field Value
| Type | Description |
|---|---|
| Model |
OnlyThisView
If OnlyThisView is not null, only those mouseevents are forwarded which come from this view.
Declaration
protected IView OnlyThisView
Field Value
| Type | Description |
|---|---|
| IView |
UseFilter
Use the active filter objects of the project for adjusting the mouse position (snap etc.)
Declaration
public bool UseFilter
Field Value
| Type | Description |
|---|---|
| System.Boolean |
ViewType
If ViewType is not null, only those mouseevents are forwarded which come from a view of that type.
Declaration
protected Type ViewType
Field Value
| Type | Description |
|---|---|
| System.Type |
Properties
| Improve this Doc View SourceActiveDrawingPlane
Returns the active drawing plane, that is the drawing plane of the active view.
Declaration
public Plane ActiveDrawingPlane { get; }
Property Value
| Type | Description |
|---|---|
| Plane |
AutoCursor
true: this class takes responsibility for setting the cursor, false: the derived class manages the cursor.
Declaration
public bool AutoCursor { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
ChangeTabInControlCenter
true: this class may change the selection in the control center false: this class may not change the selection in the control center
Declaration
public bool ChangeTabInControlCenter { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
CurrentMousePosition
Returns the current mouse position.
Declaration
public Point CurrentMousePosition { get; }
Property Value
| Type | Description |
|---|---|
| System.Drawing.Point |
CurrentMouseView
The view from which the last OnMouseMove/Up/Down was evoked
Declaration
protected IView CurrentMouseView { get; set; }
Property Value
| Type | Description |
|---|---|
| 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.
Declaration
public ActionFeedBack FeedBack { get; }
Property Value
| Type | Description |
|---|---|
| ActionFeedBack |
Frame
Returns the frame (IFrame) of the context of this action. The frame also gives access to the project.
Declaration
public IFrame Frame { get; }
Property Value
| Type | Description |
|---|---|
| IFrame |
IsActive
Checks, whether this action is the currently active action
Declaration
protected bool IsActive { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
PreviousAction
Declaration
public Action PreviousAction { get; }
Property Value
| Type | Description |
|---|---|
| Action |
WorksOnLayoutView
Determins, wether this action can work on a LayoutView. Default implementation returns false. Override, if your Action can work on a LayoutView.
Declaration
public virtual bool WorksOnLayoutView { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Methods
| Improve this Doc View SourceAutoRepeat()
Defines, whether this Action should be repeated after it was removed. The default implementation returns false, override it if you want a different behaviour.
Declaration
public virtual bool AutoRepeat()
Returns
| Type | Description |
|---|---|
| System.Boolean | true to repeat, false otherwise |
AutoRepeated()
Called before OnSetAction() is called, if the action is created by the "autorepeat" machanism.
Declaration
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.
Declaration
public bool CurveHitTest(ICurve curve, Point mousePoint)
Parameters
| Type | Name | Description |
|---|---|---|
| ICurve | curve | the curve to test |
| System.Drawing.Point | mousePoint | the mouse position |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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"
Declaration
public abstract string GetID()
Returns
| Type | Description |
|---|---|
| System.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.
Declaration
public GeoObjectList GetObjectsUnderCursor(Point mousePoint)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Drawing.Point | mousePoint | the mouse position to test |
Returns
| Type | Description |
|---|---|
| GeoObjectList | list of touched IGeoObjects |
OnActivate(Action, Boolean)
The action has been activated. From now on it will receive calls of the mouse event methods like OnMouseMove(MouseEventArgs, IView).
Declaration
public virtual void OnActivate(Action OldActiveAction, bool SettingAction)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | OldActiveAction | the action that was active |
| System.Boolean | SettingAction | 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.
Declaration
public virtual bool OnCommand(string MenuId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | MenuId | the menu id to process |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if processed, false if not |
OnDelete()
This method will be called when the user presses the delete key. The default implementation does nothing.
Declaration
public virtual bool OnDelete()
Returns
| Type | Description |
|---|---|
| System.Boolean |
OnDelete(Object)
This method will be called when the user presses the delete key. The default implementation does nothing.
Declaration
public virtual bool OnDelete(object sender)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | sender |
Returns
| Type | Description |
|---|---|
| System.Boolean |
OnDisplayChanged(DisplayChangeArg)
Zooming or scrolling changed the visible aspect of the current view.
Declaration
public virtual void OnDisplayChanged(DisplayChangeArg d)
Parameters
| Type | Name | Description |
|---|---|---|
| DisplayChangeArg | d | the reason for the call |
OnEnter()
This method will be called when the user presses the enter key. The default implementation does nothing.
Declaration
public virtual bool OnEnter()
Returns
| Type | Description |
|---|---|
| System.Boolean |
OnEnter(Object)
This method will be called when the user presses the enter key. The default implementation does nothing.
Declaration
public virtual bool OnEnter(object sender)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | sender |
Returns
| Type | Description |
|---|---|
| System.Boolean |
OnEscape()
This method will be called when the user presses the escape key. The default implementation does nothing.
Declaration
public virtual bool OnEscape()
Returns
| Type | Description |
|---|---|
| System.Boolean |
OnEscape(Object)
This method will be called when the user presses the escape key. The default implementation does nothing.
Declaration
public virtual bool OnEscape(object sender)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | sender |
Returns
| Type | Description |
|---|---|
| System.Boolean |
OnInactivate(Action, Boolean)
The action has been inactivated. No more calls to the mouse events will appear.
Declaration
public virtual void OnInactivate(Action NewActiveAction, bool RemovingAction)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | NewActiveAction | the action that will become active |
| System.Boolean | RemovingAction | 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.
Declaration
public virtual void OnMouseDown(MouseEventArgs e, IView vw)
Parameters
| Type | Name | Description |
|---|---|---|
| MouseEventArgs | e | MouseEventArgs of the call |
| IView | vw | the IView which contains the mouse |
OnMouseEnter(EventArgs, IView)
Override this method to react on the MouseEnter event.
Declaration
public virtual void OnMouseEnter(EventArgs e, IView vw)
Parameters
| Type | Name | Description |
|---|---|---|
| System.EventArgs | e | MouseEventArgs of the call |
| IView | vw | the IView which contains the mouse |
OnMouseHover(EventArgs, IView)
Override this method to react on the MouseHover event.
Declaration
public virtual void OnMouseHover(EventArgs e, IView vw)
Parameters
| Type | Name | Description |
|---|---|---|
| System.EventArgs | e | MouseEventArgs of the call |
| IView | vw | the IView which contains the mouse |
OnMouseLeave(EventArgs, IView)
Override this method to react on the MouseLeave event.
Declaration
public virtual void OnMouseLeave(EventArgs e, IView vw)
Parameters
| Type | Name | Description |
|---|---|---|
| System.EventArgs | e | MouseEventArgs of the call |
| IView | vw | the IView which contains the mouse |
OnMouseMove(MouseEventArgs, IView)
Override this method to react on the MouseMove event.
Declaration
public virtual void OnMouseMove(MouseEventArgs e, IView vw)
Parameters
| Type | Name | Description |
|---|---|---|
| MouseEventArgs | e | MouseEventArgs of the call |
| IView | vw | the IView which contains the mouse |
OnMouseUp(MouseEventArgs, IView)
Override this method to react on the MouseUp event.
Declaration
public virtual void OnMouseUp(MouseEventArgs e, IView vw)
Parameters
| Type | Name | Description |
|---|---|---|
| MouseEventArgs | e | MouseEventArgs of the call |
| IView | vw | the IView which contains the mouse |
OnMouseWheel(MouseEventArgs, IView)
Override this method to react on the MouseWheel event.
Declaration
public virtual void OnMouseWheel(MouseEventArgs e, IView vw)
Parameters
| Type | Name | Description |
|---|---|---|
| MouseEventArgs | e | MouseEventArgs of the call |
| IView | vw | the IView which contains the mouse |
OnRemoveAction()
Last event that is called when the action is removed from the action stack.
Declaration
public virtual void OnRemoveAction()
OnSelected(MenuWithHandler, Boolean)
Override if your action needs to handle menu selection changes (very rare)
Declaration
public virtual void OnSelected(MenuWithHandler selectedMenuItem, bool selected)
Parameters
| Type | Name | Description |
|---|---|---|
| MenuWithHandler | selectedMenuItem | |
| System.Boolean | selected |
OnSetAction()
First event that is called when the action is set via SetAction(Action)
Declaration
public virtual void OnSetAction()
OnTab(Object)
This method will be called when the user presses the tab key. The default implementation does nothing.
Declaration
public virtual bool OnTab(object sender)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | sender |
Returns
| Type | Description |
|---|---|
| System.Boolean |
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
Declaration
public virtual bool OnUpdateCommand(string MenuId, CommandState CommandState)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | MenuId | menu id the command state is queried for |
| CommandState | CommandState | the command state to manipulate |
Returns
| Type | Description |
|---|---|
| System.Boolean |
OnViewsChanged()
Will be called if new views (LayoutView or ModelView) are created or removed from the project. Default implementation does nothing.
Declaration
public virtual void OnViewsChanged()
RemoveThisAction()
Removes this action from the action stack if this action is on top of the action stack
Declaration
public void RemoveThisAction()
SetCursor(SnapPointFinder.DidSnapModes, IView)
Sets the cursor int hte provided view according to the provided snap mode. The cursors may be redefined by calling SetCursor(SnapPointFinder.DidSnapModes, String)
Declaration
protected void SetCursor(SnapPointFinder.DidSnapModes DidSnap, IView vw)
Parameters
| Type | Name | Description |
|---|---|---|
| SnapPointFinder.DidSnapModes | DidSnap | |
| IView | vw |
SetCursor(SnapPointFinder.DidSnapModes, String)
Sets the cursor name for different snap situation. The CursorTable contains the resources of the named cursors.
Declaration
public void SetCursor(SnapPointFinder.DidSnapModes DidSnap, string CursorName)
Parameters
| Type | Name | Description |
|---|---|---|
| SnapPointFinder.DidSnapModes | DidSnap | the snap situation |
| System.String | CursorName | the name of the cursor |
SnapPoint(MouseEventArgs, GeoPoint, IView, out SnapPointFinder.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.
Declaration
public GeoPoint SnapPoint(MouseEventArgs e, GeoPoint BasePoint, IView vw, out SnapPointFinder.DidSnapModes DidSnap)
Parameters
| Type | Name | Description |
|---|---|---|
| MouseEventArgs | e | point in the view |
| GeoPoint | BasePoint | the base point |
| IView | vw | the view |
| SnapPointFinder.DidSnapModes | DidSnap | kind of snap operation that was used |
Returns
| Type | Description |
|---|---|
| GeoPoint | the best snapping point found |
SnapPoint(MouseEventArgs, IView, out SnapPointFinder.DidSnapModes)
Returns a snap point according to the current snap settings in the given IView. Sets the cursor if AutoCursor is true.
Declaration
public GeoPoint SnapPoint(MouseEventArgs e, IView vw, out SnapPointFinder.DidSnapModes DidSnap)
Parameters
| Type | Name | Description |
|---|---|---|
| MouseEventArgs | e | point in the view |
| IView | vw | the view |
| SnapPointFinder.DidSnapModes | DidSnap | kind of snap operation that was used |
Returns
| Type | Description |
|---|---|
| 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.
Declaration
public GeoVector WorldDirection(Angle a)
Parameters
| Type | Name | Description |
|---|---|---|
| Angle | a | Angle of the requested direction |
Returns
| Type | Description |
|---|---|
| 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
Declaration
public double WorldLength(double ViewLength)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | ViewLength |
Returns
| Type | Description |
|---|---|
| System.Double |
WorldPoint(GeoPoint2D)
Returns a 3D point in the world coordinate system corresponding to the given 2D point in the active drawing plane.
Declaration
public GeoPoint WorldPoint(GeoPoint2D p)
Parameters
| Type | Name | Description |
|---|---|---|
| GeoPoint2D | p | 2D point in the drawing plane |
Returns
| Type | Description |
|---|---|
| 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
Declaration
public GeoPoint WorldPoint(MouseEventArgs e, IView vw)
Parameters
| Type | Name | Description |
|---|---|---|
| MouseEventArgs | e | a MouseEventArgs object, that contains the window coordinate |
| IView | vw | the IView of the MouseEventArgs |
Returns
| Type | Description |
|---|---|
| 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
Declaration
public GeoPoint WorldPoint(Point p)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Drawing.Point | p | Point in the client coordinate system of the active view |
Returns
| Type | Description |
|---|---|
| GeoPoint | the model coordinate |