当前位置: 首页>>代码示例>>C#>>正文


C# StreamGeometry.Open方法代码示例

本文整理汇总了C#中System.Windows.Media.StreamGeometry.Open方法的典型用法代码示例。如果您正苦于以下问题:C# StreamGeometry.Open方法的具体用法?C# StreamGeometry.Open怎么用?C# StreamGeometry.Open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.StreamGeometry的用法示例。


在下文中一共展示了StreamGeometry.Open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

        public override void Draw(
			IList<Point> points,
			double thickness,
			int miterLimit,
			ILogicalToScreenMapper logicalToScreenMapper)
        {
            // First define the geometric shape
            var streamGeometry = new StreamGeometry();
            using (var gc = streamGeometry.Open())
            {
                gc.BeginFigure(points[0], _fillAndClose, _fillAndClose);
                points.RemoveAt(0);

                gc.PolyLineTo(points, true, true);
            }

            using (var dc = RenderOpen())
                dc.DrawGeometry(
                    _fillAndClose ? Brushes.White : null,
                    new Pen(
                        Brushes.White,
                        thickness == 1 ? 0.25 : thickness)
                        {
                            MiterLimit = miterLimit
                        },
                    streamGeometry);
        }
开发者ID:Bruhankovi4,项目名称:Emotyper,代码行数:27,代码来源:LineDrawingVisual.cs

示例2: GetArcGeoMetry

        private Geometry GetArcGeoMetry()
        {
            Point startPoint = PointAtAngle(Math.Min(StartAngle, EndAngle));
            Point endPoint = PointAtAngle(Math.Max(StartAngle, EndAngle));
            Size arcSize = new Size(Math.Max(0, (RenderSize.Width - StrokeThickness) / 2),
                                    Math.Max(0, (RenderSize.Height - StrokeThickness) / 2));
            bool isLargeArc = Math.Abs(EndAngle - StartAngle) > 180;
            var sw = SweepDirection.Clockwise;
            if (EndAngle - StartAngle < 0)
            {
                sw = SweepDirection.Counterclockwise;
                isLargeArc = false;
            }

            StreamGeometry geom = new StreamGeometry();
            if (EndAngle - StartAngle >= 360)
            {
                using (StreamGeometryContext context = geom.Open())
                {
                    context.BeginFigure(PointAtAngle(0), false, true);
                    context.ArcTo(PointAtAngle(359.99), arcSize, 0, isLargeArc, sw, true, false);
                }
            }
            else
            {
                using (StreamGeometryContext context = geom.Open())
                {
                    context.BeginFigure(startPoint, false, false);
                    context.ArcTo(endPoint, arcSize, 0, isLargeArc, sw, true, false);
                }
            }
            geom.Transform = new TranslateTransform(StrokeThickness / 2, StrokeThickness / 2);
            return geom;
        }
开发者ID:guipasmoi,项目名称:WpfApplication1,代码行数:34,代码来源:Arc.cs

示例3: Render

        public void Render(DrawingContext context, IElement element)
        {
            var pathElement = element as CurvedPathElement;

            if (pathElement != null)
            {
                var pen = new Pen(new SolidColorBrush(pathElement.LineColor), pathElement.LineWidth);
                var brush = new SolidColorBrush(pathElement.FillColor);
                var topCurveRadius = pathElement.Radius +(pathElement.PathWidth/2);
                var bottomCurveRadius = pathElement.Radius -(pathElement.PathWidth/2);
                var geometry = new StreamGeometry();
                using (var gc = geometry.Open())
                {

                    gc.BeginFigure(pathElement.BottomLeft, false, true);
                    gc.LineTo(pathElement.TopLeft, true, true);
                    gc.ArcTo(pathElement.TopRight,
                             new Size(topCurveRadius, topCurveRadius),
                             1, false, SweepDirection.Clockwise, true, true);
                    gc.LineTo(pathElement.BottomRight, true, true);
                    gc.ArcTo(pathElement.BottomLeft,
                             new Size(bottomCurveRadius, bottomCurveRadius),
                             1, false, SweepDirection.Counterclockwise, true, true);
                }
                context.DrawGeometry(brush, pen, geometry);
                //var topPen = new Pen(Brushes.Red, 1);
                //var bottomPen = new Pen(Brushes.Blue, 1);
                //context.DrawEllipse(brush, topPen, pathElement.Origin, topCurveRadius, topCurveRadius);
                //context.DrawEllipse(brush, bottomPen, pathElement.Origin, bottomCurveRadius, bottomCurveRadius);

                //context.DrawEllipse(brush, pen, pathElement.Origin, pathElement.Radius, pathElement.Radius);
            }
        }
