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


C# Geometry.ToString方法代码示例

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


在下文中一共展示了Geometry.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Copy

    internal static Geometry Copy(Geometry g) {
      if (g == null) return null;

      RectangleGeometry rg = g as RectangleGeometry;
      if (rg != null) {
        return new RectangleGeometry() { Rect = rg.Bounds, RadiusX = rg.RadiusX, RadiusY = rg.RadiusY, Transform = rg.Transform };
      }
      EllipseGeometry eg = g as EllipseGeometry;
      if (eg != null) {
        return new EllipseGeometry() { Center = eg.Center, RadiusX = eg.RadiusX, RadiusY = eg.RadiusY, Transform = eg.Transform };
      }
      LineGeometry lg = g as LineGeometry;
      if (lg != null) {
        return new LineGeometry() { StartPoint = lg.StartPoint, EndPoint = lg.EndPoint, Transform = lg.Transform };
      }
      PathGeometry pg = g as PathGeometry;
      if (pg != null) {
        if (!Geo.PathGeometryHasFigures(pg)) {
          return new RectangleGeometry() { Rect = pg.Bounds, RadiusX = 0, RadiusY = 0, Transform = pg.Transform };
        } else {
          PathGeometry pg2 = new PathGeometry();
          pg2.FillRule = pg.FillRule;
          pg2.Figures = new PathFigureCollection();  // required for Geo.PathGeometryHasFigures to work
          foreach (PathFigure pf in pg.Figures) {
            PathFigure pf2 = new PathFigure();
            pf2.StartPoint = pf.StartPoint;
            foreach (PathSegment ps in pf.Segments) {
              pf2.Segments.Add(Copy(ps));
            }
            pf2.IsClosed = pf.IsClosed;
            pf2.IsFilled = pf.IsFilled;
            pg2.Figures.Add(pf2);
          }
          pg2.Transform = pg.Transform;
          return pg2;
        }
      }
      GeometryGroup gg = g as GeometryGroup;
      if (gg != null) {
        GeometryGroup gg2 = new GeometryGroup();
        gg2.FillRule = gg.FillRule;
        foreach (Geometry x in gg.Children) {
          gg2.Children.Add(Copy(x));
        }
        gg2.Transform = gg.Transform;
        return gg2;
      }
      Diagram.Error("Copying an unknown kind of Geometry: " + g.ToString());
      return null;
    }
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:50,代码来源:Adornment.cs

示例2: ExportGeometry

        private static void ExportGeometry(FixedContentEditor editor, FixedContentEditor filledEditor, Geometry geometry, bool isConnection = false)
        {
            // We need two editors because there might be filled and not filled figures.
#if WPF
            var pathGeometry = geometry as PathGeometry;
#else
            var pathGeometry = GeometryParser.GetGeometry(geometry.ToString()) as PathGeometry;
#endif
            if (pathGeometry != null)
            {
                var path = new G.PathGeometry();
                var filledPath = new G.PathGeometry();
                for (int i = 0; i < pathGeometry.Figures.Count; i++)
                {
                    var figure = pathGeometry.Figures[i];
                    var newFigure = new G.PathFigure();
                    newFigure.StartPoint = figure.StartPoint;
                    newFigure.IsClosed = figure.IsClosed;
                    foreach (var segment in figure.Segments)
                    {
                        var arc = segment as ArcSegment;
                        if (arc != null)
                        {
                            var newS = new G.ArcSegment();
                            newS.Point = arc.Point;
                            newS.RadiusX = arc.Size.Width;
                            newS.RadiusY = arc.Size.Height;
                            newS.RotationAngle = arc.RotationAngle;
                            // why new enum ?
                            if (arc.SweepDirection == SweepDirection.Clockwise)
                                newS.SweepDirection = G.SweepDirection.Clockwise;
                            else
                                newS.SweepDirection = G.SweepDirection.Counterclockwise;
                            newS.IsLargeArc = arc.IsLargeArc;
                            newFigure.Segments.Add(newS);
                            continue;
                        }

                        var bezier = segment as BezierSegment;
                        if (bezier != null)
                        {
                            var newS = new G.BezierSegment();
                            newS.Point1 = bezier.Point1;
                            newS.Point2 = bezier.Point2;
                            newS.Point3 = bezier.Point3;
                            newFigure.StartPoint = newFigure.StartPoint;
                            newFigure.Segments.Add(newS);
                            continue;
                        }

                        var polyLine = segment as PolyLineSegment;
                        if (polyLine != null)
                        {
                            foreach (var point in polyLine.Points)
                            {
                                var newS = new G.LineSegment();
                                newS.Point = point;
                                newFigure.Segments.Add(newS);
                            }
                            continue;
                        }

                        var line = segment as LineSegment;
                        if (line != null)
                        {
                            var newS = new G.LineSegment();
                            newS.Point = line.Point;
                            newFigure.Segments.Add(newS);
                            continue;
                        }

                        var quadraticBezier = segment as QuadraticBezierSegment;
                        if (quadraticBezier != null)
                        {
                            var newS = new G.QuadraticBezierSegment();
                            newS.Point1 = quadraticBezier.Point1;
                            newS.Point2 = quadraticBezier.Point2;
                            newFigure.Segments.Add(newS);
                            continue;
                        }
                    }
#if SILVERLIGHT
                    if (isConnection)
                    {
                        var realGeometry = geometry as PathGeometry;
                        if (realGeometry != null && realGeometry.Figures.Count > i)
                        {
                            if (realGeometry.Figures[i].IsFilled)
                                filledPath.Figures.Add(newFigure);
                            else
                                path.Figures.Add(newFigure);
                            continue;
                        }
                    }
#endif
                    if (figure.IsFilled)
                        filledPath.Figures.Add(newFigure);
                    else
                        path.Figures.Add(newFigure);
                }
//.........这里部分代码省略.........
开发者ID:CJMarsland,项目名称:xaml-sdk,代码行数:101,代码来源:ExportHelper.cs

示例3: FindMatchingPath

 private static bool FindMatchingPath(Geometry menuItemPathData, Path p)
 {
     return p.Data.ToString() == menuItemPathData.ToString();
 }
开发者ID:netintellect,项目名称:PluralsightSpaJumpStartFinal,代码行数:4,代码来源:CommandsViewModel.cs


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