Exemplo n.º 1
0
        private AnnAutomationObject CreateIntersectionPoint()
        {
            AnnAutomationObject automationObj = new AnnAutomationObject();

            AnnIntersectionPointObject annIntersectionPointObject = new AnnIntersectionPointObject();

            automationObj.Id               = annIntersectionPointObject.Id;
            automationObj.Name             = "Intersection Point";
            automationObj.DrawDesignerType = typeof(AnnTwoLinesDrawer);
            automationObj.EditDesignerType = typeof(AnnTwoLinesEditer);
            automationObj.RunDesignerType  = typeof(AnnRunDesigner);
            automationObj.ObjectTemplate   = annIntersectionPointObject;

            IAnnObjectRenderer renderer = new AnnIntersectionObjectRenderer();

            renderer.LocationsThumbStyle     = CreateLocationThumbStyle();
            renderer.RotateCenterThumbStyle  = CreateRotateCenterThumbStyle();
            renderer.RotateGripperThumbStyle = CreateRotateGripperThumbStyle();

            automationObj.Renderer = renderer;

            CreateToolBarItem(automationObj, "IntersectionPoint");

            return(automationObj);
        }
Exemplo n.º 2
0
        public override bool OnPointerMove(AnnContainer sender, AnnPointerEventArgs e)
        {
            bool handled = false;

            if (TargetObject != null && HasStarted)
            {
                LeadPointD pt = ClipPoint(e.Location, ClipRectangle);

                if (!LeadPoint.Equals(pt, _end))
                {
                    _end = pt;
                    LeadPointCollection points = TargetObject.Points;

                    if (points.Count > 1)
                    {
                        if (_clickCount % 2 != 0)
                        {
                            points[points.Count - 1] = pt; // end point
                        }
                    }

                    AnnIntersectionPointObject intersectionPointObject = TargetObject as AnnIntersectionPointObject;
                    if (intersectionPointObject != null)
                    {
                        intersectionPointObject.IntersectionInsideContainer = ClipRectangle.ContainsPoint(intersectionPointObject.IntersectionPoint);
                    }

                    Working();
                }

                handled = true;
            }

            return(handled);
        }
Exemplo n.º 3
0
        public override void Render(AnnContainerMapper mapper, AnnObject annObject)
        {
            if (mapper == null)
            {
                ExceptionHelper.ArgumentNullException("mapper");
            }
            if (annObject == null)
            {
                ExceptionHelper.ArgumentNullException("annObject");
            }

            IAnnDrawEngine engine = RenderingEngine as IAnnDrawEngine;

            if (engine != null)
            {
                base.Render(mapper, annObject);

                AnnIntersectionPointObject annIntersectionPointObject = annObject as AnnIntersectionPointObject;
                if (annIntersectionPointObject != null)
                {
                    int count = annIntersectionPointObject.Points.Count;
                    if (count < 2)
                    {
                        return;
                    }

                    LeadPointD[] leadPoints = mapper.PointsFromContainerCoordinates(annIntersectionPointObject.Points.ToArray(), annIntersectionPointObject.FixedStateOperations);

                    if (annIntersectionPointObject.SupportsStroke && annIntersectionPointObject.Stroke != null)
                    {
                        AnnStroke stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Blue"), annIntersectionPointObject.Stroke.StrokeThickness);
                        stroke.StrokeDashArray = new double[] { 3, 1, 1, 1, 1, 1 }; // DashDotDot

                        IAnnDrawPen pen = engine.ToPen(mapper.StrokeFromContainerCoordinates(stroke, annIntersectionPointObject.FixedStateOperations), annIntersectionPointObject.Opacity);
                        try
                        {
                            if (leadPoints.Length > 2)
                            {
                                LeadPointD intersectionPoint = annIntersectionPointObject.IntersectionPoint;
                                intersectionPoint = mapper.PointFromContainerCoordinates(intersectionPoint, annIntersectionPointObject.FixedStateOperations);

                                double radius = mapper.LengthFromContainerCoordinates(annIntersectionPointObject.IntersectionPointRadius, annIntersectionPointObject.FixedStateOperations);
                                DrawPoint(annIntersectionPointObject, engine, intersectionPoint, radius);

                                if (leadPoints.Length < 5 && annIntersectionPointObject.IntersectionInsideContainer)
                                {
                                    engine.DrawLine(pen, leadPoints[3], intersectionPoint);
                                }
                            }
                        }
                        finally
                        {
                            engine.Destroy(pen);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        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);

                AnnIntersectionPointObject annIntersectionPointObject = annObject as AnnIntersectionPointObject;
                if (annIntersectionPointObject != null)
                {
                    int count = annIntersectionPointObject.Points.Count;
                    if (count < 2)
                    {
                        return;
                    }

                    LeadPointD[] leadPoints = mapper.PointsFromContainerCoordinates(annIntersectionPointObject.Points.ToArray(), annIntersectionPointObject.FixedStateOperations);
                    PointF[]     points     = AnnWinFormsRenderingEngine.ToPoints(leadPoints);

                    if (annIntersectionPointObject.SupportsStroke && annIntersectionPointObject.Stroke != null)
                    {
                        using (Pen pen = AnnWinFormsRenderingEngine.ToPen(mapper.StrokeFromContainerCoordinates(annIntersectionPointObject.Stroke, annIntersectionPointObject.FixedStateOperations), annIntersectionPointObject.Opacity))
                        {
                            if (points.Length > 2)
                            {
                                LeadPointD LeadIntersectionPoint = annIntersectionPointObject.IntersectionPoint;
                                LeadIntersectionPoint = mapper.PointFromContainerCoordinates(LeadIntersectionPoint, annIntersectionPointObject.FixedStateOperations);
                                PointF intersectionPoint = new PointF((float)LeadIntersectionPoint.X, (float)LeadIntersectionPoint.Y);

                                double radius = mapper.LengthFromContainerCoordinates(annIntersectionPointObject.IntersectionPointRadius, annIntersectionPointObject.FixedStateOperations);
                                DrawPoint(annIntersectionPointObject, engine.Context, intersectionPoint, radius);

                                if (points.Length < 5 && annIntersectionPointObject.IntersectionInsideContainer)
                                {
                                    pen.Brush     = Brushes.Blue;
                                    pen.DashStyle = DashStyle.DashDotDot;
                                    engine.Context.DrawLine(pen, points[3], intersectionPoint);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void DrawPoint(AnnIntersectionPointObject 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("green"), 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)));
            }
        }
Exemplo n.º 6
0
        protected override void MoveThumb(int thumbIndex, LeadPointD offset)
        {
            AnnObject  targetObject = TargetObject;
            LeadPointD point        = targetObject.Points[thumbIndex];

            targetObject.Points[thumbIndex] = ClipPoint(AnnTransformer.TranslatePoint(point, offset.X, offset.Y), ClipRectangle);

            AnnIntersectionPointObject intersectionPointObject = targetObject as AnnIntersectionPointObject;

            if (intersectionPointObject != null)
            {
                intersectionPointObject.IntersectionInsideContainer = ClipRectangle.ContainsPoint(intersectionPointObject.IntersectionPoint);
            }

            base.MoveThumb(thumbIndex, offset);
        }
Exemplo n.º 7
0
        private void DrawPoint(AnnIntersectionPointObject 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("green"), 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);
            }
        }