public override void AddShape(WpfPoint point, WpfStreamGeometryContext sgc)
        {
            var x1 = point.X - Size / 2f;
            var x2 = point.X - Size / 4f;
            var x3 = point.X + Size / 4f;
            var x4 = point.X + Size / 2f;

            var y1 = point.Y - Size / 2f;
            var y2 = point.Y - Size / 4f;
            var y3 = point.Y + Size / 4f;
            var y4 = point.Y + Size / 2f;

            sgc.BeginFigure(new WpfPoint(x2, y1), true, true);
            sgc.PolyLineTo(new List <WpfPoint>(new[]
            {
                new WpfPoint(x3, y1),
                new WpfPoint(x3, y2),
                new WpfPoint(x4, y2),
                new WpfPoint(x4, y3),
                new WpfPoint(x3, y3),
                new WpfPoint(x3, y4),
                new WpfPoint(x2, y4),
                new WpfPoint(x2, y3),
                new WpfPoint(x1, y3),
                new WpfPoint(x1, y2),
                new WpfPoint(x2, y2),
                new WpfPoint(x2, y1)
            }), true, true);
        }
        public override void AddShape(WpfPoint point, WpfStreamGeometryContext sgc)
        {
            var start = new WpfPoint(point.X, point.Y - Size * 0.5);

            sgc.BeginFigure(start, true, true);
            sgc.ArcTo(start, new Size(Size, Size), 360, true, WpfSweepDirection.Clockwise, true, true);
        }
Exemplo n.º 3
0
        static void AddArrow(WStreamGeometryContext context, MPoint start, MPoint end, double thickness)
        {
            if (thickness > 1)
            {
                MPoint dir = end - start;
                MPoint h   = dir;
                double dl  = dir.Length;
                if (dl < 0.001)
                {
                    return;
                }
                dir /= dl;

                var    s  = new MPoint(-dir.Y, dir.X);
                double w  = 0.5 * thickness;
                MPoint s0 = w * s;

                s *= h.Length * HalfArrowAngleTan;
                s += s0;

                double rad = w / HalfArrowAngleCos;

                context.BeginFigure(Common.WpfPoint(start + s), true, true);
                context.LineTo(Common.WpfPoint(start - s), true, false);
                context.LineTo(Common.WpfPoint(end - s0), true, false);
                context.ArcTo(Common.WpfPoint(end + s0), new WSize(rad, rad),
                              Math.PI - ArrowAngle, false, WSweepDirection.Clockwise, true, false);
            }
            else
            {
                MPoint dir = end - start;
                double dl  = dir.Length;
                //take into account the widths
                double delta = Math.Min(dl / 2, thickness + thickness / 2);
                dir *= (dl - delta) / dl;
                end  = start + dir;
                dir  = dir.Rotate(Math.PI / 2);
                MPoint s = dir * HalfArrowAngleTan;

                context.BeginFigure(Common.WpfPoint(start + s), true, true);
                context.LineTo(Common.WpfPoint(end), true, true);
                context.LineTo(Common.WpfPoint(start - s), true, true);
            }
        }
Exemplo n.º 4
0
        private void AddShape(WpfStreamGeometryContext sgc, ILinearRing linearRing, bool filled)
        {
            var coords = linearRing.Coordinates;

            WpfPoint[] wpfPoints;
            var        startPoint = TransformSequence(coords, out wpfPoints);

            sgc.BeginFigure(startPoint, filled, true);
            sgc.PolyLineTo(wpfPoints, true, true);
        }
