Table of Contents

Class ActionEntity

Namespace
VectorDraw.Professional.Actions
Assembly
VectorDraw.Professional.dll

Implements the ActionEntity object. This is a base object for generating actions between the component and the user.

public abstract class ActionEntity : ActionGetRefPoint, IDisposable, IBaseObject, IBaseAction
Inheritance
BaseAction
ActionGetPoint
ActionGetRefPoint
ActionEntity
Implements
IBaseAction
Derived
Inherited Members
ActionGetRefPoint.Value
ActionGetPoint.UserWaiting
ActionGetPoint.WaitingPoint
BaseAction.m_Visible
BaseAction.mFixPointLocation
BaseAction.mIsParsed
BaseAction.mUserValue
BaseAction.mDefaultValue
BaseAction.OsnapCrossMarksCount
BaseAction.OsnapTrakingMarksMarksCount
BaseAction.OsnapExtensionMarksCount
BaseAction.OsnapMarksClearKey
BaseAction.ExtensionLockKey
BaseAction.GetAcceptedStringValues()
BaseAction.RaiseOnShow()
BaseAction.RaiseOnHide()
BaseAction.RaiseOnDrawOsnaps(OsnapMode, vdRender)
BaseAction.RaiseOnWorldToUserMatrix()
BaseAction.RaiseOnFinishAction(BaseAction)
BaseAction.RaiseOnCancelAction(BaseAction)
BaseAction.SetsupportObjectSnapObject(ISupportObjectSnaps)
BaseAction.ClearTemporaryOsnaps()
BaseAction.GetValueString(LUnits, AUnits)
BaseAction.GetRender()
BaseAction.Start()
BaseAction.End()
BaseAction.Activated()
BaseAction.DeActivated()
BaseAction.AllowDeactivateFromAction(BaseAction)
BaseAction.Show()
BaseAction.Draw()
BaseAction.Hide()
BaseAction.ScreenPaint(ActionWrapperRender)
BaseAction.GotFocus()
BaseAction.LostFocus()
BaseAction.WndProc(MessageManager.MSG)
BaseAction.OnIdle()
BaseAction.MouseEnter()
BaseAction.MouseLeave()
BaseAction.RestoreCursor()
BaseAction.WaitToFinish()
BaseAction.FinishAction(BaseAction)
BaseAction.CancelAction(BaseAction)
BaseAction.DrawAxis()
BaseAction.DrawPick()
BaseAction.DrawCross(gPoint)
BaseAction.Owner
BaseAction.AcceptedPoints
BaseAction.MouseLogic
BaseAction.IsTouchScreen
BaseAction.IsPolarTrackOn
BaseAction.IsOrthoPointFixed
BaseAction.MouseArgs
BaseAction.SelectedEntity
BaseAction.SelectedEntities
BaseAction.TemporaryOsnaps
BaseAction.CurrentOsnap
BaseAction.OsnapCrossPointsAddvalue
BaseAction.FreezeEvents
BaseAction.ShowOnPaint
BaseAction.SendKeyEvents
BaseAction.KeepFocus
BaseAction.CancelOnFocus
BaseAction.FixPointLocation
BaseAction.ParalleAngle
BaseAction.ApparentEntity
BaseAction.IsParsed
BaseAction.ValueTypeProp
BaseAction.IsStartUpAction
BaseAction.IsStarted
BaseAction.IsVisible
BaseAction.HasOsnapPoint
BaseAction.IsGripLocation
BaseAction.HasPointZValue
BaseAction.OsnapOverrideMode
BaseAction.SupportOsnaps
BaseAction.osnapPoints
BaseAction.GdiMousePos
BaseAction.PressedKeyCode
BaseAction.Cancelled
BaseAction.OrthoPoint
BaseAction.ReferencePoint
BaseAction.ExtensionReferencePoint
BaseAction.GdiReferencePoint
BaseAction.MouseLocation
BaseAction.GdiMouseLocation
BaseAction.Render
BaseAction.OsnapOrthoMouseLocation
BaseAction.UsesDraw
BaseAction.ContainsScreenPaints
BaseAction.ExtensionMarks
BaseAction.IsFocused
BaseAction.DoEventsWithWin32API
BaseAction.IsInWaitingLoop
BaseAction.IsPerspectiveOn
BaseAction.OnMouseLeave
BaseAction.OnMouseEnter
BaseAction.OnMouseMove
BaseAction.OnMouseDown
BaseAction.OnMouseUp
BaseAction.OnMouseDoubleClick
BaseAction.OnTimerIdle
BaseAction.OnWorldToUserMatrix
BaseAction.OnCancel
BaseAction.OnFinish
BaseAction.OnDraw
BaseAction.OnDrawAfter
BaseAction.OnDrawOsnaps
BaseAction.OnGetFixPosition
BaseAction.OnShow
BaseAction.OnHide
BaseAction.OnJobLoop
BaseAction.OnJobLoopEx

Remarks

The ActionEntity class provides a foundation for creating interactive user actions that involve drawing and manipulating entities within a vdLayout. It handles coordinate system transformations, mouse position tracking, and entity rendering during the action.

To create a custom action, derive from ActionEntity and override the following key members:

