예제 #1
0
        private static bool IsCompositeOrNonDefaultValue <T>(DocumentCompositeNode compositeNode, IPropertyId propertyKey, T defaultValue)
        {
            T t = defaultValue;

            PathGeometrySerializationHelper.PropertyValueKind primitiveValue = PathGeometrySerializationHelper.GetPrimitiveValue <T>(compositeNode, propertyKey, ref t);
            if (primitiveValue == PathGeometrySerializationHelper.PropertyValueKind.Composite)
            {
                return(true);
            }
            if (primitiveValue == PathGeometrySerializationHelper.PropertyValueKind.Primitive && !object.Equals(t, defaultValue))
            {
                return(true);
            }
            return(false);
        }
예제 #2
0
 private static bool GetSimpleSegmentAsString(DocumentCompositeNode simpleSegmentNode, StringBuilder stringBuilder, char symbol, params IPropertyId[] pointProperties)
 {
     stringBuilder.Append(' ');
     stringBuilder.Append(symbol);
     for (int i = 0; i < (int)pointProperties.Length; i++)
     {
         Point point = new Point();
         if (PathGeometrySerializationHelper.GetPrimitiveValue <Point>(simpleSegmentNode, pointProperties[i], ref point) == PathGeometrySerializationHelper.PropertyValueKind.Composite)
         {
             return(false);
         }
         if (i > 0)
         {
             stringBuilder.Append(' ');
         }
         PointSerializationHelper.AppendPoint(stringBuilder, point);
     }
     return(true);
 }
예제 #3
0
        private static bool GetArcSegmentAsString(DocumentCompositeNode arcSegmentNode, StringBuilder stringBuilder)
        {
            Size           size           = new Size();
            double         num            = 0;
            bool           flag           = false;
            SweepDirection sweepDirection = SweepDirection.Counterclockwise;
            Point          point          = new Point();

            if (PathGeometrySerializationHelper.GetPrimitiveValue <Size>(arcSegmentNode, PathMetadata.ArcSegmentSizeProperty, ref size) == PathGeometrySerializationHelper.PropertyValueKind.Composite || PathGeometrySerializationHelper.GetPrimitiveValue <double>(arcSegmentNode, PathMetadata.ArcSegmentRotationAngleProperty, ref num) == PathGeometrySerializationHelper.PropertyValueKind.Composite || PathGeometrySerializationHelper.GetPrimitiveValue <bool>(arcSegmentNode, PathMetadata.ArcSegmentIsLargeArcProperty, ref flag) == PathGeometrySerializationHelper.PropertyValueKind.Composite || PathGeometrySerializationHelper.GetPrimitiveValue <SweepDirection>(arcSegmentNode, PathMetadata.ArcSegmentSweepDirectionProperty, ref sweepDirection) == PathGeometrySerializationHelper.PropertyValueKind.Composite || PathGeometrySerializationHelper.GetPrimitiveValue <Point>(arcSegmentNode, PathMetadata.ArcSegmentPointProperty, ref point) == PathGeometrySerializationHelper.PropertyValueKind.Composite)
            {
                return(false);
            }
            StringBuilder stringBuilder1 = stringBuilder;

            object[] width = new object[] { size.Width, size.Height, num, null, null };
            width[3] = (flag ? '1' : '0');
            width[4] = (sweepDirection == SweepDirection.Clockwise ? '1' : '0');
            stringBuilder1.AppendFormat(" A{0:G8},{1:G8},{2:G8},{3},{4},", width);
            PointSerializationHelper.AppendPoint(stringBuilder, point);
            return(true);
        }
예제 #4
0
        private static string GetPathGeometryAsString(DocumentCompositeNode pathGeometryNode)
        {
            StringBuilder stringBuilder = new StringBuilder();
            Transform     transform     = null;

            PathGeometrySerializationHelper.PropertyValueKind primitiveValue = PathGeometrySerializationHelper.GetPrimitiveValue <Transform>(pathGeometryNode, PathMetadata.GeometryTransformProperty, ref transform);
            if (primitiveValue == PathGeometrySerializationHelper.PropertyValueKind.Composite || transform != null)
            {
                return(null);
            }
            FillRule fillRule = FillRule.EvenOdd;

            primitiveValue = PathGeometrySerializationHelper.GetPrimitiveValue <FillRule>(pathGeometryNode, PathMetadata.PathGeometryFillRuleProperty, ref fillRule);
            if (primitiveValue == PathGeometrySerializationHelper.PropertyValueKind.Composite)
            {
                return(null);
            }
            if (primitiveValue == PathGeometrySerializationHelper.PropertyValueKind.Primitive && fillRule != FillRule.EvenOdd)
            {
                stringBuilder.Append("F1 ");
            }
            DocumentNode item = pathGeometryNode.Properties[PathMetadata.PathGeometryFiguresProperty];

            if (item != null)
            {
                DocumentCompositeNode documentCompositeNode = item as DocumentCompositeNode;
                if (documentCompositeNode == null)
                {
                    return(null);
                }
                if (!PathGeometrySerializationHelper.GetPathFigureCollectionAsString(documentCompositeNode, stringBuilder))
                {
                    return(null);
                }
            }
            return(stringBuilder.ToString());
        }
예제 #5
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);
        }