| Article | 60000173 |
| Type | Wish |
| Product | Engine |
| Version | 6006 |
| Date Added | 5/31/2007 |
| Fixed | Yes [5/31/2007] |
| Submitted by | Vissariwn Giwrspyros |
| Keywords |
New events in vdDocument object ,was added in 6007
OnPolarTrackToolTip (gPoint referencePoint, gPoint currentPoint, ref string tooltipText, ref bool cancel)
Fires before the PolarTrack Tooltip display.
/// <summary>
/// Represents the method that will handle the <see cref="vdDocument.OnPolarTrackToolTip"/> event.
/// </summary>
/// <param name="sender">A vdDocument object.</param>
/// <param name="referencePoint">The reference point of current action in User Coordinate System.</param>
/// <param name="currentPoint">The mouse position of current action in User Coordinate System.</param>
/// <param name="tooltipText">A string reference to the Tooltip text.</param>
/// <param name="cancel">Set this as true in order to cancel the default action.</param>
OnPolarTrackAngleValidate(gPoint referencePoint, gPoint currentPoint, double DefaultEquality, ref double NewTrackingAngle, ref bool isValid, ref bool cancel)
Fires when the PolarTrack angle need validation and the PolarTrack is set to true.
/// <summary>
/// Represents the method that will handle the <see cref="vdDocument.OnPolarTrackAngleValidate"/> event.
/// </summary>
/// <param name="sender">A vdDocument object.</param>
/// <param name="referencePoint">The reference point of current action in User Coordinate System.</param>
/// <param name="currentPoint">The mouse position of current action in User Coordinate System.</param>
/// <param name="DefaultEquality">The default angle equality used to lock the action position in specific NewTrackingAngle direction.</param>
/// <param name="NewTrackingAngle">The desired tracking angle in radius.</param>
/// <param name="isValid">A reference value representing if the the currentPoint is valid to display the NewTrackingAngle.</param>
/// <param name="cancel">Set this as true in order to cancel the default action.</param>
Example:
private void Form1_Load(object sender, EventArgs e)
{
vdFramedControl.BaseControl.ActiveDocument.OnPolarTrackAngleValidate += new vdDocument.PolarTrackAngleValidateEventHandler(ActiveDocument_OnPolarTrackAngleValidate);
vdFramedControl.BaseControl.ActiveDocument.OnPolarTrackToolTip += new vdDocument.PolarTrackToolTipEventHandler(ActiveDocument_OnPolarTrackToolTip);
vdFramedControl.BaseControl.ActiveDocument.PolarTrack = true;
}
void ActiveDocument_OnPolarTrackToolTip(object sender, gPoint referencePoint, gPoint currentPoint, ref string tooltipText, ref bool cancel)
{
double angle = referencePoint.GetAngle(currentPoint);
double dist = referencePoint.Distance2D(currentPoint);
if (VectorDraw.Geometry.Globals.AreEqualAngle(angle, 0.0d, VectorDraw.Geometry.Globals.VD_ZERO6)) cancel = true;//do not display tooltip for angle 0.0
tooltipText = angle.ToString() + " / " + dist.ToString();//change the default tooltip text
}
void ActiveDocument_OnPolarTrackAngleValidate(object sender, gPoint referencePoint, gPoint currentPoint, double DefaultEquality, ref double NewTrackingAngle, ref bool isValid, ref bool cancel)
{
double angle = referencePoint.GetAngle(currentPoint);
double dist = referencePoint.Distance2D(currentPoint);
cancel = true;//accept only my angles (0,90,180,270,360) and ingnore default Vdraw actions.
if (VectorDraw.Geometry.Globals.AreEqualAngle(angle, 0.0d, DefaultEquality))
{
NewTrackingAngle = 0.0d;
isValid = true;
}
else if (VectorDraw.Geometry.Globals.AreEqualAngle(angle, VectorDraw.Geometry.Globals.HALF_PI, DefaultEquality))
{
NewTrackingAngle = VectorDraw.Geometry.Globals.HALF_PI;
isValid = true;
}
else if (VectorDraw.Geometry.Globals.AreEqualAngle(angle, VectorDraw.Geometry.Globals.PI, DefaultEquality))
{
NewTrackingAngle = VectorDraw.Geometry.Globals.PI;
isValid = true;
}
else if (VectorDraw.Geometry.Globals.AreEqualAngle(angle, VectorDraw.Geometry.Globals.VD_270PI, DefaultEquality))
{
NewTrackingAngle = VectorDraw.Geometry.Globals.VD_270PI;
isValid = true;
}
else if (VectorDraw.Geometry.Globals.AreEqualAngle(angle, VectorDraw.Geometry.Globals.VD_TWOPI, DefaultEquality))
{
NewTrackingAngle = VectorDraw.Geometry.Globals.VD_TWOPI;
isValid = true;
}
}