Exemplo n.º 5
0
        public void StreamGeometryTriangleExample(List <System.Windows.Point> arrPoints)
        {
            // Create a path to draw a geometry with.
            System.Windows.Shapes.Path myPath = new System.Windows.Shapes.Path();
            myPath.Stroke          = System.Windows.Media.Brushes.Black;
            myPath.StrokeThickness = 1;
            System.Windows.Media.Color cl = new System.Windows.Media.Color();
            byte[] arr = new byte[4];
            rand.NextBytes(arr);
            //cl.A =
            System.Windows.Media.Brush br = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(arr[0], arr[1], arr[2], arr[3]));
            #region для заполнение разкоментировать
            //  myPath.Fill = br;
            #endregion

            // Create a StreamGeometry to use to specify myPath.
            System.Windows.Media.StreamGeometry geometry = new System.Windows.Media.StreamGeometry();
            //   geometry.FillRule = System.Windows.Media.FillRule.EvenOdd;

            // Open a StreamGeometryContext that can be used to describe this StreamGeometry
            // object's contents.

            using (System.Windows.Media.StreamGeometryContext ctx = geometry.Open())
            {
                // Begin the triangle at the point specified. Notice that the shape is set to
                // be closed so only two lines need to be specified below to make the triangle.
                //ctx.BeginFigure(arrPoints[0], true /* is filled */, true /* is closed */);
                ctx.BeginFigure(arrPoints[0], true /* is filled */, false /* is closed */);
                for (int i = 1; i < arrPoints.Count; i++)
                {
                    ctx.LineTo(arrPoints[i], true /* is stroked */, false /* is smooth join */);
                }
                // Draw a line to the next specified point.
                //   ctx.LineTo(new System.Windows.Point(100, 100), true /* is stroked */, false /* is smooth join */);

                // Draw another line to the next specified point.
                //  ctx.LineTo(new System.Windows.Point(100, 50), true /* is stroked */, false /* is smooth join */);
            }

            // Freeze the geometry (make it unmodifiable)
            // for additional performance benefits.
            geometry.Freeze();

            // Specify the shape (triangle) of the Path using the StreamGeometry.
            myPath.Data = geometry;

            // Add path shape to the UI.
            StackPanel mainPanel = new StackPanel();
            Canvas     ss        = cv;
            ss.Children.Clear();
            ss.Children.Add(myPath);
        }
        public override void AddShape(WpfPoint point, WpfStreamGeometryContext sgc)
        {
            var start   = new WpfPoint(point.X, (point.Y - Size / 2));
            var linesTo = new List <WpfPoint>(
                new[]
            {
                new WpfPoint((point.X + Size / 2), (point.Y + Size / 2)),
                new WpfPoint((point.X - Size / 2), (point.Y + Size / 2)),
                new WpfPoint((point.X), (point.Y - Size / 2))
            });

            sgc.BeginFigure(start, true, true);
            sgc.PolyLineTo(linesTo, true, true);
        }
        public override void AddShape(WpfPoint point, WpfStreamGeometryContext sgc)
        {
            var start      = new WpfPoint(point.X - 0.5 * Size, point.Y - 0.5 * Size);
            var polylineTo = new List <WpfPoint>(new[]
            {
                new WpfPoint(point.X + 0.5 * Size, point.Y - 0.5 * Size),
                new WpfPoint(point.X + 0.5 * Size, point.Y + 0.5 * Size),
                new WpfPoint(point.X - 0.5 * Size, point.Y + 0.5 * Size),
                start
            });

            sgc.BeginFigure(start, true, true);
            sgc.PolyLineTo(polylineTo, true, true);
        }
 public override void AddShape(WpfPoint point, WpfStreamGeometryContext sgc)
 {
     sgc.BeginFigure(new WpfPoint((point.X), (point.Y - Size * 1 / 8)), true, true);
     sgc.PolyLineTo(new List <WpfPoint>(new[]
     {
         new WpfPoint((point.X + Size * 2 / 8), (point.Y - Size / 2)),
         new WpfPoint((point.X + Size / 2), (point.Y - Size / 2)),
         new WpfPoint((point.X + Size * 1 / 8), (point.Y)),
         new WpfPoint((point.X + Size / 2), (point.Y + Size / 2)),
         new WpfPoint((point.X + Size * 2 / 8), (point.Y + Size / 2)),
         new WpfPoint((point.X), (point.Y + Size * 1 / 8)),
         new WpfPoint((point.X - Size * 2 / 8), (point.Y + Size / 2)),
         new WpfPoint((point.X - Size / 2), (point.Y + Size / 2)),
         new WpfPoint((point.X - Size * 1 / 8), (point.Y)),
         new WpfPoint((point.X - Size / 2), (point.Y - Size / 2)),
         new WpfPoint((point.X - Size * 2 / 8), (point.Y - Size / 2))
     }), true, true);
 }