开发者ID:curtmantle,项目名称:LayoutRender,代码行数:33,代码来源:CurvedPathElementRenderer.cs

示例4: createGeometry

        //Redraw the streamgeometry
        public void createGeometry() {
            // Create a StreamGeometry to use to specify myPath.
            geometry = new StreamGeometry();
            // Open a StreamGeometryContext that can be used to describe this StreamGeometry  
            // object's contents. 
            using (StreamGeometryContext geo = geometry.Open())
            {
                double xmax = window.anchorOut; //views xmax
                double xmin = window.anchorIn; //views xmin
                int xres = (int)Math.Ceiling((xmax-xmin) / window.plot.Width);

                geo.BeginFigure(new Point(0, 0), false, false);
                for (int i = (int)xmin; i < xmax; i+=1) //always 600 steps
                {
                    double value;
                    if (i < (values.Count() - 1))
                    {
                        value = values[i];
                    }
                    else { break; }
                    geo.LineTo(new Point(i, value), true, false);
                    i++;
                }
            }
            geometry.Freeze(); //Freeze to free resources
            line.Data = geometry;
        }
开发者ID:DiLRandI,项目名称:ArduinoMonitor,代码行数:28,代码来源:Signal.cs

示例5: CreateArcDrawing

        /// <summary>
        /// Create an Arc geometry drawing of an ellipse or circle
        /// </summary>
        /// <param name="rect">Box to hold the whole ellipse described by the arc</param>
        /// <param name="startDegrees">Start angle of the arc degrees within the ellipse. 0 degrees is a line to the right.</param>
        /// <param name="sweepDegrees">Sweep angle, -ve = Counterclockwise, +ve = Clockwise</param>
        /// <returns>GeometryDrawing object</returns>
        private static GeometryDrawing CreateArcDrawing(Rect rect, double startDegrees, double sweepDegrees)
        {
            // degrees to radians conversion
            double startRadians = startDegrees * Math.PI / 180.0;
            double sweepRadians = sweepDegrees * Math.PI / 180.0;

            // x and y radius
            double dx = rect.Width / 2;
            double dy = rect.Height / 2;

            // determine the start point
            double xs = rect.X + dx + (Math.Cos(startRadians) * dx);
            double ys = rect.Y + dy + (Math.Sin(startRadians) * dy);

            // determine the end point
            double xe = rect.X + dx + (Math.Cos(startRadians + sweepRadians) * dx);
            double ye = rect.Y + dy + (Math.Sin(startRadians + sweepRadians) * dy);

            // draw the arc into a stream geometry
            StreamGeometry streamGeom = new StreamGeometry();
            using (StreamGeometryContext ctx = streamGeom.Open())
            {
                bool isLargeArc = Math.Abs(sweepDegrees) > 180;
                SweepDirection sweepDirection = sweepDegrees < 0 ? SweepDirection.Counterclockwise : SweepDirection.Clockwise;

                ctx.BeginFigure(new Point(xs, ys), false, false);
                ctx.ArcTo(new Point(xe, ye), new Size(dx, dy), 0, isLargeArc, sweepDirection, true, false);
            }

            // create the drawing
            GeometryDrawing drawing = new GeometryDrawing();
            drawing.Geometry = streamGeom;
            return drawing;
        }
开发者ID:Meddington,项目名称:xyzmidi,代码行数:41,代码来源:MappingFeedback.cs

示例6: MakeGeometry

        internal void MakeGeometry()
        {
            if (Edge.Points.Count > 0)
            {
                var points = Edge.Points;
                StreamGeometry g = new StreamGeometry();
                StreamGeometryContext c = g.Open();

                c.BeginFigure(points[0], false, false);
                var r = Edge.Points.Where(p => p != Edge.Points[0]);
                c.PolyBezierTo(r.ToList(), true, false);

                if (Edge.EndPoint.HasValue)
                {
                    Point from = Edge.Points.Last();
                    Point to = Edge.EndPoint.Value;

                    DrawArrow(c, from, to, 4);
                }

                if (Edge.StartPoint.HasValue)
                {
                    Point from = Edge.Points.First();
                    Point to = Edge.StartPoint.Value;

                    DrawArrow(c, from, to, 4);
                }

                c.Close();
                g.Freeze();

                EdgeGeometry = g;
            }
        }
开发者ID:smartcaveman,项目名称:graphviznet,代码行数:34,代码来源:EdgePresenter.cs