This example demonstrates creating a custom action to interactively draw a rectangle. The user specifies an insertion point, a second point for width and rotation, and then moves the mouse to define the height.
private bool NewRectCommand()
{
    doc.Prompt("Insertion Point of Rect:");
    gPoint InsertionPt = doc.ActionUtility.getUserPoint() as gPoint;
    if (InsertionPt == null) return false;
    doc.Prompt(null);
gPoint SecondPointWidth = null;
doc.Prompt("Second Point for Width and Rotation of Rect:");
StatusCode status = doc.ActionUtility.getUserRefPoint(InsertionPt, out SecondPointWidth);
doc.Prompt(null);
if (status != StatusCode.Success) return false;

StatusCode ret = StatusCode.Other;
ActionMyRect myAction = new ActionMyRect(InsertionPt, SecondPointWidth, doc.ActiveLayOut);
doc.ActionAdd(myAction);
ret = myAction.WaitToFinish();
if (ret == VectorDraw.Actions.StatusCode.Success)
{
    vdRect rect = myAction.Entity as vdRect;
    if (rect == null) return false;
    vdRect Myrect = rect.Clone(doc) as vdRect;
    Myrect.Transformby(doc.User2WorldMatrix);
    doc.ActiveLayOut.Entities.AddItem(Myrect);
    doc.ActionDrawFigure(Myrect);
    return true;
}
return false;

}

public class ActionMyRect : VectorDraw.Professional.Actions.ActionEntity { /// <summary> /// A vdRect object created from the action. /// </summary> protected vdRect rect; gPoint FirstPt = null; gPoint SecondPt = null;

/// <summary>
/// Initializes the object with the given parameters.
/// </summary>
/// <param name="InsertionPoint">First Insertion Point of rect</param>
/// <param name="SecondPoint">Second Point where we calculate the rotation and the width of the rect.</param>
/// <param name="layout">The vdLayout object where the action takes place.</param>
public ActionMyRect(gPoint InsertionPoint, gPoint SecondPoint, vdLayout layout)
    : base(InsertionPoint, layout)
{
    ValueTypeProp |= valueType.REFPOINT;
    rect = new vdRect();
    rect.SetUnRegisterDocument(layout.Document);
    rect.setDocumentDefaults();
    rect.InsertionPoint = InsertionPoint;
    rect.Rotation = InsertionPoint.GetAngle(SecondPoint);
    rect.Width = InsertionPoint.Distance2D(SecondPoint);
    FirstPt = new gPoint(InsertionPoint);
    SecondPt = new gPoint(SecondPoint);
}

/// <summary>
/// The reference point of the action in World Coordinate System.
/// </summary>
public override gPoint ReferencePoint
{
    get
    {
        return base.ReferencePoint;
    }
    set
    {
        base.ReferencePoint = value;
        if (ReferencePoint != null && this.Entity != null && Layout != null)
        {
            rect.InsertionPoint = Layout.Document.World2UserMatrix.Transform(ReferencePoint);
        }
    }
}

/// <summary>
/// Get a value that represents if the rubber line is drawn or not. Returns false since a rubber line is needed.
/// </summary>
public override bool HideRubberLine
{
    get
    {
        return false;
    }
}

/// <summary>
/// The entity which is currently selected for this action. Returns the created rect.
/// </summary>
public override vdFigure Entity
{
    get
    {
        return rect;
    }
}

/// <summary>
/// Called when the mouse position changes. We calculate the Height of the rect from the distance of the cursor from the Initial rect width line.
/// </summary>
/// <param name="newPosition">A gPoint representing the new mouse position in User Coordinate System.</param>
protected override void OnMyPositionChanged(gPoint newPosition)
{
    vdLine l = new vdLine();
    l.StartPoint = FirstPt;
    l.EndPoint = SecondPt;
    gPoint WorldNewPos = Layout.Document.User2WorldMatrix.Transform(newPosition);
    l.Transformby(Layout.Document.User2WorldMatrix);
    double side = l.TestOffsetSide(WorldNewPos);

    if (side > 0.0)
    {
        rect.Height = Globals.distPointFromLine(newPosition, FirstPt, SecondPt);
    }
    else
    {
        rect.Height = -Globals.distPointFromLine(newPosition, FirstPt, SecondPt);
    }
}

/// <summary>
/// Get a value that represents if the entity should be updated after each position change. Returns true since an update is needed.
/// </summary>
public override bool needUpdate
{
    get
    {
        return true;
    }
}

}

Constructors

ActionEntity(gPoint, vdLayout)

Initializes the object with the passed parameters.

Properties

Entity

The entity which is currently selected for this action.

HideRubberLine

Get a value that represents if the rubber line is drawn or not.

IsEntityInUserCS

Default value is true which means that the entity is in UserCS and during draw the User2WorldMatrix is pushed to the Render.

Layout

Get the vdLayout object where the action will take place.

ValuePointCS

Get a value that represents the coordinate system of the VectorDraw.Actions.BaseAction.Value property.

needUpdate

Get a value that represents if the entity should be updated after each position change.

Methods

Dispose()

Dispose of the object.

DrawEntity(vdRender)

Called from PureDraw method when the action entity is to be drawn or hide to the screen.

OnAfterDrawEntity()

Called after drawning Entity property object using VectorDraw.Render rendering graphics engine. Default implementation do nothing.

OnBeforeDrawEntity()

Called before drawning Entity property object using VectorDraw.Render rendering graphics engine. Default implementation do nothing.

OnFinishAction()

Called when the action is finished.

OnMyPositionChanged(gPoint)

Called when the mouse position changes.

OnPositionChanged(gPoint)

Called when the mouse position changes.

PureDraw()

Called when the action entity is to be drawn to the screen.