Example #1
0
        public XThumb CreateThumb(double x, double y, XLine line, Action <XLine, XThumb, double, double> drag)
        {
            var thumb = CreateThumb(x, y);

            SetLineDragDeltaHandler(line, thumb, drag);
            return(thumb);
        }
Example #2
0
        /// <inheritdoc/>
        public override void LeftDown(double x, double y)
        {
            base.LeftDown(x, y);

            double sx = _editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(x, _editor.Project.Options.SnapX) : x;
            double sy = _editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(y, _editor.Project.Options.SnapY) : y;

            switch (_currentState)
            {
            case ToolState.None:
            {
                _shape = XLine.Create(
                    sx, sy,
                    _editor.Project.CurrentStyleLibrary.Selected,
                    _editor.Project.Options.PointShape,
                    _editor.Project.Options.DefaultIsStroked);
                if (_editor.Project.Options.TryToConnect)
                {
                    var result = TryToConnectStart(_shape as XLine, sx, sy);
                    if (!result)
                    {
                        _editor.TryToSplitLine(x, y, _shape.Start);
                    }
                }
                _editor.Project.CurrentContainer.WorkingLayer.Shapes = _editor.Project.CurrentContainer.WorkingLayer.Shapes.Add(_shape);
                _editor.Project.CurrentContainer.WorkingLayer.Invalidate();
                ToStateOne();
                Move(_shape);
                _editor.Project.CurrentContainer.HelperLayer.Invalidate();
                _currentState           = ToolState.One;
                _editor.CancelAvailable = true;
            }
            break;

            case ToolState.One:
            {
                var line = _shape as XLine;
                if (line != null)
                {
                    line.End.X = sx;
                    line.End.Y = sy;
                    if (_editor.Project.Options.TryToConnect)
                    {
                        var result = TryToConnectEnd(_shape as XLine, sx, sy);
                        if (!result)
                        {
                            _editor.TryToSplitLine(x, y, _shape.End);
                        }
                    }
                    _editor.Project.CurrentContainer.WorkingLayer.Shapes = _editor.Project.CurrentContainer.WorkingLayer.Shapes.Remove(_shape);
                    Remove();
                    Finalize(_shape);
                    _editor.Project.AddShape(_editor.Project.CurrentContainer.CurrentLayer, _shape);
                    _currentState           = ToolState.None;
                    _editor.CancelAvailable = false;
                }
            }
            break;
            }
        }
Example #3
0
        private void DrawLineArrowsInternal(SKCanvas canvas, XLine line, double dx, double dy, out SKPoint pt1, out SKPoint pt2)
        {
            using (SKPaint fillStartArrow = ToSKPaintBrush(line.Style.StartArrowStyle.Fill))
                using (SKPaint strokeStartArrow = ToSKPaintPen(line.Style.StartArrowStyle, _scaleToPage, _sourceDpi, _targetDpi))
                    using (SKPaint fillEndArrow = ToSKPaintBrush(line.Style.EndArrowStyle.Fill))
                        using (SKPaint strokeEndArrow = ToSKPaintPen(line.Style.EndArrowStyle, _scaleToPage, _sourceDpi, _targetDpi))
                        {
                            double _x1 = line.Start.X + dx;
                            double _y1 = line.Start.Y + dy;
                            double _x2 = line.End.X + dx;
                            double _y2 = line.End.Y + dy;

                            line.GetMaxLength(ref _x1, ref _y1, ref _x2, ref _y2);

                            float x1 = _scaleToPage(_x1);
                            float y1 = _scaleToPage(_y1);
                            float x2 = _scaleToPage(_x2);
                            float y2 = _scaleToPage(_y2);

                            var    sas = line.Style.StartArrowStyle;
                            var    eas = line.Style.EndArrowStyle;
                            double a1  = Math.Atan2(y1 - y2, x1 - x2);
                            double a2  = Math.Atan2(y2 - y1, x2 - x1);

                            // Draw start arrow.
                            pt1 = DrawLineArrowInternal(canvas, strokeStartArrow, fillStartArrow, x1, y1, a1, sas);

                            // Draw end arrow.
                            pt2 = DrawLineArrowInternal(canvas, strokeEndArrow, fillEndArrow, x2, y2, a2, eas);
                        }
        }
