• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Media.PathGeometry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



PathGeometry类属于System.Windows.Media命名空间,在下文中一共展示了PathGeometry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Draw

        public static void Draw(Canvas canvas, List<LinePoint> points, Brush stroke, bool clear = true)
        {
            if (clear)
            {
                canvas.Children.Clear();
            }

            PathFigureCollection myPathFigureCollection = new PathFigureCollection();
            PathGeometry myPathGeometry = new PathGeometry();

            foreach (LinePoint p in points)
            {
                PathFigure myPathFigure = new PathFigure();
                myPathFigure.StartPoint = p.StartPoint;

                LineSegment myLineSegment = new LineSegment();
                myLineSegment.Point = p.EndPoint;

                PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
                myPathSegmentCollection.Add(myLineSegment);

                myPathFigure.Segments = myPathSegmentCollection;

                myPathFigureCollection.Add(myPathFigure);
            }

            myPathGeometry.Figures = myPathFigureCollection;
            Path myPath = new Path();
            myPath.Stroke = stroke == null ? Brushes.Black : stroke;
            myPath.StrokeThickness = 1;
            myPath.Data = myPathGeometry;

            canvas.Children.Add(myPath);
        }
开发者ID:Eddie104,项目名称:Libra-CSharp,代码行数:34,代码来源:GraphicsHelper.cs


示例2: GetShapeGeometry

        public Geometry GetShapeGeometry()
        {
            PathFigure outer = new PathFigure();
            outer.IsClosed = true;
            outer.StartPoint = new Point(0, 2.5);
            outer.Segments.Add(new LineSegment() { Point = new Point(2.5, 0) });
            outer.Segments.Add(new LineSegment() { Point = new Point(5, 2.5) });
            outer.Segments.Add(new LineSegment() { Point = new Point(7.5, 0) });
            outer.Segments.Add(new LineSegment() { Point = new Point(10, 2.5) });
            outer.Segments.Add(new LineSegment() { Point = new Point(9, 3.5) });
            outer.Segments.Add(new LineSegment() { Point = new Point(7.5, 2) });
            outer.Segments.Add(new LineSegment() { Point = new Point(6, 3.5) });
            outer.Segments.Add(new LineSegment() { Point = new Point(8.5, 6) });
            outer.Segments.Add(new LineSegment() { Point = new Point(5, 9.5) });
            outer.Segments.Add(new LineSegment() { Point = new Point(1.5, 6) });
            outer.Segments.Add(new LineSegment() { Point = new Point(4, 3.5) });
            outer.Segments.Add(new LineSegment() { Point = new Point(2.5, 2) });
            outer.Segments.Add(new LineSegment() { Point = new Point(1, 3.5) });

            PathFigure inner = new PathFigure();
            inner.StartPoint = new Point(3.5, 6);
            inner.IsClosed = true;
            inner.Segments.Add(new LineSegment() { Point = new Point(5, 7.5) });
            inner.Segments.Add(new LineSegment() { Point = new Point(6.5, 6) });
            inner.Segments.Add(new LineSegment() { Point = new Point(5, 4.5) });

            PathGeometry logoGeometry = new PathGeometry();
            logoGeometry.Figures.Add(inner);
            logoGeometry.Figures.Add(outer);

            return logoGeometry;
        }
开发者ID:Motaz-Al-Zoubi,项目名称:xaml-sdk,代码行数:32,代码来源:TelerikLogo.cs


示例3: Page_Loaded

 /// <summary>
 /// 页面加载
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     IsVirtualMark = new SolidColorBrush(Properties.Settings.Default.MarkVirtualColor);
     NotVirtualMark = new SolidColorBrush(Properties.Settings.Default.MarkNotColor);
     MarkDiameter = Properties.Settings.Default.MarkDiameter;
     RouteColor = new SolidColorBrush(Properties.Settings.Default.RouteColor);
     EVirtualMark.Fill = IsVirtualMark;
     ENotVirtualMark.Fill = NotVirtualMark;
     RecRoute.Fill = RouteColor;
     // Create the animation path.
     path = new Path();
     path.Stroke = RouteColor;
     path.StrokeThickness = 3;
     animationPath = new PathGeometry();
     pFigure = new PathFigure();
     route = new PolyLineSegment();
     path.Data = animationPath;
     pFigure.Segments.Add(route);
     animationPath.Figures.Add(pFigure);
     MapInit();
     //修改日期:2013-12-1
     //修改日期:2013-12-30
     BindWorkLineCombox();
     BindLineCombox(cbRoute_WorkLine.Text.Trim());
     LoadAllMark();
 }