Exemplo n.º 9
0
        public System.Windows.Media.Geometry GetCaptureShape()
        {
            System.Windows.Media.StreamGeometry        geo = new System.Windows.Media.StreamGeometry();
            System.Windows.Media.StreamGeometryContext ctx = geo.Open();
            System.Collections.ObjectModel.ReadOnlyCollection <System.Drawing.Point> points = _shape.Points;

            List <System.Windows.Point> mPoints = new List <System.Windows.Point>();

            foreach (Point p in points)
            {
                mPoints.Add(new System.Windows.Point(p.X, p.Y));
            }

            if (mPoints.Count > 0)
            {
                //mPoints.Add(mPoints[0]);
                ctx.BeginFigure(mPoints[0], false, false);
                ctx.PolyLineTo(mPoints, true, false);
            }
            ctx.Close();
            return(geo);
        }
        private void AddShape(WpfStreamGeometryContext sgc, ILinearRing linearRing, bool filled)
        {
            var coords = linearRing.Coordinates;

            WpfPoint[] wpfPoints;
            var startPoint = TransformSequence(coords, out wpfPoints);

            sgc.BeginFigure(startPoint, filled, true);
            sgc.PolyLineTo(wpfPoints, true, true);
        }
Exemplo n.º 11
0
        internal static void FillContextForICurve(WStreamGeometryContext context, ICurve iCurve)
        {
            context.BeginFigure(Common.WpfPoint(iCurve.Start), false, false);

            var c = iCurve as Curve;

            if (c != null)
            {
                FillContexForCurve(context, c);
            }
            else
            {
                var cubicBezierSeg = iCurve as CubicBezierSegment;
                if (cubicBezierSeg != null)
                {
                    context.BezierTo(Common.WpfPoint(cubicBezierSeg.B(1)), Common.WpfPoint(cubicBezierSeg.B(2)),
                                     Common.WpfPoint(cubicBezierSeg.B(3)), true, false);
                }
                else
                {
                    var ls = iCurve as MLineSegment;
                    if (ls != null)
                    {
                        context.LineTo(Common.WpfPoint(ls.End), true, false);
                    }
                    else
                    {
                        var rr = iCurve as RoundedRect;
                        if (rr != null)
                        {
                            FillContexForCurve(context, rr.Curve);
                        }
                        else
                        {
                            var poly = iCurve as MPolyline;
                            if (poly != null)
                            {
                                FillContexForPolyline(context, poly);
                            }
                            else
                            {
                                var ellipse = iCurve as MEllipse;
                                if (ellipse != null)
                                {
                                    double     sweepAngle = EllipseSweepAngle(ellipse);
                                    bool       largeArc   = Math.Abs(sweepAngle) >= Math.PI;
                                    MRectangle box        = ellipse.FullBox();
                                    context.ArcTo(Common.WpfPoint(ellipse.End),
                                                  new WSize(box.Width / 2, box.Height / 2),
                                                  sweepAngle,
                                                  largeArc,
                                                  sweepAngle < 0
                                                      ? WSweepDirection.Counterclockwise
                                                      : WSweepDirection.Clockwise,
                                                  true, true);
                                }
                                else
                                {
                                    throw new NotImplementedException();
                                }
                            }
                        }
                    }
                }
            }
        }
 public override void AddShape(WpfPoint point, WpfStreamGeometryContext sgc)
 {
     sgc.BeginFigure(new WpfPoint((point.X), (point.Y - Size * 1 / 8)), true, true);
     sgc.PolyLineTo(new List<WpfPoint>(new[]
         {
             new WpfPoint((point.X + Size*2/8), (point.Y - Size/2)),
             new WpfPoint((point.X + Size/2), (point.Y - Size/2)),
             new WpfPoint((point.X + Size*1/8), (point.Y)),
             new WpfPoint((point.X + Size/2), (point.Y + Size/2)),
             new WpfPoint((point.X + Size*2/8), (point.Y + Size/2)),
             new WpfPoint((point.X), (point.Y + Size*1/8)),
             new WpfPoint((point.X - Size*2/8), (point.Y + Size/2)),
             new WpfPoint((point.X - Size/2), (point.Y + Size/2)),
             new WpfPoint((point.X - Size*1/8), (point.Y)),
             new WpfPoint((point.X - Size/2), (point.Y - Size/2)),
             new WpfPoint((point.X - Size*2/8), (point.Y - Size/2))
         }), true, true);
 }
        public override void AddShape(WpfPoint point, WpfStreamGeometryContext sgc)
        {
            var x1 = point.X - Size / 2f;
            var x2 = point.X - Size / 4f;
            var x3 = point.X + Size / 4f;
            var x4 = point.X + Size / 2f;

            var y1 = point.Y - Size / 2f;
            var y2 = point.Y - Size / 4f;
            var y3 = point.Y + Size / 4f;
            var y4 = point.Y + Size / 2f;

            sgc.BeginFigure(new WpfPoint(x2, y1), true, true);
            sgc.PolyLineTo(new List<WpfPoint>(new[]
                {
                    new WpfPoint(x3, y1),
                    new WpfPoint(x3, y2),
                    new WpfPoint(x4, y2),
                    new WpfPoint(x4, y3),
                    new WpfPoint(x3, y3),
                    new WpfPoint(x3, y4),
                    new WpfPoint(x2, y4),
                    new WpfPoint(x2, y3),
                    new WpfPoint(x1, y3),
                    new WpfPoint(x1, y2),
                    new WpfPoint(x2, y2),
                    new WpfPoint(x2, y1)
                }), true, true);
        }
 public override void AddShape(WpfPoint point, WpfStreamGeometryContext sgc)
 {
     var start = new WpfPoint(point.X, point.Y - Size * 0.5);
     sgc.BeginFigure(start, true, true);
     sgc.ArcTo(start, new Size(Size, Size), 360, true, WpfSweepDirection.Clockwise, true, true);
 }
 public override void AddShape(WpfPoint point, WpfStreamGeometryContext sgc)
 {
     var start = new WpfPoint(point.X, (point.Y - Size / 2));
     var linesTo = new List<WpfPoint>(
         new[]
             {
                 new WpfPoint((point.X + Size/2), (point.Y + Size/2)),
                 new WpfPoint((point.X - Size/2), (point.Y + Size/2)),
                 new WpfPoint((point.X), (point.Y - Size/2))
             });
     sgc.BeginFigure(start, true, true);
     sgc.PolyLineTo(linesTo, true, true);
 }
 public override void AddShape(WpfPoint point, WpfStreamGeometryContext sgc)
 {
     var start = new WpfPoint(point.X - 0.5 * Size, point.Y - 0.5 * Size);
     var polylineTo = new List<WpfPoint>(new[]
                          {
                              new WpfPoint(point.X + 0.5*Size, point.Y - 0.5*Size),
                              new WpfPoint(point.X + 0.5*Size, point.Y + 0.5*Size),
                              new WpfPoint(point.X - 0.5*Size, point.Y + 0.5*Size),
                              start
                          });
     sgc.BeginFigure(start, true, true);
     sgc.PolyLineTo(polylineTo, true, true);
 }