예제 #1
0
        public static string SerializeDoubleCollectionAsAttribute(DocumentCompositeNode compositeNode)
        {
            string        str;
            StringBuilder stringBuilder = new StringBuilder();

            using (IEnumerator <DocumentNode> enumerator = compositeNode.Children.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    DocumentPrimitiveNode current = enumerator.Current as DocumentPrimitiveNode;
                    if (current != null)
                    {
                        double value = current.GetValue <double>();
                        if (stringBuilder.Length > 0)
                        {
                            stringBuilder.Append(' ');
                        }
                        CultureInfo invariantCulture = CultureInfo.InvariantCulture;
                        object[]    objArray         = new object[] { value };
                        stringBuilder.AppendFormat(invariantCulture, "{0:G8}", objArray);
                    }
                    else
                    {
                        str = null;
                        return(str);
                    }
                }
                return(stringBuilder.ToString());
            }
            return(str);
        }
예제 #2
0
        private void UpdatePropertyValues(DocumentCompositeNode compositeNode, SamplePropertyTypeOrFormatChanged change)
        {
            if (compositeNode == null)
            {
                return;
            }
            SampleProperty sampleProperty = change.SampleProperty;

            if (compositeNode.Type == sampleProperty.DeclaringSampleType)
            {
                if (change.OldType == SampleBasicType.Image)
                {
                    DocumentPrimitiveNode documentPrimitiveNode = compositeNode.Properties[(IPropertyId)sampleProperty] as DocumentPrimitiveNode;
                    if (documentPrimitiveNode != null)
                    {
                        string relativePath = documentPrimitiveNode.GetValue <string>();
                        sampleProperty.DeclaringDataSet.UnuseAssetFile(relativePath);
                    }
                }
                this.CreatePropertyValue(compositeNode, sampleProperty);
                ++this.changeCount;
            }
            for (int index = 0; index < compositeNode.Properties.Count; ++index)
            {
                this.UpdatePropertyValues(compositeNode.Properties[index] as DocumentCompositeNode, change);
            }
            if (!compositeNode.SupportsChildren)
            {
                return;
            }
            for (int index = 0; index < compositeNode.Children.Count; ++index)
            {
                this.UpdatePropertyValues(compositeNode.Children[index] as DocumentCompositeNode, change);
            }
        }
예제 #3
0
        public static string GetSourceFilePath(DocumentCompositeNode designDataNode)
        {
            string value = null;

            try
            {
                IProperty             member = (IProperty)designDataNode.Type.GetMember(MemberType.LocalProperty, "Source", MemberAccessTypes.Public);
                DocumentPrimitiveNode item   = designDataNode.Properties[member] as DocumentPrimitiveNode;
                if (item != null)
                {
                    value = item.GetValue <string>();
                    Uri uri = designDataNode.Context.MakeDesignTimeUri(new Uri(value, UriKind.RelativeOrAbsolute));
                    value = uri.LocalPath;
                }
                else
                {
                    return(null);
                }
            }
            catch (InvalidOperationException invalidOperationException)
            {
            }
            catch (IOException oException)
            {
            }
            return(value);
        }
예제 #4
0
        private T GetPrimitiveProperty <T>(DocumentCompositeNode docNode, IPropertyId property, T defaultValue)
        {
            DocumentPrimitiveNode documentPrimitiveNode = docNode.Properties[property] as DocumentPrimitiveNode;

            if (documentPrimitiveNode == null)
            {
                return(defaultValue);
            }
            return(documentPrimitiveNode.GetValue <T>());
        }
예제 #5
0
        internal bool IsStyleControlParts(StyleAsset styleAsset)
        {
            DocumentPrimitiveNode documentPrimitiveNode = ((DocumentCompositeNode)styleAsset.ResourceModel.ValueNode).Properties[DesignTimeProperties.IsControlPartProperty] as DocumentPrimitiveNode;

            if (documentPrimitiveNode != null)
            {
                return(documentPrimitiveNode.GetValue <bool>());
            }
            return(false);
        }
