當前位置: 首頁>>代碼示例>>C#>>正文


C# Shapes.Path類代碼示例

本文整理匯總了C#中System.Windows.Shapes.Path的典型用法代碼示例。如果您正苦於以下問題:C# Path類的具體用法?C# Path怎麽用?C# Path使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Path類屬於System.Windows.Shapes命名空間,在下文中一共展示了Path類的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: WpfArc

        public WpfArc(IArc arc)
        {
            _xarc = arc;

            _fillBrush = new SolidColorBrush(_xarc.Fill.ToNativeColor());
            _fillBrush.Freeze();
            _strokeBrush = new SolidColorBrush(_xarc.Stroke.ToNativeColor());
            _strokeBrush.Freeze();

            _path = new Path();
            _path.Tag = this;
            _path.Fill = _fillBrush;
            _path.Stroke = _strokeBrush;
            _path.StrokeThickness = arc.StrokeThickness;
            _pg = new PathGeometry();
            _pf = new PathFigure();
            _pf.IsFilled = arc.IsFilled;
            _pf.IsClosed = arc.IsClosed;
            _start = new Point();
            _as = new ArcSegment();
            SetArcSegment(_as, arc, out _start);
            _pf.StartPoint = _start;
            _pf.Segments.Add(_as);
            _pg.Figures.Add(_pf);
            _path.Data = _pg;

            Native = _path;
        }
開發者ID:monocraft,項目名稱:RxCanvas,代碼行數:28,代碼來源:Wpf.cs

示例3: Draw

        public void Draw(EasingFunctionBase easingFunction)
        {
            canvas1.Children.Clear();


            PathSegmentCollection pathSegments = new PathSegmentCollection();

            for (double i = 0; i < 1; i += _samplingInterval)
            {
                double x = i * canvas1.Width;
                double y = easingFunction.Ease(i) * canvas1.Height;

                var segment = new LineSegment();
                segment.Point = new Point(x, y);

                pathSegments.Add(segment);

            }
            var p = new Path();
            p.Stroke = new SolidColorBrush(Colors.Black);
            p.StrokeThickness = 3;
            PathFigureCollection figures = new PathFigureCollection();
            figures.Add(new PathFigure() { Segments = pathSegments });
            p.Data = new PathGeometry() { Figures = figures };
            canvas1.Children.Add(p);
        }
開發者ID:CNinnovation,項目名稱:WPFWorkshopFeb2016,代碼行數:26,代碼來源:EasingChartControl.xaml.cs

示例4: GraphmapsEdge

        public GraphmapsEdge(Edge edge, FrameworkElement labelFrameworkElement) {
            Edge = edge;
            CurvePath = new Path {
                Data = GetICurveWpfGeometry(edge.GeometryEdge.Curve),
                Tag = this
            };

            EdgeAttrClone = edge.Attr.Clone();

            if (edge.Attr.ArrowAtSource)
                SourceArrowHeadPath = new Path {
                    Data = DefiningSourceArrowHead(),
                    Tag = this
                };
            if (edge.Attr.ArrowAtTarget)
                TargetArrowHeadPath = new Path {
                    Data = DefiningTargetArrowHead(Edge.GeometryEdge.EdgeGeometry, PathStrokeThickness),
                    Tag = this
                };

            SetPathStroke();

            if (labelFrameworkElement != null) {
                LabelFrameworkElement = labelFrameworkElement;
                Common.PositionFrameworkElement(LabelFrameworkElement, edge.Label.Center, 1);
            }
            edge.Attr.VisualsChanged += (a, b) => Invalidate();
            
        }
開發者ID:WenzCao,項目名稱:automatic-graph-layout,代碼行數:29,代碼來源:GraphmapsEdge.cs