Example #4
0
        /// <inheritdoc/>
        public override void Draw(object dc, XLine line, double dx, double dy, ImmutableArray <XProperty> db, XRecord r)
        {
            var canvas = dc as SKCanvas;

            using (SKPaint strokeLine = ToSKPaintPen(line.Style, _scaleToPage, _sourceDpi, _targetDpi))
            {
                SKPoint pt1, pt2;

                DrawLineArrowsInternal(canvas, line, dx, dy, out pt1, out pt2);

                if (line.Style.LineStyle.IsCurved)
                {
                    DrawLineCurveInternal(
                        canvas,
                        strokeLine, line.IsStroked,
                        ref pt1, ref pt2,
                        line.Style.LineStyle.Curvature,
                        line.Style.LineStyle.CurveOrientation,
                        line.Start.Alignment,
                        line.End.Alignment);
                }
                else
                {
                    DrawLineInternal(canvas, strokeLine, line.IsStroked, ref pt1, ref pt2);
                }
            }
        }
Example #5
0
        private void DrawLineArrowsInternal(AM.DrawingContext dc, XLine line, double dx, double dy, out A.Point pt1, out A.Point pt2)
        {
            AM.IBrush fillStartArrow   = ToBrush(line.Style.StartArrowStyle.Fill);
            AM.Pen    strokeStartArrow = ToPen(line.Style.StartArrowStyle, _scaleToPage);

            AM.IBrush fillEndArrow   = ToBrush(line.Style.EndArrowStyle.Fill);
            AM.Pen    strokeEndArrow = ToPen(line.Style.EndArrowStyle, _scaleToPage);

            double _x1 = line.Start.X + dx;
            double _y1 = line.Start.Y + dy;
            double _x2 = line.End.X + dx;
            double _y2 = line.End.Y + dy;

            line.GetMaxLength(ref _x1, ref _y1, ref _x2, ref _y2);

            float x1 = _scaleToPage(_x1);
            float y1 = _scaleToPage(_y1);
            float x2 = _scaleToPage(_x2);
            float y2 = _scaleToPage(_y2);

            var    sas = line.Style.StartArrowStyle;
            var    eas = line.Style.EndArrowStyle;
            double a1  = Math.Atan2(y1 - y2, x1 - x2);
            double a2  = Math.Atan2(y2 - y1, x2 - x1);

            // Draw start arrow.
            pt1 = DrawLineArrowInternal(dc, strokeStartArrow, fillStartArrow, x1, y1, a1, sas);

            // Draw end arrow.
            pt2 = DrawLineArrowInternal(dc, strokeEndArrow, fillEndArrow, x2, y2, a2, eas);
        }
Example #6
0
        /// <inheritdoc/>
        public override void Draw(object dc, XLine line, double dx, double dy, ImmutableArray <XProperty> db, XRecord r)
        {
            var _dc = dc as AM.DrawingContext;

            AM.Pen  strokeLine = ToPen(line.Style, _scaleToPage);
            A.Point pt1, pt2;

            DrawLineArrowsInternal(_dc, line, dx, dy, out pt1, out pt2);

            if (line.Style.LineStyle.IsCurved)
            {
                DrawLineCurveInternal(
                    _dc,
                    strokeLine, line.IsStroked,
                    ref pt1, ref pt2,
                    line.Style.LineStyle.Curvature,
                    line.Style.LineStyle.CurveOrientation,
                    line.Start.Alignment,
                    line.End.Alignment);
            }
            else
            {
                DrawLineInternal(_dc, strokeLine, line.IsStroked, ref pt1, ref pt2);
            }
        }