示例7: CalculateGeometry

    /// <summary>
    /// Does a one off calculation of the geometry to be rendered
    /// </summary>
    private void CalculateGeometry() {

      if(_recalcGeometry) {
        Func<bool, int, StreamGeometry> buildGeometry = (bool isFilled, int pointIndex) => {
          StreamGeometry childGeometry = new StreamGeometry();
          using(StreamGeometryContext ctx = childGeometry.Open()) {
            // Break up into groups of 4
            ctx.BeginFigure(Points[pointIndex], isFilled, isFilled);
            for(int j = 0; j < 4; ++j) {
              ctx.LineTo(Points[pointIndex + j], !isFilled, true);
            }
            if(!isFilled) {
              ctx.LineTo(Points[pointIndex], !isFilled, true);
            }
          }
          return childGeometry;
        };

        _filledGeometry = _filledGeometry ?? new GeometryGroup();
        _unfilledGeometry = _unfilledGeometry ?? new GeometryGroup();

        _filledGeometry.Children.Clear();
        _unfilledGeometry.Children.Clear();
        if(Points.Count > 0) {
          for(int pointIndex = 0, colorIndex = 0; pointIndex < (Points.Count - 3); pointIndex += 4, colorIndex += 1) {
            _unfilledGeometry.Children.Add(buildGeometry(false, pointIndex));
            _filledGeometry.Children.Add(buildGeometry(true, pointIndex));
          }
        }
        _recalcGeometry = false;
      }
    }
开发者ID:jrc60752,项目名称:iRacingAdminSync,代码行数:35,代码来源:ChartPrimitiveHBar.cs

示例8: PathOutlineVisual

        public PathOutlineVisual(IPathOutline outline)
        {
            var brush = new SolidColorBrush(outline.LineColor);
            var pen = new Pen(brush, 1);

            var geometry = new StreamGeometry();
            using (var gc = geometry.Open())
            {

                gc.BeginFigure(outline.BottomLeft, false, false);
                gc.LineTo(outline.TopLeft, true, true);
                gc.ArcTo(outline.TopRight,
                    new Size(outline.Radius + (outline.Width / 2), outline.Radius + (outline.Width / 2)),
                    1,
                    false,
                    outline.Direction == PathType.Convex ? SweepDirection.Clockwise : SweepDirection.Counterclockwise,
                    true,
                    true);

                gc.LineTo(outline.BottomRight, true, true);
                gc.ArcTo(outline.BottomLeft,
                    new Size(outline.Radius - (outline.Width / 2), outline.Radius - (outline.Width / 2)),
                    1,
                    false,
                    outline.Direction == PathType.Convex ? SweepDirection.Counterclockwise : SweepDirection.Clockwise,
                    true,
                    true);

            }

            using (var context = RenderOpen())
            {
                context.DrawGeometry(brush, pen, geometry);
            }
        }
开发者ID:curtmantle,项目名称:Geometry,代码行数:35,代码来源:PathOutlineVisual.cs

示例9: Draw

        public void Draw( EdgeLayout layoutState )
        {
            var styleState = myPresentation.GetPropertySetFor<EdgeStyle>().Get( Owner.Id );

            var stream = new StreamGeometry();
            var context = stream.Open();

            context.BeginFigure( layoutState.Points.First(), false, false );

            context.PolyBezierTo( layoutState.Points.Skip( 1 ).ToList(), true, false );

            // draw arrow head
            var start = layoutState.Points.Last();
            var v = start - layoutState.Points.ElementAt( layoutState.Points.Count() - 2 );
            v.Normalize();

            start = start - v * 0.15;
            context.BeginFigure( start + v * 0.28, true, true );
            double t = v.X; v.X = v.Y; v.Y = -t;  // Rotate 90°
            context.LineTo( start + v * 0.08, true, true );
            context.LineTo( start + v * -0.08, true, true );
            context.Close();

            var pen = new Pen( styleState.Color, 0.016 );

            // http://stackoverflow.com/questions/1755520/improve-drawingvisual-renders-speed
            Visual = new DrawingVisual();
            var dc = Visual.RenderOpen();
            dc.DrawGeometry( pen.Brush, pen, stream );
            dc.Close();

            Visual.SetValue( GraphItemProperty, Owner );
        }
开发者ID:mwidmeyer,项目名称:Plainion.GraphViz,代码行数:33,代码来源:EdgeVisual.cs