示例5: Initialize

        protected void Initialize()
        {
            System.IO.DirectoryInfo directoryInfo = new System.IO.DirectoryInfo(source);
            System.IO.FileInfo[] filesInfo = directoryInfo.GetFiles();
            var files = filesInfo.OrderBy(f => f.FullName);//sort alphabetically
            //foreach (System.IO.FileInfo info in filesInfo)
            foreach(System.IO.FileInfo info in files)
            {
                //System.Diagnostics.Debug.WriteLine("Reading " + info.Name + "...");

                SvgReader reader = new SvgReader(info.FullName);
                //HACK: At this moment only support one Path in a template file. Ideal case is get a group of graphic object.
                var elements = reader.GetXMLElements("path");
                foreach (XElement element in elements)
                {
                    Path path = new Path();
                    path.Fill = Brushes.Black;
                    XAttribute attribute = element.Attribute(XName.Get("d"));
                    path.Data = (Geometry)new GeometryConverter().ConvertFromString(attribute.Value);//key

                    //string name = info.Name.ToLower().TrimEnd(new char[] { 'g', 'v', 's', '.' });//caused some ended with 's' interpreted wrongly.
                    string name = info.Name.ToLower().Substring(0, info.Name.Length - 4);
                    string label = GetLabel(info.Name);
                    if (label.Length > 0) name = name.Replace(label, string.Empty);

                    PathViewModel item = new PathViewModel(name, path, label);
                    this.items.Add(item);
                    break;
                }
            }//end loops
        }
開發者ID:nilmarpublio,項目名稱:jawiweb,代碼行數:31,代碼來源:PathCollection.cs

示例6: Triangle

        public Triangle()
        {
            InitializeComponent();

            l1 = new LineSegment();
            l2 = new LineSegment();

            f = new PathFigure();
            f.Segments.Add(l1);
            f.Segments.Add(l2);
            f.IsClosed = true;

            PathGeometry g = new PathGeometry();
            g.Figures.Add(f);

            Path p = new Path();
            this.SetBinding(FillProperty, new Binding("Fill") { Source = p, Mode = BindingMode.TwoWay });
            this.SetBinding(StrokeProperty, new Binding("Stroke") { Source = p, Mode = BindingMode.TwoWay });
            this.SetBinding(StrokeThicknessProperty, new Binding("StrokeThickness") { Source = p, Mode = BindingMode.TwoWay });
            p.Data = g;

            this.Fill = new SolidColorBrush(Colors.White);
            this.Stroke = new SolidColorBrush(Colors.Black);

            this.LayoutRoot.Children.Add(p);
        }
開發者ID:satomacoto,項目名稱:Silverlight-Graph,代碼行數:26,代碼來源:Triangle.xaml.cs

示例7: HologramDisplay2

        public HologramDisplay2(Hologram2 holo)
        {
            hologram2 = holo;
            InitializeComponent();
            Path PathInstance = new Path();
            PathInstance.PathId = holo.video;
            this.DataContext = PathInstance;

            myMediaElement1.LoadedBehavior = MediaState.Manual;
            myMediaElement2.LoadedBehavior = MediaState.Manual;
            myMediaElement3.LoadedBehavior = MediaState.Manual;
            myMediaElement4.LoadedBehavior = MediaState.Manual;

            myMediaElement1.MediaEnded += new RoutedEventHandler(myMediaElement1_MediaEnded);
            myMediaElement2.MediaEnded += new RoutedEventHandler(myMediaElement2_MediaEnded);
            myMediaElement3.MediaEnded += new RoutedEventHandler(myMediaElement3_MediaEnded);
            myMediaElement4.MediaEnded += new RoutedEventHandler(myMediaElement4_MediaEnded);

            myMediaElement1.MediaOpened += new RoutedEventHandler(myMediaElement1_MediaOpened);
            

            myMediaElement1.Play();
            myMediaElement2.Play();
            myMediaElement3.Play();
            myMediaElement4.Play();
            state = "play";
        }
開發者ID:Broams,項目名稱:holography,代碼行數:27,代碼來源:HologramDisplay2.xaml.cs

示例8: UpdatePath

 public void UpdatePath(Path path, Point sp, Point ep)
 {
     using (StreamGeometryContext cnt = ((StreamGeometry)(path.Data)).Open())
     {
         InternalDrawGeometry(cnt, sp, ep);
     }
 }
開發者ID:chijianfeng,項目名稱:PNManager,代碼行數:7,代碼來源:BaseAction.cs

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

