///<summary>
        /// Creates a shape representing an <see cref="IPoint"/>.
        ///</summary>
        public WpfGeometry CreatePoint(WpfPoint point)
        {
            var pointMarker = new WpfStreamGeometry();

            using (var sgc = pointMarker.Open())
                AddShape(point, sgc);
            return(pointMarker);
        }
Ejemplo n.º 2
0
        internal static WGeometry GetICurveWpfGeometry(ICurve curve)
        {
            var streamGeometry = new WStreamGeometry();

            using (WStreamGeometryContext context = streamGeometry.Open())
            {
                FillStreamGeometryContext(context, curve);
                return(streamGeometry);
            }
        }
Ejemplo n.º 3
0
        WGeometry DefiningSourceArrowHead()
        {
            var streamGeometry = new WStreamGeometry();

            using (WStreamGeometryContext context = streamGeometry.Open())
            {
                AddArrow(context, Edge.GeometryEdge.Curve.Start, Edge.GeometryEdge.EdgeGeometry.SourceArrowhead.TipPosition, PathStrokeThickness);
                return(streamGeometry);
            }
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        internal static WGeometry DefiningTargetArrowHead(EdgeGeometry edgeGeometry, double thickness)
        {
            if (edgeGeometry.TargetArrowhead == null || edgeGeometry.Curve == null)
            {
                return(null);
            }
            var streamGeometry = new WStreamGeometry();

            using (WStreamGeometryContext context = streamGeometry.Open())
            {
                AddArrow(context, edgeGeometry.Curve.End,
                         edgeGeometry.TargetArrowhead.TipPosition, thickness);
                return(streamGeometry);
            }
        }
Ejemplo n.º 6
0
        ///<summary>
        /// Creates a <see cref="WpfGeometry"/> representing a <see cref="IGeometry"/>, according to the specified PointTransformation and PointShapeFactory (if relevant).
        ///</summary>
        public WpfGeometry ToShape(IGeometry geometry)
        {
            if (geometry.IsEmpty)
            {
                return(new WpfStreamGeometry());
            }

            var p = new WpfStreamGeometry();

            using (var sgc = p.Open())
                AddShape(sgc, geometry);

            p.Freeze();
            return(p);
        }
Ejemplo n.º 7
0
        private static System.Windows.Media.StreamGeometry _CreateGeometry(ReadOnlySpan <Point2> points, bool isClosed, bool isFilled, bool isStroked, bool isSmoothJoin = false)
        {
            var g = new System.Windows.Media.StreamGeometry();

            using (var gg = g.Open())
            {
                gg.BeginFigure(points[0].ToDevicePoint(), isFilled, isClosed);

                for (int i = 0; i < points.Length; ++i)
                {
                    gg.LineTo(points[i].ToDevicePoint(), isStroked, isSmoothJoin);
                }

                gg.Close();
            }

            return(g);
        }
Ejemplo n.º 8
0
        WFrameworkElement CreateFrameworkElementForRailArrowhead(Rail rail, Arrowhead arrowhead, MPoint curveAttachmentPoint, byte edgeTransparency)
        {
            var streamGeometry = new WStreamGeometry();

            using (WStreamGeometryContext context = streamGeometry.Open())
            {
                AddArrow(context, curveAttachmentPoint, arrowhead.TipPosition,
                         PathStrokeThickness);
            }

            var path = new WPath
            {
                Data = streamGeometry,
                Tag  = this
            };

            SetPathStrokeToRailPath(rail, path, edgeTransparency);
            return(path);
        }
Ejemplo 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);
        }
        ///<summary>
        /// Creates a <see cref="WpfGeometry"/> representing a <see cref="IGeometry"/>, according to the specified PointTransformation and PointShapeFactory (if relevant).
        ///</summary>
        public WpfGeometry ToShape(IGeometry geometry)
        {
            if (geometry.IsEmpty)
                return new WpfStreamGeometry();

            var p = new WpfStreamGeometry();
            using (var sgc = p.Open())
                AddShape(sgc, geometry);

            p.Freeze();
            return p;
        }
Ejemplo n.º 11
0
        public void Draw(TextView textView, System.Windows.Media.DrawingContext drawingContext) {
            if (markers == null || !textView.VisualLinesValid) {
                return;
            }
            var visualLines = textView.VisualLines;
            if (visualLines.Count == 0) {
                return;
            }
            int viewStart = visualLines.First().FirstDocumentLine.Offset;
            int viewEnd = visualLines.Last().LastDocumentLine.EndOffset;
            foreach (TextMarker marker in markers.FindOverlappingSegments(viewStart, viewEnd - viewStart)) {
                if (marker.BackgroundColor != null) {
                    var geoBuilder = new BackgroundGeometryBuilder { AlignToWholePixels = true, CornerRadius = 3 };
                    geoBuilder.AddSegment(textView, marker);
                    System.Windows.Media.Geometry geometry = geoBuilder.CreateGeometry();
                    if (geometry != null) {
                        System.Windows.Media.Color color = marker.BackgroundColor.Value;
                        var brush = new System.Windows.Media.SolidColorBrush(color);
                        brush.Freeze();
                        drawingContext.DrawGeometry(brush, null, geometry);
                    }
                }
                foreach (System.Windows.Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, marker)) {
                    var startPoint = r.BottomLeft;
                    var endPoint = r.BottomRight;

                    var usedPen = new System.Windows.Media.Pen(new System.Windows.Media.SolidColorBrush(marker.MarkerColor), 1);
                    usedPen.Freeze();
                    const double offset = 2.5;

                    int count = Math.Max((int)((endPoint.X - startPoint.X) / offset) + 1, 4);

                    var geometry = new System.Windows.Media.StreamGeometry();

                    using (System.Windows.Media.StreamGeometryContext ctx = geometry.Open()) {
                        ctx.BeginFigure(startPoint, false, false);
                        ctx.PolyLineTo(CreatePoints(startPoint, endPoint, offset, count).ToArray(), true, false);
                    }

                    geometry.Freeze();

                    drawingContext.DrawGeometry(System.Windows.Media.Brushes.Transparent, usedPen, geometry);
                    break;
                }
            }
        }
Ejemplo n.º 12
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;
        }
 ///<summary>
 /// Creates a shape representing an <see cref="IPoint"/>.
 ///</summary>
 public WpfGeometry CreatePoint(WpfPoint point)
 {
     var pointMarker = new WpfStreamGeometry();
     using (var sgc = pointMarker.Open())
         AddShape(point, sgc);
     return pointMarker;
 }