开发者ID:qq5013,项目名称:AGV_Server,代码行数:31,代码来源:RouteManage.xaml.cs


示例4: DrawUnderlyingPolyline

 internal static void DrawUnderlyingPolyline(PathGeometry pg, DEdge edge)
 {
     IEnumerable<WinPoint> points = edge.GeometryEdge.UnderlyingPolyline.Select(p => WinPoint(p));
     PathFigure pf = new PathFigure() { IsFilled = false, IsClosed = false, StartPoint = points.First() };
     foreach (WinPoint p in points)
     {
         if (p != points.First())
             pf.Segments.Add(new WinLineSegment() { Point = p });
         PathFigure circle = new PathFigure() { IsFilled = false, IsClosed = true, StartPoint = new WinPoint(p.X - edge.RadiusOfPolylineCorner, p.Y) };
         circle.Segments.Add(
            new ArcSegment()
            {
                Size = new WinSize(edge.RadiusOfPolylineCorner, edge.RadiusOfPolylineCorner),
                SweepDirection = SweepDirection.Clockwise,
                Point = new WinPoint(p.X + edge.RadiusOfPolylineCorner, p.Y)
            });
         circle.Segments.Add(
            new ArcSegment()
            {
                Size = new WinSize(edge.RadiusOfPolylineCorner, edge.RadiusOfPolylineCorner),
                SweepDirection = SweepDirection.Clockwise,
                Point = new WinPoint(p.X - edge.RadiusOfPolylineCorner, p.Y)
            });
         pg.Figures.Add(circle);
     }
     pg.Figures.Add(pf);
 }
开发者ID:mrkcass,项目名称:SuffixTreeExplorer,代码行数:27,代码来源:Draw.cs


示例5: Click_ConvertToFigures

		void Click_ConvertToFigures(object sender, System.Windows.RoutedEventArgs e)
		{
			var path = this.designItem.Component as Path;
			
			if (path.Data is StreamGeometry) {
				var sg = path.Data as StreamGeometry;
				
				var pg = sg.GetFlattenedPathGeometry();
				
//				foreach (var g in parts) {
//					
//				}
				
				var pgDes = designItem.Services.Component.RegisterComponentForDesigner(pg);
				designItem.Properties[Path.DataProperty].SetValue(pgDes);
			}
			else if (path.Data is PathGeometry) {
				var pg = path.Data as PathGeometry;
				
				var figs = pg.Figures;
				
				var newPg = new PathGeometry();
				var newPgDes = designItem.Services.Component.RegisterComponentForDesigner(newPg);
				
				foreach (var fig in figs) {
					newPgDes.Properties[PathGeometry.FiguresProperty].CollectionElements.Add(FigureToDesignItem(fig));
				}
								
				designItem.Properties[Path.DataProperty].SetValue(newPg);
			}
			
		}
开发者ID:modulexcite,项目名称:WpfDesigner,代码行数:32,代码来源:PathContextMenu.xaml.cs


示例6: ConvertBack

        /// <summary>
        ///     Main back conversion routine - converts PathGeometry object to its string equivalent
        /// </summary>
        /// <param name="geometry">Path Geometry object</param>
        /// <returns>String equivalent to PathGeometry contents</returns>
        public string ConvertBack(PathGeometry geometry)
        {
            if (null == geometry)
                throw new ArgumentException("Path Geometry cannot be null!");

            return parseBack(geometry);
        }
开发者ID:Neils320,项目名称:TextOnAPathPhone,代码行数:12,代码来源:PathConverter.cs


示例7: InsertionAdorner

        // Create the pen and triangle in a static constructor and freeze them to improve performance.
        static InsertionAdorner()
        {
            pen = new Pen
            {
                Brush = Brushes.Gray,
                Thickness = 2
            };
            pen.Freeze();

            LineSegment firstLine = new LineSegment(new Point(0, -5), false);
            firstLine.Freeze();
            LineSegment secondLine = new LineSegment(new Point(0, 5), false);
            secondLine.Freeze();

            PathFigure figure = new PathFigure
            {
                StartPoint = new Point(5, 0)
            };
            figure.Segments.Add(firstLine);
            figure.Segments.Add(secondLine);
            figure.Freeze();

            triangle = new PathGeometry();
            triangle.Figures.Add(figure);
            triangle.Freeze();
        }
