Example #1
0
        private static bool GetPathFigureAsString(DocumentNode pathFigureNode, StringBuilder stringBuilder)
        {
            bool                  flag;
            bool                  flag1;
            StringBuilder         stringBuilder1;
            DocumentCompositeNode documentCompositeNode = pathFigureNode as DocumentCompositeNode;

            if (documentCompositeNode == null)
            {
                return(false);
            }
            if (PathGeometrySerializationHelper.IsCompositeOrNonDefaultValue <bool>(documentCompositeNode, PathMetadata.PathFigureIsFilledProperty, true))
            {
                return(false);
            }
            Point point = new Point();

            if (PathGeometrySerializationHelper.GetPrimitiveValue <Point>(documentCompositeNode, PathMetadata.PathFigureStartPointProperty, ref point) == PathGeometrySerializationHelper.PropertyValueKind.Composite)
            {
                return(false);
            }
            stringBuilder.Append('M');
            PointSerializationHelper.AppendPoint(stringBuilder, point);
            DocumentNode item = documentCompositeNode.Properties[PathMetadata.PathFigureSegmentsProperty];

            if (item != null)
            {
                DocumentCompositeNode documentCompositeNode1 = item as DocumentCompositeNode;
                if (documentCompositeNode1 == null)
                {
                    return(false);
                }
                using (IEnumerator <DocumentNode> enumerator = documentCompositeNode1.Children.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        if (PathGeometrySerializationHelper.GetPathSegmentAsString(enumerator.Current, stringBuilder))
                        {
                            continue;
                        }
                        flag1 = false;
                        return(flag1);
                    }
                    flag = false;
                    if (PathGeometrySerializationHelper.GetPrimitiveValue <bool>(documentCompositeNode, PathMetadata.PathFigureIsClosedProperty, ref flag) == PathGeometrySerializationHelper.PropertyValueKind.Composite)
                    {
                        return(false);
                    }
                    if (flag)
                    {
                        stringBuilder1 = stringBuilder.Append(" z");
                    }
                    return(true);
                }
                return(flag1);
            }
            flag = false;
            if (PathGeometrySerializationHelper.GetPrimitiveValue <bool>(documentCompositeNode, PathMetadata.PathFigureIsClosedProperty, ref flag) == PathGeometrySerializationHelper.PropertyValueKind.Composite)
            {
                return(false);
            }
            if (flag)
            {
                stringBuilder1 = stringBuilder.Append(" z");
            }
            return(true);
        }
Example #2
0
        private static bool GetPathSegmentAsString(DocumentNode pathSegmentNode, StringBuilder stringBuilder)
        {
            DocumentCompositeNode documentCompositeNode = pathSegmentNode as DocumentCompositeNode;

            if (documentCompositeNode == null)
            {
                return(false);
            }
            if (pathSegmentNode.TypeResolver.ResolveProperty(PathMetadata.PathSegmentIsStrokedProperty) != null && PathGeometrySerializationHelper.IsCompositeOrNonDefaultValue <bool>(documentCompositeNode, PathMetadata.PathSegmentIsStrokedProperty, true))
            {
                return(false);
            }
            if (pathSegmentNode.TypeResolver.ResolveProperty(PathMetadata.PathSegmentIsSmoothJoinProperty) != null && PathGeometrySerializationHelper.IsCompositeOrNonDefaultValue <bool>(documentCompositeNode, PathMetadata.PathSegmentIsSmoothJoinProperty, false))
            {
                return(false);
            }
            if (PlatformTypes.ArcSegment.IsAssignableFrom(documentCompositeNode.Type))
            {
                return(PathGeometrySerializationHelper.GetArcSegmentAsString(documentCompositeNode, stringBuilder));
            }
            if (PlatformTypes.LineSegment.IsAssignableFrom(documentCompositeNode.Type))
            {
                IPropertyId[] lineSegmentPointProperty = new IPropertyId[] { PathMetadata.LineSegmentPointProperty };
                return(PathGeometrySerializationHelper.GetSimpleSegmentAsString(documentCompositeNode, stringBuilder, 'L', lineSegmentPointProperty));
            }
            if (PlatformTypes.QuadraticBezierSegment.IsAssignableFrom(documentCompositeNode.Type))
            {
                IPropertyId[] quadraticBezierSegmentPoint1Property = new IPropertyId[] { PathMetadata.QuadraticBezierSegmentPoint1Property, PathMetadata.QuadraticBezierSegmentPoint2Property };
                return(PathGeometrySerializationHelper.GetSimpleSegmentAsString(documentCompositeNode, stringBuilder, 'Q', quadraticBezierSegmentPoint1Property));
            }
            if (PlatformTypes.BezierSegment.IsAssignableFrom(documentCompositeNode.Type))
            {
                IPropertyId[] bezierSegmentPoint1Property = new IPropertyId[] { PathMetadata.BezierSegmentPoint1Property, PathMetadata.BezierSegmentPoint2Property, PathMetadata.BezierSegmentPoint3Property };
                return(PathGeometrySerializationHelper.GetSimpleSegmentAsString(documentCompositeNode, stringBuilder, 'C', bezierSegmentPoint1Property));
            }
            if (PlatformTypes.PolyLineSegment.IsAssignableFrom(documentCompositeNode.Type))
            {
                return(PathGeometrySerializationHelper.GetPolySegmentAsString(documentCompositeNode, stringBuilder, 'L', PathMetadata.PolyLineSegmentPointsProperty));
            }
            if (PlatformTypes.PolyQuadraticBezierSegment.IsAssignableFrom(documentCompositeNode.Type))
            {
                return(PathGeometrySerializationHelper.GetPolySegmentAsString(documentCompositeNode, stringBuilder, 'Q', PathMetadata.PolyQuadraticBezierSegmentPointsProperty));
            }
            if (!PlatformTypes.PolyBezierSegment.IsAssignableFrom(documentCompositeNode.Type))
            {
                return(false);
            }
            return(PathGeometrySerializationHelper.GetPolySegmentAsString(documentCompositeNode, stringBuilder, 'C', PathMetadata.PolyBezierSegmentPointsProperty));
        }