示例10: CalculateShape

		private void CalculateShape()
		{
			//Vorberechnen für bessere Performance
			float angle = Angle * (float)(Math.PI / 180);
			float sinAngle = (float)Math.Sin(angle);
			float cosAngle = (float)Math.Cos(angle);

			//P_L
			startPoint = new Point(Size - cosAngle * Size, Size + sinAngle * Size);
			//P_O
			circleIntersectionPoint = new Point(2 * Size, Size);
			//P_R
			circleEndPoint = new Point(Size * 3 + cosAngle * Size, Size + sinAngle * Size);
			//P_U
			Vector angledVector = new Vector(-sinAngle, cosAngle);
			double lineLength = (2 * Size - (Size * 3 + cosAngle * Size)) / angledVector.X;
			trianglePoint = Point.Add(circleEndPoint, Vector.Multiply(angledVector, lineLength));

			//Form aus Punkten erstellen
			heart = new StreamGeometry();
			using (StreamGeometryContext ctx = heart.Open())
			{
				ctx.BeginFigure(startPoint, true, true);
				ctx.ArcTo(circleIntersectionPoint, new Size(Size, Size), Math.PI + angle, true, SweepDirection.Clockwise, true, false);
				ctx.ArcTo(circleEndPoint, new Size(Size, Size), Math.PI + angle, true, SweepDirection.Clockwise, true, false);
				ctx.LineTo(trianglePoint, true, false);
			}
			heart.Freeze();
		}
开发者ID:lkempf,项目名称:Bwinf-34-r2,代码行数:29,代码来源:Cake.cs

示例11: Draw

 public void Draw(TextView textView, DrawingContext drawingContext)
 {
     foreach (TextSegment current in this.SearchHitsSegments)
     {
         foreach (Rect current2 in BackgroundGeometryBuilder.GetRectsForSegment(textView, current))
         {
             Point bottomLeft = current2.BottomLeft;
             Point bottomRight = current2.BottomRight;
             Pen pen = new Pen(new SolidColorBrush(Colors.OrangeRed), 1);
             pen.Freeze();
             double num = 2.5;
             int count = System.Math.Max((int)((bottomRight.X - bottomLeft.X) / num) + 1, 4);
             StreamGeometry streamGeometry = new StreamGeometry();
             using (StreamGeometryContext streamGeometryContext = streamGeometry.Open())
             {
                 streamGeometryContext.BeginFigure(bottomLeft, true, true);
                 streamGeometryContext.LineTo(current2.TopLeft, true, false);
                 streamGeometryContext.LineTo(current2.TopRight, true, false);
                 streamGeometryContext.LineTo(current2.BottomRight, true, false);
             }
             streamGeometry.Freeze();
             drawingContext.DrawGeometry(Brushes.Transparent, pen, streamGeometry);
         }
     }
 }
开发者ID:BernardNotarianni,项目名称:DownmarkerWPF,代码行数:25,代码来源:SearchBackgroundRenderer.cs

示例12: AddArrow

        private void AddArrow(Panel rootCanvas, Point arrowPoint)
        {
            var size = 10.0;

            var relationshipPath = new Path
            {
                Stroke = Brushes.Black,
                StrokeThickness = 2,
                Visibility = Visibility.Visible,
                Fill = Brushes.Black
            };

            var geometry = new StreamGeometry
            {
                FillRule = FillRule.EvenOdd
            };

            using (var ctx = geometry.Open())
            {
                ctx.BeginFigure(new Point(arrowPoint.X, arrowPoint.Y), true, true);

                ctx.LineTo(new Point(arrowPoint.X - size / 2, arrowPoint.Y - size), true, true);
                ctx.LineTo(new Point(arrowPoint.X + size / 2, arrowPoint.Y - size), true, true);
            }

            geometry.Freeze();

            relationshipPath.Data = geometry;
            rootCanvas.Children.Add(relationshipPath);
        }
开发者ID:NicoVermeir,项目名称:ServiceInsight,代码行数:30,代码来源:SagaWindowView.xaml.cs

