public static PathGeometry RemoveDegeneratePoints(System.Windows.Media.Geometry geometry)
        {
            if (geometry == null)
            {
                return((PathGeometry)null);
            }
            PathGeometry pathGeometry1 = new PathGeometry();

            pathGeometry1.AddGeometry(geometry);
            PathGeometry pathGeometry2 = geometry as PathGeometry;

            if (pathGeometry2 != null)
            {
                pathGeometry1.FillRule = pathGeometry2.FillRule;
            }
            for (int index = 0; index < pathGeometry1.Figures.Count; ++index)
            {
                PathFigure pathFigure = pathGeometry1.Figures[index];
                if (pathFigure.IsFrozen)
                {
                    pathFigure = pathFigure.Clone();
                    pathGeometry1.Figures[index] = pathFigure;
                }
                PathConversionHelper.ReplacePolySegments(pathFigure.Segments);
                bool removeInvisible = true;
                PathConversionHelper.RemoveDegenerateSegments(pathFigure, removeInvisible);
                if (pathFigure.Segments.Count == 0)
                {
                    pathGeometry1.Figures.RemoveAt(index--);
                }
            }
            return(pathGeometry1);
        }
Beispiel #2
0
        public override object Clone()
        {
            NTriangle clonedFigure = base.Clone() as NTriangle;

            clonedFigure.PathFigure          = PathFigure.Clone();
            clonedFigure.PathFigure.IsClosed = true;
            clonedFigure.line1 = line1.Clone();
            clonedFigure.line2 = line2.Clone();
            return(clonedFigure);
        }
        private static PathGeometry SimplifyGeometry(System.Windows.Media.Geometry geometry, bool removeSmoothJoin, bool removeInvisible)
        {
            PathGeometry pathGeometry = new PathGeometry();

            pathGeometry.AddGeometry(geometry);
            for (int index = 0; index < pathGeometry.Figures.Count; ++index)
            {
                PathFigure pathFigure = pathGeometry.Figures[index];
                if (pathFigure.IsFrozen)
                {
                    pathFigure = pathFigure.Clone();
                    pathGeometry.Figures[index] = pathFigure;
                }
                PathConversionHelper.ReplacePolySegments(pathFigure.Segments);
                PathConversionHelper.RemoveDegenerateSegments(pathFigure, removeInvisible);
                if (removeInvisible && pathFigure.Segments.Count == 0)
                {
                    pathGeometry.Figures.RemoveAt(index--);
                }
            }
            foreach (PathFigure pathFigure in pathGeometry.Figures)
            {
                for (int index = 0; index < pathFigure.Segments.Count; ++index)
                {
                    PathSegment pathSegment = pathFigure.Segments[index];
                    object      obj1        = pathSegment.ReadLocalValue(PathSegment.IsStrokedProperty);
                    if (obj1 is bool && (bool)obj1)
                    {
                        pathSegment.ClearValue(PathSegment.IsStrokedProperty);
                    }
                    if (removeSmoothJoin)
                    {
                        object obj2 = pathSegment.ReadLocalValue(PathSegment.IsSmoothJoinProperty);
                        if (obj2 is bool && (bool)obj2)
                        {
                            pathSegment.ClearValue(PathSegment.IsSmoothJoinProperty);
                        }
                    }
                }
            }
            return(pathGeometry);
        }