Example #7
0
        /// <summary>
        /// Remove selection.
        /// </summary>
        public void Remove()
        {
            if (_line12 != null)
            {
                _layer.Shapes = _layer.Shapes.Remove(_line12);
                _line12       = null;
            }

            if (_line32 != null)
            {
                _layer.Shapes = _layer.Shapes.Remove(_line32);
                _line32       = null;
            }

            if (_helperPoint1 != null)
            {
                _layer.Shapes = _layer.Shapes.Remove(_helperPoint1);
                _helperPoint1 = null;
            }

            if (_helperPoint2 != null)
            {
                _layer.Shapes = _layer.Shapes.Remove(_helperPoint2);
                _helperPoint2 = null;
            }

            if (_helperPoint3 != null)
            {
                _layer.Shapes = _layer.Shapes.Remove(_helperPoint3);
                _helperPoint3 = null;
            }

            _layer.Invalidate();
        }
Example #8
0
        public void DrawLine(object dc, IStyle style, XLine line)
        {
            double thickness = style.Thickness / Zoom;
            double half      = thickness / 2.0;

            var pen = new Pen(
                new SolidColorBrush(
                    Color.FromArgb(
                        (byte)style.Stroke.A,
                        (byte)style.Stroke.R,
                        (byte)style.Stroke.G,
                        (byte)style.Stroke.B)),
                thickness);

            pen.Freeze();

            var gs = new GuidelineSet(
                new double[] { line.X1 + half, line.X2 + half },
                new double[] { line.Y1 + half, line.Y2 + half });

            (dc as DrawingContext).PushGuidelineSet(gs);

            (dc as DrawingContext).DrawLine(
                pen,
                new Point(line.X1, line.Y1),
                new Point(line.X2, line.Y2));

            (dc as DrawingContext).Pop();
        }
Example #9
0
        /// <inheritdoc/>
        public override void Draw(object dc, XLine line, double dx, double dy, ImmutableArray <XProperty> db, XRecord r)
        {
            var _gfx = dc as Graphics;

            Pen    strokeLine = ToPen(line.Style, _scaleToPage);
            PointF pt1, pt2;

            DrawLineArrowsInternal(line, dx, dy, _gfx, out pt1, out pt2);

            if (line.Style.LineStyle.IsCurved)
            {
                DrawLineCurveInternal(
                    _gfx,
                    strokeLine, line.IsStroked,
                    ref pt1, ref pt2,
                    line.Style.LineStyle.Curvature,
                    line.Style.LineStyle.CurveOrientation,
                    line.Start.Alignment,
                    line.End.Alignment);
            }
            else
            {
                DrawLineInternal(_gfx, strokeLine, line.IsStroked, ref pt1, ref pt2);
            }

            strokeLine.Dispose();
        }
Example #10
0
        /// <summary>
        /// Transfer selection state to <see cref="ToolState.Two"/>.
        /// </summary>
        public void ToStateTwo()
        {
            _line12       = XLine.Create(0, 0, _style, null);
            _helperPoint2 = XPoint.Create(0, 0, _point);

            _layer.Shapes = _layer.Shapes.Add(_line12);
            _layer.Shapes = _layer.Shapes.Add(_helperPoint2);
        }
Example #11
0
        public void MoveDeltaEnd(double dx, double dy, XLine line)
        {
            double oldx = _blockHelper.GetX2(line);
            double oldy = _blockHelper.GetY2(line);

            _blockHelper.SetX2(line, oldx + dx);
            _blockHelper.SetY2(line, oldy + dy);
        }
Example #12
0
        public bool HitTest(XLine line, Point2 p, double treshold)
        {
            var    a        = new Point2(line.X1, line.Y1);
            var    b        = new Point2(line.X2, line.Y2);
            var    nearest  = NearestPointOnLine(a, b, p);
            double distance = Distance(p.X, p.Y, nearest.X, nearest.Y);

            return(distance < treshold);
        }
