public override void Render(AnnContainerMapper mapper, AnnObject annObject) { if (mapper == null) { ExceptionHelper.ArgumentNullException("mapper"); } if (annObject == null) { ExceptionHelper.ArgumentNullException("annObject"); } AnnWinFormsRenderingEngine engine = RenderingEngine as AnnWinFormsRenderingEngine; if (engine != null && engine.Context != null) { base.Render(mapper, annObject); AnnMidlineObject annMidlineObject = annObject as AnnMidlineObject; if (annMidlineObject != null) { LeadPointD[] leadPoints = annMidlineObject.Points.ToArray(); int linesCount = leadPoints.Length / 2; if (linesCount > 0) { PointF[] linesCenters = new PointF[linesCount]; leadPoints = mapper.PointsFromContainerCoordinates(leadPoints, annMidlineObject.FixedStateOperations); PointF[] points = AnnWinFormsRenderingEngine.ToPoints(leadPoints); if (annMidlineObject.SupportsStroke && annMidlineObject.Stroke != null) { double radius = mapper.LengthFromContainerCoordinates(annMidlineObject.CenterPointRadius, annMidlineObject.FixedStateOperations); using (Pen pen = AnnWinFormsRenderingEngine.ToPen(mapper.StrokeFromContainerCoordinates(annMidlineObject.Stroke, annMidlineObject.FixedStateOperations), annMidlineObject.Opacity)) { for (int i = 0; i < linesCount; ++i) { PointF firstPoint = points[2 * i]; PointF secondPoint = points[2 * i + 1]; PointF center = new PointF((firstPoint.X + secondPoint.X) / 2, (firstPoint.Y + secondPoint.Y) / 2); DrawPoint(annMidlineObject, engine.Context, center, radius); linesCenters[i] = center; } if (linesCount > 1) { int count = linesCount - 1; for (int i = 0; i < count; ++i) { engine.Context.DrawLine(pen, linesCenters[i], linesCenters[i + 1]); // draw midline } } } } } } } }
public override bool OnPointerUp(AnnContainer sender, AnnPointerEventArgs e) { AnnMidlineObject midlineObject = TargetObject as AnnMidlineObject; LeadPointCollection points = midlineObject.Points; if (ClickCount > 1) { EndWorking(); } return(true); }
private void DrawPoint(AnnMidlineObject annObject, Graphics context, PointF point, double radius) { LeadRectD pointBounds = new LeadRectD(point.X - radius, point.Y - radius, radius * 2, radius * 2); LeadPointD topLeft = pointBounds.TopLeft; LeadPointD topRight = pointBounds.TopRight; LeadPointD bottomLeft = pointBounds.BottomLeft; LeadPointD bottomRight = pointBounds.BottomRight; using (Pen pen = AnnWinFormsRenderingEngine.ToPen(AnnStroke.Create(AnnSolidColorBrush.Create("blue"), annObject.Stroke.StrokeThickness), annObject.Opacity)) { context.DrawLine(pen, new PointF((float)topLeft.X, (float)topLeft.Y), new PointF((float)bottomRight.X, (float)bottomRight.Y)); context.DrawLine(pen, new PointF((float)bottomLeft.X, (float)bottomLeft.Y), new PointF((float)topRight.X, (float)topRight.Y)); context.DrawLine(pen, new PointF((float)point.X, (float)(point.Y - pointBounds.Width / 2)), new PointF((float)point.X, (float)(point.Y + pointBounds.Width / 2))); context.DrawLine(pen, new PointF((float)point.X - (float)pointBounds.Width / 2, (float)(point.Y)), new PointF((float)point.X + (float)pointBounds.Width / 2, (float)(point.Y))); } }
private AnnAutomationObject CreateSnapPoint() { AnnAutomationObject automationObj = new AnnAutomationObject(); AnnMidlineObject annMidlineObject = new AnnMidlineObject(); annMidlineObject.SetId(annMidlineObject.Id - 1); automationObj.Id = annMidlineObject.Id; automationObj.Name = "SnapPoint"; automationObj.DrawDesignerType = typeof(AnnSnapPointDrawer); automationObj.EditDesignerType = typeof(AnnSnapPointEditor); automationObj.RunDesignerType = typeof(AnnRunDesigner); automationObj.ObjectTemplate = annMidlineObject; IAnnObjectRenderer renderer = new AnnMidlineObjectRenderer(); renderer.LocationsThumbStyle = CreateLocationThumbStyle(); automationObj.Renderer = renderer; return(automationObj); }
private void DrawPoint(AnnMidlineObject annObject, IAnnDrawEngine engine, LeadPointD point, double radius) { LeadRectD pointBounds = new LeadRectD(point.X - radius, point.Y - radius, radius * 2, radius * 2); LeadPointD topLeft = pointBounds.TopLeft; LeadPointD topRight = pointBounds.TopRight; LeadPointD bottomLeft = pointBounds.BottomLeft; LeadPointD bottomRight = pointBounds.BottomRight; IAnnDrawPen pen = engine.ToPen(AnnStroke.Create(AnnSolidColorBrush.Create("blue"), annObject.Stroke.StrokeThickness), annObject.Opacity); try { engine.DrawLine(pen, topLeft, bottomRight); engine.DrawLine(pen, bottomLeft, topRight); engine.DrawLine(pen, new LeadPointD(point.X, (point.Y - pointBounds.Width / 2)), new LeadPointD(point.X, (point.Y + pointBounds.Width / 2))); engine.DrawLine(pen, new LeadPointD(point.X - pointBounds.Width / 2, point.Y), new LeadPointD(point.X + pointBounds.Width / 2, point.Y)); } finally { engine.Destroy(pen); } }
private AnnAutomationObject CreateMidline() { AnnAutomationObject automationObj = new AnnAutomationObject(); AnnMidlineObject annMidlineObject = new AnnMidlineObject(); automationObj.Id = annMidlineObject.Id; automationObj.Name = "MidLine"; automationObj.DrawDesignerType = typeof(AnnTwoLinesDrawer); automationObj.EditDesignerType = typeof(AnnTwoLinesEditer); automationObj.RunDesignerType = typeof(AnnRunDesigner); automationObj.ObjectTemplate = annMidlineObject; IAnnObjectRenderer renderer = new AnnMidlineObjectRenderer(); renderer.LocationsThumbStyle = CreateLocationThumbStyle(); renderer.RotateCenterThumbStyle = CreateRotateCenterThumbStyle(); renderer.RotateGripperThumbStyle = CreateRotateGripperThumbStyle(); automationObj.Renderer = renderer; return(automationObj); }
public AnnSnapPointEditor(IAnnAutomationControl automationControl, AnnContainer container, AnnMidlineObject annMidlineObject) : base(automationControl, container, annMidlineObject) { }