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
-
BaseActionActionGetPointActionGetRefPointActionEntity
- Implements
-
IBaseAction
- Derived
- Inherited Members
-
ActionGetRefPoint.ValueActionGetPoint.UserWaitingActionGetPoint.WaitingPointBaseAction.m_VisibleBaseAction.mFixPointLocationBaseAction.mIsParsedBaseAction.mUserValueBaseAction.mDefaultValueBaseAction.OsnapCrossMarksCountBaseAction.OsnapTrakingMarksMarksCountBaseAction.OsnapExtensionMarksCountBaseAction.OsnapMarksClearKeyBaseAction.ExtensionLockKeyBaseAction.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.OwnerBaseAction.AcceptedPointsBaseAction.MouseLogicBaseAction.IsTouchScreenBaseAction.IsPolarTrackOnBaseAction.IsOrthoPointFixedBaseAction.MouseArgsBaseAction.SelectedEntityBaseAction.SelectedEntitiesBaseAction.TemporaryOsnapsBaseAction.CurrentOsnapBaseAction.OsnapCrossPointsAddvalueBaseAction.FreezeEventsBaseAction.ShowOnPaintBaseAction.SendKeyEventsBaseAction.KeepFocusBaseAction.CancelOnFocusBaseAction.FixPointLocationBaseAction.ParalleAngleBaseAction.ApparentEntityBaseAction.IsParsedBaseAction.ValueTypePropBaseAction.IsStartUpActionBaseAction.IsStartedBaseAction.IsVisibleBaseAction.HasOsnapPointBaseAction.IsGripLocationBaseAction.HasPointZValueBaseAction.OsnapOverrideModeBaseAction.SupportOsnapsBaseAction.osnapPointsBaseAction.GdiMousePosBaseAction.PressedKeyCodeBaseAction.CancelledBaseAction.OrthoPointBaseAction.ReferencePointBaseAction.ExtensionReferencePointBaseAction.GdiReferencePointBaseAction.MouseLocationBaseAction.GdiMouseLocationBaseAction.RenderBaseAction.OsnapOrthoMouseLocationBaseAction.UsesDrawBaseAction.ContainsScreenPaintsBaseAction.ExtensionMarksBaseAction.IsFocusedBaseAction.DoEventsWithWin32APIBaseAction.IsInWaitingLoopBaseAction.IsPerspectiveOnBaseAction.OnMouseLeaveBaseAction.OnMouseEnterBaseAction.OnMouseMoveBaseAction.OnMouseDownBaseAction.OnMouseUpBaseAction.OnMouseDoubleClickBaseAction.OnTimerIdleBaseAction.OnWorldToUserMatrixBaseAction.OnCancelBaseAction.OnFinishBaseAction.OnDrawBaseAction.OnDrawAfterBaseAction.OnDrawOsnapsBaseAction.OnGetFixPositionBaseAction.OnShowBaseAction.OnHideBaseAction.OnJobLoopBaseAction.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:
- Entity - Return the entity being created or modified
- OnMyPositionChanged(gPoint) - Update the entity based on mouse movement
- needUpdate - Control whether the entity updates on each mouse move
- HideRubberLine - Control whether a rubber line is drawn from the reference point
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.