示例10: SelectTest

        public void SelectTest()
        {
            PathCollection target = new PathCollection(@"E:\jawi\khots");
            //alef raw data
            string alef = "M2.8853219,14.535578L3.4452919,24.413808 6.0826619,72.682508C6.0826619,72.682508 7.8725619,70.888858 8.9450019,69.255188 10.466172,66.940318 10.546172,64.950418 11.003652,62.728038 11.362382,60.984378 11.386132,60.595648 11.238632,58.834488L8.3512919,24.397558 8.0763019,18.551618C8.3637919,18.709108,8.6375219,18.851598,8.8950119,18.977838L13.337272,21.177728 12.489822,18.840348C12.393622,18.575368 12.291082,18.294128 12.188582,18.011638 10.956152,14.616818 10.272432,11.259498 9.4512319,7.77842770000001 8.6662719,4.44610770000001 7.6188219,0.00758770000001263 7.6188219,0.00758770000001263 7.6188219,0.00758770000001263 6.8776119,-0.0311122999999874 6.1939019,0.0662877000000126 4.3165019,0.335027700000013 0.307961849999997,6.31470770000001 0.0479718499999979,7.67338770000001 0.0229718499999979,7.80212770000001 0.00797184999999793,7.93087770000001 0.00297184999999793,8.05836770000001 -0.00832815000000207,8.33959770000001 0.0129718499999979,8.63458770000001 0.0604718499999979,8.93956770000001 0.404201849999998,11.129458 1.5066519,12.998108 2.8853219,14.535528z";
            Path path = new Path();
            path.Data = (Geometry)new GeometryConverter().ConvertFromString(alef);

            PathViewModel viewModel = new PathViewModel(string.Empty, path, string.Empty);
            target.Select(viewModel);
            //check SelectedPath
            Assert.AreEqual(target.SelectedPath.Path.Data.ToString(), viewModel.Path.Data.ToString());

            //ensure always only one Item IsChecked.
            int count = 0;
            foreach (PathViewModel item in target.Items)
                if (item.IsChecked) count++;
            Assert.AreEqual(1, count);

            //select next object.
            string dot = "M3.1054696,15.75434C3.6094426,18.82793 4.5492686,23.76517 4.0869176,25.03635 3.7460606,25.97381 3.0559716,26.66627 2.4212556,27.49747 -0.2264804,30.96604 -0.6113344,35.03333 0.8220896,39.70933 2.3521336,44.70032 7.7263506,42.62043 12.616468,39.51934 15.53069,37.67069 22.65219,32.61096 24.193108,29.29988 24.278228,29.11614 24.35785,28.92865 24.432221,28.73616 23.762131,26.18129 21.683116,28.80496 21.676741,28.80866 13.716785,34.24837 5.3694746,37.5407 2.7644876,36.5195 2.1845176,36.29201 1.8942836,35.68829 2.2572636,34.40961 2.4872516,33.5984 2.9583516,32.7547 3.0645966,32.6272 4.2296596,31.21978 6.6485326,29.7861 8.1425786,28.15369 9.0814046,27.12749 9.6549996,26.02255 10.645197,25.32509 11.898881,24.44264 13.820405,24.21265 15.293827,23.55393 19.110751,21.84777 22.053346,17.22927 22.415827,13.61696 23.065668,7.1410503 19.6006,5.0074103 13.9169,1.0438703 13.15794,0.5139003 12.546472,0.0951703 11.285414,0.0151703000000001 9.9611076,-0.0685296999999999 7.9205906,0.2214103 7.9205906,0.2214103 7.9205906,0.2214103 7.8168456,3.3425003 8.2474486,5.5648803 8.7287976,8.0485003 9.8782376,9.4096803 10.368087,11.07084 10.477081,11.44082 10.553452,11.8258 10.422457,11.95954 10.287464,12.09704 9.9326076,11.96854 9.5935006,11.75455 6.9287656,10.06839 6.7901486,7.6610203 4.6721346,8.7434603 3.5073216,9.3396803 2.9713496,10.73336 2.8809796,12.64201 2.8233596,13.85944 2.8458596,14.17068 3.1054676,15.75434z M12.059248,8.3897303L11.909756,7.1123003C11.909756,7.1123003 12.745087,6.9660603 13.331431,7.0248003 14.077891,7.1010003 14.420623,7.5122803 14.86935,7.9035103 17.496086,10.19839 20.907657,11.09834 19.429234,13.39572 19.191497,13.76445 17.71095,15.29812 16.400519,16.42056 14.615988,17.94923 13.518921,18.30171 13.693787,16.38806 13.965647,13.41697 11.998626,7.8710103 12.059248,8.3897303z M9.0800296,19.17791L7.4994876,19.27421C6.7894006,19.31791 6.6677816,19.30921 6.2840516,19.19541 5.5918386,18.99042 4.7182596,18.27046 4.3830266,17.58425 4.2211606,17.25301 4.1994116,17.15302 4.1646636,16.5843L4.0872936,15.32062 5.3517266,15.24312C5.9198216,15.20812 6.0216916,15.21812 6.3701736,15.33812 7.3446216,15.67435 8.8960406,17.33176 8.9930346,17.75549 9.1320276,18.36296 9.0800346,19.17791 9.0800346,19.17791z";
            Path path2 = new Path();
            path2.Data = (Geometry)new GeometryConverter().ConvertFromString(dot);
            PathViewModel viewModel2 = new PathViewModel(string.Empty, path2, string.Empty);
            target.Select(viewModel2);
            //check SelectedPath
            Assert.AreEqual(target.SelectedPath.Path.Data.ToString(), path2.Data.ToString());

            //ensure always only one Item IsChecked.
            count = 0;
            foreach (PathViewModel item in target.Items)
                if (item.IsChecked) count++;
            Assert.AreEqual(1, count);
        }