开发者ID:Boddlnagg,项目名称:WordsLive,代码行数:27,代码来源:InsertionAdorner.cs


示例8: AddCircularArcGraph

		private void AddCircularArcGraph(Point startPoint, Point endPoint, Size size)
		{
			PathFigure pf = new PathFigure();
			pf.StartPoint = new Point(startPoint.X, startPoint.Y);

			ArcSegment arcSegment = new ArcSegment();
			arcSegment.Point = new Point(endPoint.X, endPoint.Y);
			arcSegment.Size = size;
			arcSegment.SweepDirection = SweepDirection.Counterclockwise;

			PathSegmentCollection psc = new PathSegmentCollection();
			psc.Add(arcSegment);

			pf.Segments = psc;

			PathFigureCollection pfc = new PathFigureCollection();
			pfc.Add(pf);

			PathGeometry pg = new PathGeometry();
			pg.Figures = pfc;

			var path = new Path();
			path.Stroke = Brushes.Black;
			path.StrokeThickness = 1;
			path.Data = pg;
			path.Fill = Brushes.Orange;
			path.Stretch = Stretch.Fill;

			var viewportPanel = new ViewportHostPanel();
			ViewportPanel.SetViewportBounds(path, new DataRect(0, 0, 50, 50));
			viewportPanel.Children.Add(path);
			plotter.Children.Add(viewportPanel);
		}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:33,代码来源:Window1.xaml.cs


示例9: ToXaml

 public static XamlMedia.PathGeometry ToXaml(this IEnumerable<LinearRing> linearRings)
 {
     var pathGeometry = new XamlMedia.PathGeometry();
     foreach (var linearRing in linearRings)
         pathGeometry.Figures.Add(CreatePathFigure(linearRing));
     return pathGeometry;
 }
开发者ID:HackatonArGP,项目名称:Guardianes,代码行数:7,代码来源:GeometryExtensions.cs


示例10: OnRender

        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            

            // allows the points to be rendered as an image that can be further manipulated
            PathGeometry geometry = new PathGeometry();
            this.Siz

            // Add all points to the geometry
            foreach (Points pointXY in _points)
            {
                PathFigure figure = new PathFigure();
                figure.StartPoint = pointXY.FromPoint;
                figure.Segments.Add(new LineSegment(pointXY.ToPoint, true));
                geometry.Figures.Add(figure);
            }

            // Add the first point to close the gap from the graph's end point
            // to graph's start point
            PathFigure lastFigure = new PathFigure();
            lastFigure.StartPoint = _points[_points.Count - 1].FromPoint;
            lastFigure.Segments.Add(new LineSegment(_firstPoint, true));
            geometry.Figures.Add(lastFigure);

            // Create a new drawing and drawing group in order to apply
            // a custom drawing effect
            GeometryDrawing drawing = new GeometryDrawing(this.Pen.Brush, this.Pen, geometry);
            DrawingGroup drawingGroup = new DrawingGroup();
            drawingGroup.Children.Add(drawing);
        }
开发者ID:valentine-palazkov,项目名称:tictactoe-wpf,代码行数:32,代码来源:BoardCellView.xaml.cs


示例11: StartDrawItem

		public void StartDrawItem(DesignItem clickedOn, Type createItemType, IDesignPanel panel, System.Windows.Input.MouseEventArgs e)
		{
			var createdItem = CreateItem(panel.Context, createItemType);

			var startPoint = e.GetPosition(clickedOn.View);
			var operation = PlacementOperation.TryStartInsertNewComponents(clickedOn,
			                                                               new DesignItem[] { createdItem },
			                                                               new Rect[] { new Rect(startPoint.X, startPoint.Y, double.NaN, double.NaN) },
			                                                               PlacementType.AddItem);
			if (operation != null) {
				createdItem.Services.Selection.SetSelectedComponents(new DesignItem[] { createdItem });
				operation.Commit();
			}
			
			createdItem.Properties[Shape.StrokeProperty].SetValue(Brushes.Black);
			createdItem.Properties[Shape.StrokeThicknessProperty].SetValue(2d);
			createdItem.Properties[Shape.StretchProperty].SetValue(Stretch.None);
			
			var figure = new PathFigure();
			var geometry = new PathGeometry();
			var geometryDesignItem = createdItem.Services.Component.RegisterComponentForDesigner(geometry);
			var figureDesignItem = createdItem.Services.Component.RegisterComponentForDesigner(figure);
			createdItem.Properties[Path.DataProperty].SetValue(geometry);
			//geometryDesignItem.Properties[PathGeometry.FiguresProperty].CollectionElements.Add(figureDesignItem);
			figureDesignItem.Properties[PathFigure.StartPointProperty].SetValue(new Point(0,0));
			
			new DrawPathMouseGesture(figure, createdItem, clickedOn.View, changeGroup, this.ExtendedItem.GetCompleteAppliedTransformationToView()).Start(panel, (MouseButtonEventArgs) e);
		}
