WPF SL C# 后台画线

记录备份一下。

xmal:

 <Path Data="M102.03442,598.79645 L105.22962,597.78918 L106.78825,600.42358 C106.78825,600.42358 108.51028,595.74304 110.21724,593.60419 C112.00967,591.35822 114.89314,591.42316 114.89314,591.42316 C114.89314,591.42316 112.67844,593.42645 111.93174,594.44464 C110.7449,596.06293 107.15683,604.13837 107.15683,604.13837 z" 
                    					Fill="#FF333333" FlowDirection="LeftToRight" Stretch="Fill"/>  

对应的C#代码:

        private Path GetPath()
        {
            var path = new Path { Fill = new SolidColorBrush(Color.FromArgb(255, 51, 51, 51));, FlowDirection = FlowDirection.LeftToRight, Stretch = Stretch.Fill };
            var pathFigure = new PathFigure { StartPoint = new Point(102.03442, 598.79645) };
            var l1 = new LineSegment { Point = new Point(105.22962, 597.78918) };
            var l2 = new LineSegment { Point = new Point(106.78825, 600.42358) };
            var c1 = new PolyBezierSegment();
            c1.Points.Add(new Point(106.78825, 600.42358));
            c1.Points.Add(new Point(108.51028, 595.74304));
            c1.Points.Add(new Point(110.21724, 593.60419));
            var c2 = new PolyBezierSegment();
            c1.Points.Add(new Point(112.00967, 591.35822));
            c1.Points.Add(new Point(114.89314, 591.42316));
            c1.Points.Add(new Point(114.89314, 591.42316));
            var c3 = new PolyBezierSegment();
            c1.Points.Add(new Point(114.89314, 591.42316));
            c1.Points.Add(new Point(112.67844, 593.42645));
            c1.Points.Add(new Point(111.93174, 594.44464));
            var c4 = new PolyBezierSegment();
            c1.Points.Add(new Point(110.7449, 596.06293));
            c1.Points.Add(new Point(107.15683, 604.13837));
            c1.Points.Add(new Point(107.15683, 604.13837));
            pathFigure.Segments.Add(l1);
            pathFigure.Segments.Add(l2);
            pathFigure.Segments.Add(c1);
            pathFigure.Segments.Add(c2);
            pathFigure.Segments.Add(c3);
            pathFigure.Segments.Add(c4);
            var pathGeometry = new PathGeometry();
            pathGeometry.Figures.Add(pathFigure);
            path.Data = pathGeometry;
            return path;
        }



其他相关文章链接1:http://blog.csdn.net/wwei466/article/details/3936684


你可能感兴趣的:(WPF SL C# 后台画线)