開發者ID:nilmarpublio,項目名稱:jawiweb,代碼行數:34,代碼來源:PathCollectionTest.cs

示例11: VEdge

        public VEdge(Edge edge, FrameworkElement labelFrameworkElement) {
            Edge = edge;
            CurvePath = new Path {
                Data = GetICurveWpfGeometry(edge.GeometryEdge.Curve),
                Tag = this
            };

            EdgeAttrClone = edge.Attr.Clone();

            if (edge.Attr.ArrowAtSource)
                SourceArrowHeadPath = new Path {
                    Data = DefiningSourceArrowHead(),
                    Tag = this
                };
            if (edge.Attr.ArrowAtTarget)
                TargetArrowHeadPath = new Path {
                    Data = DefiningTargetArrowHead(Edge.GeometryEdge.EdgeGeometry, PathStrokeThickness),
                    Tag = this
                };

            SetPathStroke();

            if (labelFrameworkElement != null) {
                LabelFrameworkElement = labelFrameworkElement;
                Common.PositionFrameworkElement(LabelFrameworkElement, edge.Label.Center, 1);
            }
            edge.Attr.VisualsChanged += (a, b) => Invalidate();

            edge.IsVisibleChanged += obj => {
                foreach (var frameworkElement in FrameworkElements) {
                    frameworkElement.Visibility = edge.IsVisible ? Visibility.Visible : Visibility.Hidden;
                }
            };
        }
開發者ID:danielskowronski,項目名稱:network-max-flow-demo,代碼行數:34,代碼來源:VEdge.cs

示例12: DrawPath

        private void DrawPath(IEnumerable<Vector2> path)
        {
            if (!path.Any())
                throw new ArgumentException("Path cannot be empty.");

            var figure = new PathFigure();

            var start = path.First();
            figure.StartPoint = PointFromVector(start);

            foreach (var vector in path.Skip(1))
            {
                var point = PointFromVector(vector);
                figure.Segments.Add(new LineSegment(point, true));
            }

            var geometry = new PathGeometry();
            geometry.Figures.Add(figure);

            var pathImage = new Path()
            {
                Stroke = Brushes.Black,
                StrokeThickness = 3,
                Data = geometry
            };

            mainCanvas.Children.Add(pathImage);
        }
開發者ID:PlastecProfiles,項目名稱:ComputationalGeometry,代碼行數:28,代碼來源:MainWindow.xaml.cs