开发者ID:modulexcite,项目名称:WpfDesigner,代码行数:28,代码来源:DrawPathExtension.cs


示例12: geometryLine

        public geometryLine(Canvas cvs)
        {
            rootPanel = cvs;
            //myPathFigure = new PathFigure();
            myPathGeometry = new PathGeometry();
            //myPathGeometry.Figures.Add(myPathFigure);

            myPath = new Path();
            myPath.Stroke = Brushes.Blue;
            myPath.StrokeThickness = 1;
            myPath.Data = myPathGeometry;
            rootPanel.Children.Add(myPath);

            myPathFigureOld = new PathFigure();
            myPathGeometryOld = new PathGeometry();
            myPathGeometryOld.Figures.Add(myPathFigureOld);

            myPathOld = new Path();
            myPathOld.Stroke = Brushes.Blue;
            myPathOld.StrokeThickness = 1;
            myPathOld.Data = myPathGeometryOld;

            rootPanel.Children.Add(myPathOld);
            myPathFigureTest = new PathFigure();
            myPathGeometry.Figures.Add(myPathFigureTest);

            isFirstPoint = true;
        }
开发者ID:hehaiyang7133862,项目名称:VICO_Current,代码行数:28,代码来源:geometryLine.cs


示例13: MoveImage

        public void MoveImage(TimeSpan interval, PathGeometry beeFlyHerePath)
        {
            var storyboard = new Storyboard
            {
                RepeatBehavior = RepeatBehavior.Forever
            };

            var moveCircleAnimation = new DoubleAnimationUsingPath
            {
                PathGeometry = beeFlyHerePath,
                Source = PathAnimationSource.X,
                Duration = interval
            };

            Storyboard.SetTarget(moveCircleAnimation, this);
            Storyboard.SetTargetProperty(moveCircleAnimation, new PropertyPath("(Canvas.Left)"));

            var moveCircleAnimation2 = new DoubleAnimationUsingPath
            {
                PathGeometry = beeFlyHerePath,
                Source = PathAnimationSource.Y,
                Duration = interval
            };

            Storyboard.SetTarget(moveCircleAnimation2, this);
            Storyboard.SetTargetProperty(moveCircleAnimation2, new PropertyPath("(Canvas.Top)"));

            storyboard.Children.Add(moveCircleAnimation);
            storyboard.Children.Add(moveCircleAnimation2);

            storyboard.Begin();
        }
开发者ID:PascalHonegger,项目名称:FreitagsProjekte,代码行数:32,代码来源:AnimatedImage.xaml.cs


示例14: SineCurve

 // Constructor
 public SineCurve()
 {
     polyLineSegment = new PolyLineSegment();
     PathFigure = new PathFigure(new Point(), new PathSegment[] { polyLineSegment }, false);
     pathGeometry = new PathGeometry(new PathFigure[] { PathFigure });
     OnRedrawPropertyChanged(new DependencyPropertyChangedEventArgs());
 }
开发者ID:CodeByBerglund,项目名称:nai-framework,代码行数:8,代码来源:SineCurve.cs