Example #13
0
        /// <summary>
        /// Checks if line contains point.
        /// </summary>
        /// <param name="line"></param>
        /// <param name="v"></param>
        /// <param name="threshold"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <returns></returns>
        public static bool Contains(XLine line, Vector2 v, double threshold, double dx, double dy)
        {
            var    a        = new Vector2(line.Start.X + dx, line.Start.Y + dy);
            var    b        = new Vector2(line.End.X + dx, line.End.Y + dy);
            var    nearest  = MathHelpers.NearestPointOnLine(a, b, v);
            double distance = MathHelpers.Distance(v.X, v.Y, nearest.X, nearest.Y);

            return(distance < threshold);
        }
Example #14
0
        private void DrawLineArrowsInternal(DrawingContext dc, XLine line, ShapeStyle style, double halfStart, double halfEnd, double thicknessStart, double thicknessEnd, double dx, double dy, out Point pt1, out Point pt2)
        {
            // Start arrow style.
            Tuple <Brush, Pen> startArrowCache = _arrowStyleCache.Get(style.StartArrowStyle);
            Brush fillStartArrow;
            Pen   strokeStartArrow;

            if (startArrowCache != null)
            {
                fillStartArrow   = startArrowCache.Item1;
                strokeStartArrow = startArrowCache.Item2;
            }
            else
            {
                fillStartArrow   = CreateBrush(style.StartArrowStyle.Fill);
                strokeStartArrow = CreatePen(style.StartArrowStyle, thicknessStart);
                _arrowStyleCache.Set(style.StartArrowStyle, Tuple.Create(fillStartArrow, strokeStartArrow));
            }

            // End arrow style.
            Tuple <Brush, Pen> endArrowCache = _arrowStyleCache.Get(style.EndArrowStyle);
            Brush fillEndArrow;
            Pen   strokeEndArrow;

            if (endArrowCache != null)
            {
                fillEndArrow   = endArrowCache.Item1;
                strokeEndArrow = endArrowCache.Item2;
            }
            else
            {
                fillEndArrow   = CreateBrush(style.EndArrowStyle.Fill);
                strokeEndArrow = CreatePen(style.EndArrowStyle, thicknessEnd);
                _arrowStyleCache.Set(style.EndArrowStyle, Tuple.Create(fillEndArrow, strokeEndArrow));
            }

            // Line max length.
            double x1 = line.Start.X + dx;
            double y1 = line.Start.Y + dy;
            double x2 = line.End.X + dx;
            double y2 = line.End.Y + dy;

            line.GetMaxLength(ref x1, ref y1, ref x2, ref y2);

            // Arrow transforms.
            var    sas = style.StartArrowStyle;
            var    eas = style.EndArrowStyle;
            double a1  = Math.Atan2(y1 - y2, x1 - x2) * 180.0 / Math.PI;
            double a2  = Math.Atan2(y2 - y1, x2 - x1) * 180.0 / Math.PI;

            // Draw start arrow.
            pt1 = DrawLineArrowInternal(dc, halfStart, strokeStartArrow, fillStartArrow, x1, y1, a1, sas);

            // Draw end arrow.
            pt2 = DrawLineArrowInternal(dc, halfEnd, strokeEndArrow, fillEndArrow, x2, y2, a2, eas);
        }
Example #15
0
        /// <summary>
        /// Checks if line contains point.
        /// </summary>
        /// <param name="line"></param>
        /// <param name="v"></param>
        /// <param name="threshold"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <returns></returns>
        public static bool Contains(XLine line, Vector2 v, double threshold, double dx, double dy)
        {
            var    a        = new Point2(line.Start.X + dx, line.Start.Y + dy);
            var    b        = new Point2(line.End.X + dx, line.End.Y + dy);
            var    target   = new Point2(v.X, v.Y);
            var    nearest  = target.NearestOnLine(a, b);
            double distance = target.DistanceTo(nearest);

            return(distance < threshold);
        }
Example #16
0
        /// <summary>
        /// Transfer selection state to <see cref="ToolState.Three"/>.
        /// </summary>
        public void ToStateThree()
        {
            _line43       = XLine.Create(0, 0, _style, null);
            _line23       = XLine.Create(0, 0, _style, null);
            _helperPoint3 = XPoint.Create(0, 0, _point);

            _layer.Shapes = _layer.Shapes.Add(_line43);
            _layer.Shapes = _layer.Shapes.Add(_line23);
            _layer.Shapes = _layer.Shapes.Add(_helperPoint3);
        }
