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


C# Media.PathGeometry类代码示例

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


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


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