예제 #6
0
        private static bool GetPolySegmentAsString(DocumentCompositeNode polySegmentNode, StringBuilder stringBuilder, char symbol, IPropertyId pointsProperty)
        {
            DocumentPrimitiveNode item = polySegmentNode.Properties[pointsProperty] as DocumentPrimitiveNode;

            if (item == null)
            {
                return(false);
            }
            PointCollection value = item.GetValue <PointCollection>();

            stringBuilder.Append(' ');
            stringBuilder.Append(symbol);
            stringBuilder.Append(PointSerializationHelper.GetPointCollectionAsString(value));
            return(true);
        }
예제 #7
0
        private string GetBindingRelativeSource(DataBindingProcessingContext context)
        {
            DocumentCompositeNode documentCompositeNode = context.DocumentCompositeNode.Properties[BindingSceneNode.RelativeSourceProperty] as DocumentCompositeNode;

            if (documentCompositeNode == null || documentCompositeNode.Properties.Count != 1)
            {
                return((string)null);
            }
            DocumentPrimitiveNode documentPrimitiveNode = documentCompositeNode.Properties[0] as DocumentPrimitiveNode;

            if (documentPrimitiveNode == null || !PlatformTypes.RelativeSourceMode.IsAssignableFrom((ITypeId)documentPrimitiveNode.Type))
            {
                return((string)null);
            }
            return(documentPrimitiveNode.GetValue <string>());
        }
예제 #8
0
        private static PathGeometrySerializationHelper.PropertyValueKind GetPrimitiveValue <T>(DocumentCompositeNode compositeNode, IPropertyId propertyKey, ref T primitiveValue)
        {
            DocumentNode item = compositeNode.Properties[propertyKey];

            if (item == null)
            {
                return(PathGeometrySerializationHelper.PropertyValueKind.Unset);
            }
            DocumentPrimitiveNode documentPrimitiveNode = item as DocumentPrimitiveNode;

            if (documentPrimitiveNode == null)
            {
                return(PathGeometrySerializationHelper.PropertyValueKind.Composite);
            }
            primitiveValue = documentPrimitiveNode.GetValue <T>();
            return(PathGeometrySerializationHelper.PropertyValueKind.Primitive);
        }
        public DataStorePropertyEntry FindMatchDataStorePropertyEntry(SceneNodeProperty property, string propertyName)
        {
            if (property == null)
            {
                return((DataStorePropertyEntry)null);
            }
            bool         isMixed             = false;
            DocumentNode valueAsDocumentNode = property.GetLocalValueAsDocumentNode(false, out isMixed);

            if (valueAsDocumentNode != null && property.SceneNodeObjectSet.ViewModel.IsExternal(valueAsDocumentNode))
            {
                return((DataStorePropertyEntry)null);
            }
            BindingSceneNode bindingSceneNode = property.SceneNodeObjectSet.ViewModel.GetSceneNode(valueAsDocumentNode) as BindingSceneNode;

            if (bindingSceneNode == null)
            {
                return((DataStorePropertyEntry)null);
            }
            string path                = propertyName ?? bindingSceneNode.Path;
            string dataStore           = (string)null;
            DocumentCompositeNode node = bindingSceneNode.Source as DocumentCompositeNode;

            if (node != null && PlatformTypes.StaticResource.IsAssignableFrom((ITypeId)node.Type))
            {
                DocumentPrimitiveNode documentPrimitiveNode = ResourceNodeHelper.GetResourceKey(node) as DocumentPrimitiveNode;
                if (documentPrimitiveNode != null)
                {
                    dataStore = documentPrimitiveNode.GetValue <string>();
                }
            }
            return(Enumerable.FirstOrDefault <DataStorePropertyEntry>(Enumerable.Where <DataStorePropertyEntry>((IEnumerable <DataStorePropertyEntry>) this.Properties, (Func <DataStorePropertyEntry, bool>)(entry =>
            {
                if (entry.Name == path)
                {
                    return entry.DataSetName == dataStore;
                }
                return false;
            }))));
        }