示例13: OvLine

        //to be modified

        //constructor
        public OvLine(Canvas canvas, ITextSnapshotLine itv, float bzCurvArea, OvCollection parent)
        {
            _bzCurvArea = bzCurvArea;

            lnNumber = itv.LineNumber;
            lnStart = 0.0f;
            lnTextStart = (float)Find1stChar(itv);
            //if (lnNumber == 65) System.Diagnostics.Trace.WriteLine("%%%                 REGEX: " + lnTextStart ); 
            lnEnd = (float)itv.Length;
            lnHeight = 1.0f;
            lnLength = itv.Length;
            lnColor = new System.Windows.Media.Color();                    //get the color of the textview
            lnFocus = false;

            myCanvas = canvas;
            myPath = new Path();
            myParent = parent;

            IsSeleted = false;
            

            this.myPath.MouseEnter += new System.Windows.Input.MouseEventHandler(myPath_MouseEnter);
            this.myPath.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(myPath_MouseLeftButtonDown);
            this.myPath.MouseLeave += new System.Windows.Input.MouseEventHandler(myPath_MouseLeave);

            
        }
開發者ID:mintberry,項目名稱:stackrecaller,代碼行數:30,代碼來源:OvLine.cs

示例14: Stop

 internal void Stop(Canvas field, Subway subway)
 {
     pathAnimationStoryboard.Children.Clear();
     field.Children.Remove(trainPath);
     RectangleGeometry rc = trainPath.Data as RectangleGeometry;
     trainPath.RenderTransform = null;
     travelTime = 0;
     timeOnStation = 3;
     Start = false;
     onStation = false;
     leftStation = false;
     numOfPassage = passage;
     currStationInd = 0;
     id = 0;
     Back = false;
     away = false;
     if (subway.GetRailways.ElementAt(lineNumber).GetStations.Count > 1)
     {
         if (subway.GetRailways.ElementAt(lineNumber).GetStations.ElementAt(0) != null)
         {
             Station st = subway.GetRailways.ElementAt(lineNumber).GetStations.ElementAt(0);
             rc.Rect = new Rect(st.Coordinate.X - 15, st.Coordinate.Y - 15, 30, 30);
         }
         else
         {
             trainPath = null;
         }
     }
 }
開發者ID:M0N3,項目名稱:Subway,代碼行數:29,代碼來源:Train.cs

示例15: InitializeComponent

 public void InitializeComponent()
 {
     if (!this._contentLoaded)
     {
         this._contentLoaded = true;
         Application.LoadComponent(this, new Uri("/TWC.OVP;component/Views/CaptionSettingsView.xaml", UriKind.Relative));
         this.userControl = (UserControl) base.FindName("userControl");
         this.LayoutRoot = (Grid) base.FindName("LayoutRoot");
         this.DialogBorder = (Border) base.FindName("DialogBorder");
         this.BackgroundRectangle = (Border) base.FindName("BackgroundRectangle");
         this.Gradient = (Rectangle) base.FindName("Gradient");
         this.HeaderGrid = (Grid) base.FindName("HeaderGrid");
         this.GlyphCanvas = (Canvas) base.FindName("GlyphCanvas");
         this.BoxPath = (Path) base.FindName("BoxPath");
         this.CPath1 = (Path) base.FindName("CPath1");
         this.CPath2 = (Path) base.FindName("CPath2");
         this.CheckedBoxPath = (Path) base.FindName("CheckedBoxPath");
         this.CheckedCPath1 = (Path) base.FindName("CheckedCPath1");
         this.CheckedCPath2 = (Path) base.FindName("CheckedCPath2");
         this.CaptionSettingsLayoutRoot = (Grid) base.FindName("CaptionSettingsLayoutRoot");
         this.MetaDataBackground = (Rectangle) base.FindName("MetaDataBackground");
         this.CharacterSettingsLayoutRoot = (Grid) base.FindName("CharacterSettingsLayoutRoot");
         this.FooterGrid = (Grid) base.FindName("FooterGrid");
         this.DefaultsButton = (Button) base.FindName("DefaultsButton");
         this.CloseButton = (Button) base.FindName("CloseButton");
     }
 }
開發者ID:BigBri41,項目名稱:TWCTVWindowsPhone,代碼行數:27,代碼來源:CaptionSettingsView.cs


注:本文中的System.Windows.Shapes.Path類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。