示例15: AddRing

        //private WpfPoint _lastPoint;
        //internal void AddToRing(WpfPoint p, ref GraphicsPath ringPath)
        //{
        //    if (ringPath == null)
        //    {
        //        ringPath = new GraphicsPath(FillMode.Alternate);
        //        ringPath.StartFigure();
        //    }
        //    else
        //    {
        //        ringPath.AddLine(_lastPoint, p);
        //    }
        //    _lastPoint = p;
        //}

        //internal void EndRing(GraphicsPath ringPath)
        //{
        //    ringPath.CloseFigure();
        //    if (Path == null)
        //        Path = ringPath;
        //    else
        //        Path.AddPath(ringPath, false);
        //}

        ///<summary>
        /// Adds a <see cref="PathFigure"/> representing a polygon ring
        /// having the given coordinate sequence to the supplied <see cref="pathGeometry"/>
        ///</summary>
        ///<param name="pathGeometry">The path geometry.</param>
        ///<param name="coordinates">A coordinate sequence</param>
        ///<returns>The path for the coordinate sequence</returns>
        private static void AddRing(PathGeometry pathGeometry, Coordinate[] coordinates)
        {
            if (coordinates.Length <= 0)
                return;
            var figure = new PathFigure(ToPoint(coordinates[0]), ToPathSegments(coordinates), true);
            pathGeometry.Figures.Add(figure);
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:38,代码来源:PolygonWpfPathGeometry.cs


示例16: WpfMultiChart

        public WpfMultiChart()
        {
            InitializeComponent();

            LoadImages();

            //do not show no data label by default
            ShowNoDataLabel(false);

            dataSeries = new List<TimeSeriesData>();
            plotSeries = new TimeSeriesData();
            shapeTransform = new MatrixTransform();
            chartClip = new PathGeometry();
            optimalGridLineSpacing = new Point(100, 50);
            adorner = new AdornerCursor2(ChartInteractiveCanvas, shapeTransform);
            adorner.CanvasSize = new Size(ChartInteractiveCanvas.ActualWidth, ChartInteractiveCanvas.ActualHeight);

            adorner.PanCursorImage = panCursor;

            panZoomCalculator = new PanZoomCalculator();

            ChartCanvas.SizeChanged += new SizeChangedEventHandler(ChartCanvas_SizeChanged);
            ChartCanvas.IsVisibleChanged += new DependencyPropertyChangedEventHandler(ChartCanvas_IsVisibleChanged);

            NoDataLabel.MouseMove += new MouseEventHandler(NoDataLabel_MouseMove);
            AttachEventsToCanvas(ChartInteractiveCanvas);

            ResizeChart();
        }
开发者ID:jamesjrg,项目名称:taipan,代码行数:29,代码来源:WpfMultiChart.xaml.cs


示例17: GetOrCreateConnectorGeometry

        protected override Geometry GetOrCreateConnectorGeometry(Size renderSize)
        {
            var ellipse = Ellipse.CreateFromSize(renderSize);
            this.SetCurrentValue(EllipseProperty, ellipse);
            if (ellipse.IsZero)
            {
                return Geometry.Empty;
            }

            var direction = this.ConnectorOffset;
            var ip = ellipse.PointOnCircumference(direction);
            var vertexPoint = ip + this.ConnectorOffset;
            var ray = new Ray(vertexPoint, this.ConnectorOffset.Negated());

            var p1 = ConnectorPoint.Find(ray, this.ConnectorAngle / 2, this.StrokeThickness, ellipse);
            var p2 = ConnectorPoint.Find(ray, -this.ConnectorAngle / 2, this.StrokeThickness, ellipse);

            this.SetCurrentValue(ConnectorVertexPointProperty, vertexPoint);
            this.SetCurrentValue(ConnectorPoint1Property, p1);
            this.SetCurrentValue(ConnectorPoint2Property, p2);
            if (this.ConnectorGeometry is PathGeometry)
            {
                return this.ConnectorGeometry;
            }

            var figure = this.CreatePathFigureStartingAt(ConnectorPoint1Property);
            figure.Segments.Add(this.CreateLineSegmentTo(ConnectorVertexPointProperty));
            figure.Segments.Add(this.CreateLineSegmentTo(ConnectorPoint2Property));
            var geometry = new PathGeometry();
            geometry.Figures.Add(figure);
            return geometry;
        }
开发者ID:JohanLarsson,项目名称:Gu.Wpf.Geometry,代码行数:32,代码来源:EllipseBalloon.cs


示例18: OnApplyTemplate

        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            var partPath = this.GetTemplateChild("PART_Path") as Path;
            if (partPath != null)
            {
                var pathGeometry = new PathGeometry();
                var ellipsePathFigure = new PathFigure() { StartPoint = new Point(0, 20) };
                ellipsePathFigure.Segments = new PathSegmentCollection();
                ellipsePathFigure.Segments.Add(new ArcSegment()
                {
                    Size = new Size(5.0 / 6.0 * this.Width, 25),
                    Point = new Point(this.Width, 20),
                    IsLargeArc = false,
                    SweepDirection = SweepDirection.Counterclockwise
                });
                pathGeometry.Figures.Add(ellipsePathFigure);

                var linePathFigure = new PathFigure();
                linePathFigure.Segments = new PathSegmentCollection();
                linePathFigure.Segments.Add(new LineSegment() { Point = new Point(this.Width, 0) });
                linePathFigure.Segments.Add(new LineSegment() { Point = new Point(this.Width, 20) });
                linePathFigure.Segments.Add(new LineSegment() { Point = new Point(0, 20) });
                
                pathGeometry.Figures.Add(linePathFigure);

                partPath.Data = pathGeometry;
            }

        }