Example #17
0
 public void Cancel()
 {
     _state.OverlaySheet.ReleaseCapture();
     _state.OverlaySheet.Remove(TempLine);
     _state.OverlaySheet.Remove(TempStartEllipse);
     _state.OverlaySheet.Remove(TempEndEllipse);
     TempLine         = null;
     TempStartEllipse = null;
     TempEndEllipse   = null;
 }
Example #18
0
        public void ConnectEnd(XPoint point, XLine line)
        {
            Action <XElement, XPoint> update = (element, p) =>
            {
                _blockHelper.SetX2(element as XLine, p.X);
                _blockHelper.SetY2(element as XLine, p.Y);
            };

            point.Connected.Add(new Dependency(line, update));
        }
Example #19
0
        /// <summary>
        /// Try to connect <see cref="XLine.End"/> point at specified location.
        /// </summary>
        /// <param name="line">The line object.</param>
        /// <param name="x">The X coordinate of point.</param>
        /// <param name="y">The Y coordinate of point.</param>
        /// <returns>True if connected.</returns>
        public bool TryToConnectEnd(XLine line, double x, double y)
        {
            var result = ShapeHitTestPoint.HitTest(_editor.Project.CurrentContainer.CurrentLayer.Shapes, new Vector2(x, y), _editor.Project.Options.HitThreshold);

            if (result != null && result is XPoint)
            {
                line.End = result as XPoint;
                return(true);
            }
            return(false);
        }
Example #20
0
        /// <summary>
        /// Creates a new <see cref="BaseShape"/> instance.
        /// </summary>
        /// <param name="pss">The point shape <see cref="ShapeStyle"/>.</param>
        /// <returns>The new instance of the <see cref="BaseShape"/> class.</returns>
        public static BaseShape CrossPointShape(ShapeStyle pss)
        {
            var g = XGroup.Create("PointShape");

            var builder = g.Shapes.ToBuilder();

            builder.Add(XLine.Create(-4, 0, 4, 0, pss, null));
            builder.Add(XLine.Create(0, -4, 0, 4, pss, null));
            g.Shapes = builder.ToImmutable();

            return(g);
        }
Example #21
0
        private void DrawLineCurveInternal(DrawingContext dc, double half, Pen pen, XLine line, ref Point pt1, ref Point pt2, double dx, double dy)
        {
            double p1x = pt1.X;
            double p1y = pt1.Y;
            double p2x = pt2.X;
            double p2y = pt2.Y;

            XLineExtensions.GetCurvedLineBezierControlPoints(
                line.Style.LineStyle.CurveOrientation,
                line.Style.LineStyle.Curvature,
                line.Start.Alignment,
                line.End.Alignment,
                ref p1x, ref p1y,
                ref p2x, ref p2y);

            PathGeometry pg = _curvedLineCache.Get(line);

            if (pg != null)
            {
                var pf = pg.Figures[0];
                pf.StartPoint = new Point(pt1.X + dx, pt1.Y + dy);
                pf.IsFilled   = false;
                var bs = pf.Segments[0] as BezierSegment;
                bs.Point1    = new Point(p1x + dx, p1y + dy);
                bs.Point2    = new Point(p2x + dx, p2y + dy);
                bs.Point3    = new Point(pt2.X + dx, pt2.Y + dy);
                bs.IsStroked = line.IsStroked;
            }
            else
            {
                var pf = new PathFigure()
                {
                    StartPoint = new Point(pt1.X + dx, pt1.Y + dy),
                    IsFilled   = false
                };
                var bs = new BezierSegment(
                    new Point(p1x + dx, p1y + dy),
                    new Point(p2x + dx, p2y + dy),
                    new Point(pt2.X + dx, pt2.Y + dy),
                    line.IsStroked);
                //bs.Freeze();
                pf.Segments.Add(bs);
                //pf.Freeze();
                pg = new PathGeometry();
                pg.Figures.Add(pf);
                //pg.Freeze();

                _curvedLineCache.Set(line, pg);
            }

            DrawPathGeometryInternal(dc, half, null, pen, line.IsStroked, false, pg);
        }