示例13: Draw

        public void Draw(DrawingContext context, DrawingArgs args)
        {
            context.PushClip(new RectangleGeometry(args.RenderBounds));
            if (m_IsDirty || args.RequiresFullRedraw)
            {
                m_LonePoints.Clear();
                System.Windows.Media.StreamGeometry geo = new StreamGeometry();
                using (var c = geo.Open())
                {
                    Point? figureStart = null;
                    int pointCount = 0; //point in the figure

                    if (Values.Count() == 1 && Values.First().HasValue)
                    {
                        m_LonePoints.Add(Values.First().Value);
                    }
                    else
                    {
                        foreach (var p in Values)
                        {
                            if (p.HasValue)
                            {
                                if (!figureStart.HasValue)
                                {
                                    figureStart = p.Value;
                                    c.BeginFigure(figureStart.Value, false, false);
                                    pointCount = 1;
                                }
                                else
                                {
                                    c.LineTo(p.Value, true, true);
                                    pointCount++;
                                }
                            }
                            else
                            {
                                //detect lone points and draw a cross
                                if (pointCount == 1)
                                {
                                    m_LonePoints.Add(figureStart.Value);
                                }
                                figureStart = null;
                            }
                        }
                    }
                }

                m_Geo = geo;
                m_IsDirty = false;
            }

            m_Geo.Transform = args.Transform;
            context.DrawGeometry(null, Pen, m_Geo);

            var radius = Pen.Thickness;
            foreach (var p in m_LonePoints)
            {
                context.DrawEllipse(m_Pen.Brush, null, args.Transform.Transform(p), radius, radius);
            }
        }
开发者ID:Gusdor,项目名称:Charting,代码行数:60,代码来源:LineSeriesElement.cs

示例14: StreamGeometryFromCurve

 public static StreamGeometry StreamGeometryFromCurve(Curve curve, MatrixTransform graphToCanvas)
 {
     double[] tempX;
     double[] tempY;
     if (graphToCanvas != null)
     {
         tempX = curve.xTransformed.MultiplyBy(graphToCanvas.Matrix.M11).SumWith(graphToCanvas.Matrix.OffsetX);
         tempY = curve.yTransformed.MultiplyBy(graphToCanvas.Matrix.M22).SumWith(graphToCanvas.Matrix.OffsetY);
     }
     else
     {
         tempX = curve.xTransformed; tempY = curve.yTransformed;
     }
     StreamGeometry streamGeometry = new StreamGeometry();
     StreamGeometryContext context = streamGeometry.Open();
     int lines = 0;
     for (int i = 0; i < curve.x.Count(); ++i)
     {
         if (i == 0)
         {
             context.BeginFigure(new Point(tempX[i], tempY[i]), false, false);
         }
         else
         {
             if (curve.includeLinePoint[i])
             {
                 context.LineTo(new Point(tempX[i], tempY[i]), true, false);
                 lines++;
             }
         }
     }
     context.Close();
     return streamGeometry;
 }
开发者ID:irriss,项目名称:IronPlot.net,代码行数:34,代码来源:LineGeometries.cs

示例15: ToWpfGeometry

 public static Geometry ToWpfGeometry(this SqlGeometry sqlGeometry, double pointSize)
 {
     StreamGeometry streamGeometry = new StreamGeometry();
     using (StreamGeometryContext streamGeometryContext = streamGeometry.Open())
     {
         if (sqlGeometry != null && !sqlGeometry.IsNull)
         {
             for (int geometryIndex = 0; geometryIndex < (int)sqlGeometry.STNumGeometries(); geometryIndex++)
             {
                 SqlGeometry subGeometry = sqlGeometry.STGeometryN(geometryIndex + 1);
                 if (subGeometry.STGeometryType() == "Polygon" || subGeometry.STGeometryType() == "MultiPolygon")
                 {
                     Point[] points = GetPointsFromSqlGeometry(subGeometry.STExteriorRing());
                     AddSegmentToGeometry(streamGeometryContext, points, true);
                     for (int interiorRingIndex = 0; interiorRingIndex < subGeometry.STNumInteriorRing(); interiorRingIndex++)
                     {
                         points = GetPointsFromSqlGeometry(subGeometry.STInteriorRingN(interiorRingIndex + 1));
                         AddSegmentToGeometry(streamGeometryContext, points, true);
                     }
                 }
                 else if (subGeometry.STGeometryType() == "MultiPoint" || subGeometry.STGeometryType() == "Point")
                 {
                     Point[] points = GetPointsFromSqlGeometry(subGeometry);
                     AddCircleToGeometry(streamGeometryContext, points, pointSize);
                 }
                 else if (subGeometry.STGeometryType() == "LineString" || subGeometry.STGeometryType() == "MultiLineString")
                 {
                     Point[] points = GetPointsFromSqlGeometry(subGeometry);
                     AddSegmentToGeometry(streamGeometryContext, points, false);
                 }
             }
         }
     }
     return streamGeometry;
 }
开发者ID:HackatonArGP,项目名称:Guardianes,代码行数:35,代码来源:SqlGeometryHelper.cs


注:本文中的System.Windows.Media.StreamGeometry.Open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。