예제 #10
0
        public static bool IsDataSource(DocumentNode possibleDataSource)
        {
            bool flag = false;

            if (typeof(DataSourceProvider).IsAssignableFrom(possibleDataSource.TargetType))
            {
                flag = true;
            }
            else
            {
                DocumentCompositeNode documentCompositeNode;
                if ((documentCompositeNode = possibleDataSource as DocumentCompositeNode) != null)
                {
                    DocumentPrimitiveNode documentPrimitiveNode = documentCompositeNode.Properties[DesignTimeProperties.IsDataSourceProperty] as DocumentPrimitiveNode;
                    if (documentPrimitiveNode != null && documentPrimitiveNode.TargetType == typeof(bool))
                    {
                        flag = documentPrimitiveNode.GetValue <bool>();
                    }
                }
            }
            return(flag);
        }
예제 #11
0
        private void PostProcessDocumentNodeFromEditProxyRecursive(Microsoft.Expression.DesignModel.DocumentModel.DocumentNode node, List <Microsoft.Expression.DesignModel.DocumentModel.DocumentNode> originals, List <Microsoft.Expression.DesignModel.DocumentModel.DocumentNode> replacements)
        {
            DocumentCompositeNode documentCompositeNode = node as DocumentCompositeNode;

            if (documentCompositeNode != null)
            {
                DocumentPrimitiveNode documentPrimitiveNode = documentCompositeNode.Properties[BaseFrameworkElement.TagProperty] as DocumentPrimitiveNode;
                if (documentPrimitiveNode != null && PlatformTypes.Int32.IsAssignableFrom((ITypeId)documentPrimitiveNode.Type))
                {
                    int index = documentPrimitiveNode.GetValue <int>();
                    if (index >= 0 && index < this.inlineUIElementStandIns.Count)
                    {
                        originals.Add(node);
                        replacements.Add(this.inlineUIElementStandIns[index].Clone(node.Context));
                        return;
                    }
                }
            }
            foreach (Microsoft.Expression.DesignModel.DocumentModel.DocumentNode node1 in node.ChildNodes)
            {
                this.PostProcessDocumentNodeFromEditProxyRecursive(node1, originals, replacements);
            }
        }
예제 #12
0
        private static IType GetDesignInstanceType(DocumentCompositeNode designInstanceNode)
        {
            if (designInstanceNode.DocumentRoot == null)
            {
                return((IType)null);
            }
            IType        type      = (IType)null;
            IProperty    property1 = (IProperty)designInstanceNode.Type.GetMember(MemberType.LocalProperty, "Type", MemberAccessTypes.Public);
            DocumentNode dataNode  = designInstanceNode.Properties[(IPropertyId)property1];

            if (dataNode != null)
            {
                IType dataType = DataContextHelper.GetDataType(dataNode);
                if (dataType.RuntimeType == (Type)null)
                {
                    return((IType)null);
                }
                IProperty             property2 = (IProperty)designInstanceNode.Type.GetMember(MemberType.LocalProperty, "CreateList", MemberAccessTypes.Public);
                DocumentPrimitiveNode documentPrimitiveNode1 = designInstanceNode.Properties[(IPropertyId)property2] as DocumentPrimitiveNode;
                bool                  createList             = documentPrimitiveNode1 != null && documentPrimitiveNode1.GetValue <bool>();
                IProperty             property3 = (IProperty)designInstanceNode.Type.GetMember(MemberType.LocalProperty, "IsDesignTimeCreatable", MemberAccessTypes.Public);
                DocumentPrimitiveNode documentPrimitiveNode2 = designInstanceNode.Properties[(IPropertyId)property3] as DocumentPrimitiveNode;
                bool                  isDesignTimeCreatable  = documentPrimitiveNode2 != null && documentPrimitiveNode2.GetValue <bool>();
                DesignTypeResult      typeToInstantiate      = DesignTypeInstanceBuilder.GetTypeToInstantiate(designInstanceNode.PlatformMetadata, dataType.RuntimeType, createList, isDesignTimeCreatable);
                if (typeToInstantiate.IsFailed)
                {
                    return((IType)null);
                }
                type = designInstanceNode.TypeResolver.GetType(typeToInstantiate.DesignType);
            }
            return(type);
        }