Example #22
0
        /// <summary>
        /// Remove selection.
        /// </summary>
        public void Remove()
        {
            if (_ellipse != null)
            {
                _layer.Shapes = _layer.Shapes.Remove(_ellipse);
                _ellipse      = null;
            }

            if (_startLine != null)
            {
                _layer.Shapes = _layer.Shapes.Remove(_startLine);
                _startLine    = null;
            }

            if (_endLine != null)
            {
                _layer.Shapes = _layer.Shapes.Remove(_endLine);
                _endLine      = null;
            }

            if (_p1HelperPoint != null)
            {
                _layer.Shapes  = _layer.Shapes.Remove(_p1HelperPoint);
                _p1HelperPoint = null;
            }

            if (_p2HelperPoint != null)
            {
                _layer.Shapes  = _layer.Shapes.Remove(_p2HelperPoint);
                _p2HelperPoint = null;
            }

            if (_centerHelperPoint != null)
            {
                _layer.Shapes      = _layer.Shapes.Remove(_centerHelperPoint);
                _centerHelperPoint = null;
            }

            if (_startHelperPoint != null)
            {
                _layer.Shapes     = _layer.Shapes.Remove(_startHelperPoint);
                _startHelperPoint = null;
            }

            if (_endHelperPoint != null)
            {
                _layer.Shapes   = _layer.Shapes.Remove(_endHelperPoint);
                _endHelperPoint = null;
            }

            _layer.Invalidate();
        }
Example #23
0
        /// <inheritdoc/>
        XLine IShapeFactory.Line(XPoint start, XPoint end, bool isStroked)
        {
            var style = _editor.Project.CurrentStyleLibrary.Selected;
            var line  = XLine.Create(
                start,
                end,
                _editor.Project.Options.CloneStyle ? style.Clone() : style,
                _editor.Project.Options.PointShape,
                isStroked);

            _editor.Project.AddShape(_editor.Project.CurrentContainer.CurrentLayer, line);
            return(line);
        }
Example #24
0
        /// <inheritdoc/>
        XLine IShapeFactory.Line(double x1, double y1, double x2, double y2, bool isStroked)
        {
            var style = _editor.Project.CurrentStyleLibrary.Selected;
            var line  = XLine.Create(
                x1, y1,
                x2, y2,
                _editor.Project.Options.CloneStyle ? style.Clone() : style,
                _editor.Project.Options.PointShape,
                isStroked);

            _editor.Project.AddShape(_editor.Project.CurrentContainer.CurrentLayer, line);
            return(line);
        }
Example #25
0
        private ILine ReadLine()
        {
            var line = new XLine()
            {
                Id              = _reader.ReadInt32(),
                Point1          = ReadPoint(),
                Point2          = ReadPoint(),
                Stroke          = ReadColor(),
                StrokeThickness = _reader.ReadDouble()
            };

            _natives.Add(line.Id, line);
            return(line);
        }
Example #26
0
        /// <summary>
        /// Transfer selection state to <see cref="ToolState.Three"/>.
        /// </summary>
        public void ToStateThree()
        {
            if (_ellipse != null)
            {
                _layer.Shapes = _layer.Shapes.Remove(_ellipse);
                _ellipse      = null;
            }

            _endLine        = XLine.Create(0, 0, _style, null);
            _endHelperPoint = XPoint.Create(0, 0, _point);

            _layer.Shapes = _layer.Shapes.Add(_endLine);
            _layer.Shapes = _layer.Shapes.Add(_endHelperPoint);
        }
