public bool NextDraw(Point pt, IDrawingContext dc, bool isFinal)
        {
            if (iPoint == pointCount)
            {
                return(true);
            }

            Points[iPoint] = pt;

            var p0 = PointSnapper.SnapPoint(Points[0]);
            var p1 = PointSnapper.SnapPoint(Points[1]);

            dc.DrawLine(Pen, p0, p1);

            if (iPoint == 2)
            {
                var p2    = PointSnapper.SnapPoint(Points[2]);
                var diffX = p1.X - p2.X;
                var diffY = p1.Y - p2.Y;

                Point pt00 = new Point(p0.X - diffX, p0.Y - diffY);
                dc.DrawLine(Pen, pt00, p2);
            }
            if (isFinal)
            {
                iPoint++;
            }
            return(iPoint == PointCount);
        }
Beispiel #2
0
        public bool NextDraw(Point pt, IDrawingContext dc, bool isFinal)
        {
            Points[1] = pt;

            var p0 = PointSnapper.SnapPoint(Points[0]);
            var p1 = PointSnapper.SnapPoint(Points[1]);

            dc.DrawLine(Pen, p0, p1);

            if (isFinal)
            {
                CreateRegion();
            }
            return(isFinal);
        }
Beispiel #3
0
        private void ChartControl_PointerMoved(object sender, PointerRoutedEventArgs e)
        {
            e.Handled = true;

            if (!IsShowCursor() || _mainCollection == null)
            {
                return;
            }

            var cursorPos = e.GetCurrentPoint(this).Position;

            _gestureRecognizer.ProcessMoveEvents(e.GetIntermediatePoints(this));
            //Debug.WriteLine("Move " + cursorPos.ToString());
            if (!IsPointInChart(cursorPos))
            {
                DropPointerAction();
                return;
            }

            midPoint = cursorPos;

            if (_drawingCustomGraphics != null)
            {
                if (_isCustomGraphicsDrawingStarted)
                {
                    CreateCurrentCustomGraphicVisual(cursorPos, false);
                }
            }
            else if (IsUpdatingGraphicLocation())
            {
                UpdateGraphicLocation(cursorPos);
            }
            else if (pointerAction == PointerAction.None)
            {
                SetCursorPosition(cursorPos);

                RestartTooltipTimer();
            }
            else if (pointerAction == PointerAction.ZoomIn || pointerAction == PointerAction.Select)
            {
                CreateSelectionRectVisual(PointSnapper.RoundPoint(startPoint.Value), PointSnapper.RoundPoint(cursorPos));
            }
            else if (pointerAction == PointerAction.Measure)
            {
                CreateRulerVisual(PointSnapper.SnapPoint(startPoint.Value), PointSnapper.SnapPoint(cursorPos), GetChange(startPoint.Value.Y, cursorPos.Y));
            }
        }
Beispiel #4
0
        private void CreateRegion()
        {
            regionGeo = new StreamGeometry();

            var p0 = PointSnapper.SnapPoint(Points[0]);
            var p1 = PointSnapper.SnapPoint(Points[1]);

            using (var gdc = regionGeo.Open())
            {
                var ptTemp = new Point(p0.X, p0.Y - 3);

                gdc.BeginFigure(ptTemp, true, true);
                ptTemp = new Point(p1.X, p1.Y - 3);
                gdc.LineTo(ptTemp, false, false);
                ptTemp = new Point(p1.X, p1.Y + 3);
                gdc.LineTo(ptTemp, false, false);
                ptTemp = new Point(p0.X, p0.Y + 3);
                gdc.LineTo(ptTemp, false, false);
            }
        }
Beispiel #5
0
        public void Draw(IDrawingContext dc)
        {
            var p0 = PointSnapper.SnapPoint(Points[0]);
            var p1 = PointSnapper.SnapPoint(Points[1]);

            dc.DrawLine(Pen, p0, p1);

            if (IsSelected)
            {
                selectionGeo1 = new RectangleGeometry(new Rect(PointSnapper.RoundValue(p0.X - 3), PointSnapper.RoundValue(p0.Y - 3),
                                                               6, 6));
                selectionGeo2 = new RectangleGeometry(new Rect(PointSnapper.RoundValue(p1.X - 3), PointSnapper.RoundValue(p1.Y - 3),
                                                               6, 6));


                dc.DrawGeometry(Pen.Brush, null, selectionGeo1);
                dc.DrawGeometry(Pen.Brush, null, selectionGeo2);
            }

            CreateRegion();
        }
        public void Draw(IDrawingContext dc)
        {
            if (iPoint != pointCount)
            {
                return;
            }

            var pts = new Point[pointCount];

            for (int i = 0; i < pointCount; i++)
            {
                pts[i] = PointSnapper.SnapPoint(Points[i]);
            }

            dc.DrawLine(Pen, pts[0], pts[1]);

            var diffX = pts[1].X - pts[2].X;
            var diffY = pts[1].Y - pts[2].Y;

            Point pt00 = new Point(pts[0].X - diffX, pts[0].Y - diffY);

            dc.DrawLine(Pen, pt00, pts[2]);

            if (IsSelected)
            {
                selectionGeoList = new List <RectangleGeometry>();

                for (int i = 0; i < PointCount; i++)
                {
                    var selectionGeo = new RectangleGeometry(new Rect(PointSnapper.RoundValue(pts[i].X - 3), PointSnapper.RoundValue(pts[i].Y - 3),
                                                                      6, 6));

                    dc.DrawGeometry(Pen.Brush, null, selectionGeo);

                    selectionGeoList.Add(selectionGeo);
                }
            }

            CreateRegion(pts);
        }