예제 #13
0
        private object ConvertInternal(object value, IDocumentContext sourcePlatformDocumentContext, IDocumentContext targetPlatformDocumentContext, PlatformConverter.ConvertToType convertType)
        {
            if (value == null)
            {
                return((object)null);
            }
            if (value == PlatformConverter.PortableUserInterfaceFont)
            {
                value = (object)new FontFamily(PlatformConverter.portableUserInterfaceString);
            }
            if (PlatformConverter.IsPlatformValue(value, targetPlatformDocumentContext))
            {
                if (convertType == PlatformConverter.ConvertToType.DocumentNode)
                {
                    return((object)targetPlatformDocumentContext.CreateNode(value.GetType(), value));
                }
                return(value);
            }
            Type type1 = value.GetType();

            if (convertType == PlatformConverter.ConvertToType.InstanceValue && PlatformConverter.CanUseFastConversion(type1))
            {
                return(this.ConvertInternalFast(value, sourcePlatformDocumentContext.TypeResolver, targetPlatformDocumentContext.TypeResolver));
            }
            SceneDocument activeDocument = this.designerContext.ActiveDocument;

            ((PurePlatformProjectContext)this.StandaloneWpfDocumentContext.TypeResolver).SetActualProjectContext(activeDocument != null ? activeDocument.ProjectContext : (IProjectContext)null);
            DocumentNode documentNode1 = value as DocumentNode;
            DocumentNode node;

            using (((IProjectContext)sourcePlatformDocumentContext.TypeResolver).Platform.DocumentNodeBuilderFactory.ForceBuildAnimatedValue)
                node = documentNode1 ?? sourcePlatformDocumentContext.CreateNode(value.GetType(), value);
            if (node == null)
            {
                return((object)null);
            }
            object obj          = (object)null;
            IType  type2        = node.Type;
            IType  platformType = ((IPlatformTypes)targetPlatformDocumentContext.TypeResolver.PlatformMetadata).GetPlatformType(type2.FullName);

            if (node is DocumentPrimitiveNode)
            {
                if (convertType == PlatformConverter.ConvertToType.DocumentNode)
                {
                    return((object)this.ConvertSubtree(node, sourcePlatformDocumentContext, targetPlatformDocumentContext));
                }
                if (platformType == null || type2.TypeConverter == null || platformType.TypeConverter == null)
                {
                    return((object)null);
                }
                DocumentPrimitiveNode documentPrimitiveNode1 = value as DocumentPrimitiveNode;
                string text;
                if (documentPrimitiveNode1 != null)
                {
                    text = documentPrimitiveNode1.GetValue <string>();
                }
                else
                {
                    DocumentPrimitiveNode documentPrimitiveNode2 = node as DocumentPrimitiveNode;
                    text = documentPrimitiveNode2 == null || !(documentPrimitiveNode2.Value is DocumentNodeStringValue) ? type2.TypeConverter.ConvertToString((ITypeDescriptorContext)null, CultureInfo.InvariantCulture, value) : documentPrimitiveNode2.GetValue <string>();
                }
                try
                {
                    obj = platformType.TypeConverter.ConvertFromString((ITypeDescriptorContext)null, CultureInfo.InvariantCulture, text);
                }
                catch
                {
                }
            }
            else
            {
                DocumentNode documentNode2 = this.ConvertSubtree(node, sourcePlatformDocumentContext, targetPlatformDocumentContext);
                if (convertType == PlatformConverter.ConvertToType.DocumentNode)
                {
                    return((object)documentNode2);
                }
                if (documentNode2 != null)
                {
                    DocumentNodePath documentNodePath = new DocumentNodePath(documentNode2, documentNode2);
                    using (StandaloneInstanceBuilderContext instanceBuilderContext = new StandaloneInstanceBuilderContext(targetPlatformDocumentContext, this.designerContext))
                    {
                        instanceBuilderContext.ViewNodeManager.RootNodePath = documentNodePath;
                        instanceBuilderContext.ViewNodeManager.Instantiate(instanceBuilderContext.ViewNodeManager.Root);
                        using (instanceBuilderContext.DisablePostponedResourceEvaluation())
                            obj = instanceBuilderContext.ViewNodeManager.ValidRootInstance;
                        instanceBuilderContext.ViewNodeManager.RootNodePath = (DocumentNodePath)null;
                    }
                }
            }
            if (obj == null && platformType != null && (!platformType.SupportsNullValues && platformType.RuntimeType != (Type)null))
            {
                obj = InstanceBuilderOperations.InstantiateType(platformType.RuntimeType, true);
            }
            return(obj);
        }