Example #27
0
 public ItemLine Serialize(XLine line)
 {
     return(new ItemLine()
     {
         Id = line.Id,
         X1 = _blockHelper.GetX1(line),
         Y1 = _blockHelper.GetY1(line),
         X2 = _blockHelper.GetX2(line),
         Y2 = _blockHelper.GetY2(line),
         Stroke = _blockHelper.GetStroke(line),
         StartId = line.Start == null ? -1 : line.Start.Id,
         EndId = line.End == null ? -1 : line.End.Id
     });
 }
Example #28
0
        /// <inheritdoc/>
        public override void Draw(object dc, XLine line, double dx, double dy, ImmutableArray <XProperty> db, XRecord r)
        {
            var _dc = dc as DrawingContext;

            var style = line.Style;

            if (style == null)
            {
                return;
            }

            double zoom                = _state.ZoomX;
            double thicknessLine       = style.Thickness / zoom;
            double halfLine            = thicknessLine / 2.0;
            double thicknessStartArrow = style.StartArrowStyle.Thickness / zoom;
            double halfStartArrow      = thicknessStartArrow / 2.0;
            double thicknessEndArrow   = style.EndArrowStyle.Thickness / zoom;
            double halfEndArrow        = thicknessEndArrow / 2.0;

            // Line style.
            Tuple <Brush, Pen> styleCached = _styleCache.Get(style);
            Brush fillLine;
            Pen   strokeLine;

            if (styleCached != null)
            {
                fillLine   = styleCached.Item1;
                strokeLine = styleCached.Item2;
            }
            else
            {
                fillLine   = CreateBrush(style.Fill);
                strokeLine = CreatePen(style, thicknessLine);
                _styleCache.Set(style, Tuple.Create(fillLine, strokeLine));
            }

            Point pt1, pt2;

            DrawLineArrowsInternal(_dc, line, style, halfStartArrow, halfEndArrow, thicknessStartArrow, thicknessEndArrow, dx, dy, out pt1, out pt2);

            if (line.Style.LineStyle.IsCurved)
            {
                DrawLineCurveInternal(_dc, halfLine, strokeLine, line, ref pt1, ref pt2, dx, dy);
            }
            else
            {
                DrawLineInternal(_dc, halfLine, strokeLine, line.IsStroked, ref pt1, ref pt2);
            }
        }
        public void InitLine()
        {
            XLine.SetLeftTopAlignment();
            XLine.MakeCellIndependent(SchemeView.GridSize);

            XLine.Fill            = Colorer.GetBrushByValue(null);
            XLine.StrokeThickness = WireThickness;
            XLine.Tapped         += (_, _) => Tapped(this);

            XLine.PointerEntered += (_, _) => XLine.StrokeThickness *= 2;
            XLine.PointerExited  += (_, _) => XLine.StrokeThickness /= 2;

            XLine.Stroke = new SolidColorBrush(Colors.Wheat);
            XLine.Fill   = new SolidColorBrush(Colors.Wheat);
        }
Example #30
0
            void Initialize(IXLine parent, IXLine child)
            {
                main = parent;

                if (child != null)
                {
                    Child = child;
                    if (!float.IsNaN(child.A.Val) && !float.IsNaN(child.B.Val))

                    {
                        OutLine1 = new XLine(main.A, Child.A);
                        OutLine2 = new XLine(main.B, Child.B);
                        HasOutLines = true;
                    }
                }
            }
Example #31
0
 private ILine ReadLine()
 {
     var line = new XLine()
     {
         Id = _reader.ReadInt32(),
         Point1 = ReadPoint(),
         Point2 = ReadPoint(),
         Stroke = ReadColor(),
         StrokeThickness = _reader.ReadDouble()
     };
     _natives.Add(line.Id, line);
     return line;
 }
Example #32
0
 public ILine CreateLine()
 {
     var line = new XLine()
     {
         Point1 = new XPoint(0.0, 0.0),
         Point2 = new XPoint(0.0, 0.0),
         Stroke = new XColor(0xFF, 0x00, 0x00, 0x00),
         StrokeThickness = 2.0,
     };
     line.Point1.Connected.Add(line);
     line.Point2.Connected.Add(line);
     return line;
 }