开发者ID:fjkfjk,项目名称:ExerciseDemo,代码行数:31,代码来源:ItemPanel.cs


示例19: Superposition

        public Superposition()
        {
            InitializeComponent();
                        
            PathGeometry pathGeometry = new PathGeometry();
            PathFigure pathFigure = new PathFigure();
            
            pathFigure.StartPoint = new Point(0,0);

            PathSegmentCollection pathSegmentCollection = new PathSegmentCollection();

            int maxHeight = (int)this.Height;
            int maxWidth = (int)this.Width;
            Random rand = new Random();
            for (int i = 0; i < 500; i++)
            {
                LineSegment newSegment = new LineSegment();
                newSegment.Point = new Point(rand.Next(0, maxWidth), rand.Next(0, maxHeight));
                pathSegmentCollection.Add(newSegment);
            }

            pathFigure.Segments = pathSegmentCollection;
            pathGeometry.Figures.Add(pathFigure);

            pathBackground.Data = pathGeometry;


        }
开发者ID:Corantin,项目名称:Cegep,代码行数:28,代码来源:Superposition.xaml.cs


示例20: OnRender

        /*  将相邻两点连线
        protected override void OnRender(DrawingContext dc)
        {
            if (InternalChildren.Count < 2)
            {
                base.OnRender(dc);
                return;
            }

            Point? StartPoint = null;
            Point? EndPoint = null;

            for (int index = 0; index < InternalChildren.Count; index++)
            {
                UIElement CurChhild = this.Children[index];
                Vector CurV = VisualTreeHelper.GetOffset(CurChhild);

                if (index == 0)
                    StartPoint = new Point(CurV.X + CurChhild.RenderSize.Width / 2, CurV.Y + CurChhild.RenderSize.Height / 2);
                else
                    EndPoint = new Point(CurV.X + CurChhild.RenderSize.Width / 2, CurV.Y + CurChhild.RenderSize.Height / 2);

                if (StartPoint != null && EndPoint != null)
                {
                    dc.DrawLine(new Pen(LineBrush, 1.0), StartPoint.Value, EndPoint.Value);
                    StartPoint = EndPoint;
                }
            } 
        }
        */

        // 由LineSegment连接相邻两点并最终构成Path
        protected override void OnRender(DrawingContext dc)
        {
            if (InternalChildren.Count < 2)
            {
                base.OnRender(dc);
                return;
            }

            PathSegmentCollection segmentCollection = new PathSegmentCollection();
            PathFigure pathFigure = new PathFigure() { Segments = segmentCollection }; 

            for (int index = 0; index < InternalChildren.Count; index++)
            {
                UIElement CurChhild = this.Children[index];
                Vector CurV = VisualTreeHelper.GetOffset(CurChhild);

                if (index == 0)
                    pathFigure.StartPoint = new Point(CurV.X + CurChhild.RenderSize.Width / 2, CurV.Y + CurChhild.RenderSize.Height / 2);
                else
                    segmentCollection.Add(new LineSegment() { Point = new Point(CurV.X + CurChhild.RenderSize.Width / 2, CurV.Y + CurChhild.RenderSize.Height / 2) });
            }
 
            PathGeometry pathGeometry = new PathGeometry() { Figures = new PathFigureCollection() { pathFigure } };
            dc.DrawGeometry(Brushes.Transparent, new Pen(LineBrush, 1.0), pathGeometry);
        }
开发者ID:huangjia2107,项目名称:MyControls,代码行数:57,代码来源:PolylineGrid.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Media.Pen类代码示例发布时间:2022-05-26
下一篇:
C# Media.PathFigure类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap