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


C# Media.StreamGeometry类代码示例

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


StreamGeometry类属于System.Windows.Media命名空间,在下文中一共展示了StreamGeometry类的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: AreaSeries2D

        public AreaSeries2D()
        {
            // 初始化保存数据点的变量
            _points = new SeriesPointCollection();
            _points.CollectionChanged += _points_CollectionChanged;

            // 初始化绘制曲线的画板
            gStream_Line = new StreamGeometry();
            gStream_Area = new StreamGeometry();

            gDrawing_Line = new GeometryDrawing();
            gDrawing_Line.Brush = null;
            gDrawing_Line.Pen = new Pen()
            {
                Thickness = 1,
                Brush = Brushes.Black
            };
            gDrawing_Line.Geometry = gStream_Line;

            /* 初始化绘制填充色的画板 */
            gDrawing_Area = new GeometryDrawing();
            gDrawing_Area.Brush = Brushes.Red;
            gDrawing_Area.Pen = new Pen()
            {
                Thickness = 0,
                Brush = null
            };
            gDrawing_Area.Geometry = gStream_Area;

            /* 生成绘画组 */
            drawingGroup = new DrawingGroup();
            drawingGroup.Children.Add(gDrawing_Line);
            drawingGroup.Children.Add(gDrawing_Area);
        }
开发者ID:35408EF66CCE4377B1E3C2495CA1C18A,项目名称:XuanJiYi_PC,代码行数:34,代码来源:AreaSeries2D.cs

示例3: 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

示例4: 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

示例5: 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

示例6: TextBoxUpDownAdorner

        public TextBoxUpDownAdorner(TextBox adornedTextBox)
            : base(adornedTextBox)
        {
            this.triangle = new StreamGeometry();
            this.triangle.FillRule = FillRule.Nonzero;
            using (StreamGeometryContext geometryContext = this.triangle.Open())
            {
                geometryContext.BeginFigure(new Point(-6, 0), true /* filled */, true /* closed */);
                geometryContext.LineTo(new Point(6, 0), true, false);
                geometryContext.LineTo(new Point(0, 8), true, false);
            }
            this.triangle.Freeze();

            this.MouseDown += (s, e) =>
            {
                if (this.Button_Clicked != null)
                {
                    bool up = e.GetPosition(this.AdornedElement).Y < (top + bottom) / 2;
                    this.Button_Clicked((TextBox)this.AdornedElement, up ? 1 : -1);
                }
            };

            adornedTextBox.LostFocus += this.FocusLostOrSelectionChanged;
            adornedTextBox.SelectionChanged += this.FocusLostOrSelectionChanged;
        }
开发者ID:CascadesCarnivoreProject,项目名称:Timelapse,代码行数:25,代码来源:TextBoxUpDownAdorner.cs

示例7: 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

示例8: CreateErrorPen

 public static Pen CreateErrorPen(Color color)
 {
     var geometry = new StreamGeometry();
     using (var context = geometry.Open())
     {
         context.BeginFigure(new Point(-1, 0), false, false);
         context.PolyLineTo(new[] {
                 new Point(-0.5, 0.4),
                 new Point(0, 0),
                 new Point(0.5, -0.4),
                 new Point(1, 0),
             }, true, true);
     }
     var brushPattern = new GeometryDrawing
     {
         Pen = new Pen(new SolidColorBrush(color), 0.4),
         Geometry = geometry
     };
     var brush = new DrawingBrush(brushPattern)
     {
         TileMode = TileMode.Tile,
         Viewport = new Rect(-1, -1, 2, 2),
         ViewportUnits = BrushMappingMode.Absolute,
         Viewbox = new Rect(-1, -1, 2, 2),
         ViewboxUnits = BrushMappingMode.Absolute,
     };
     var pen = new Pen(brush, 3.0);
     pen.Freeze();
     return pen;
 }
开发者ID:osmedile,项目名称:TypeCobol,代码行数:30,代码来源:Pen.cs

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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