コード例 #1
0
        private IEnumerable <DataStoreReferenceEntry> FindDataStoreReferenceDictionary(SceneDocument document)
        {
            List <DataStoreReferenceEntry>    list = (List <DataStoreReferenceEntry>)null;
            ResourceDictionaryContentProvider dictionaryContentProvider = this.GetResourceDictionaryContentProvider(document);

            if (dictionaryContentProvider != null)
            {
                foreach (DocumentNode documentNode1 in dictionaryContentProvider.Items)
                {
                    DocumentCompositeNode documentCompositeNode = documentNode1 as DocumentCompositeNode;
                    if (documentCompositeNode != null)
                    {
                        DocumentNode documentNode2 = documentCompositeNode.Properties[DictionaryEntryNode.ValueProperty];
                        if (documentNode2 != null)
                        {
                            SampleDataSet sampleDataSet = SampleDataSet.SampleDataSetFromType(documentNode2.Type.RuntimeType);
                            if (sampleDataSet != null && sampleDataSet.Context == DataSetContext.DataStore)
                            {
                                if (list == null)
                                {
                                    list = new List <DataStoreReferenceEntry>();
                                }
                                DataStoreReferenceEntry storeReferenceEntry = new DataStoreReferenceEntry()
                                {
                                    DataStore           = sampleDataSet,
                                    DictionaryEntryNode = documentCompositeNode
                                };
                                list.Add(storeReferenceEntry);
                            }
                        }
                    }
                }
            }
            return((IEnumerable <DataStoreReferenceEntry>)list);
        }
コード例 #2
0
        public DocumentNode GetThemeResourceFromProject(IProject project, object resourceKey, out IList <DocumentCompositeNode> auxillaryResources)
        {
            auxillaryResources = (IList <DocumentCompositeNode>)null;
            IProjectContext projectContext = (IProjectContext)ProjectXamlContext.GetProjectContext(project);

            if (projectContext == null)
            {
                return((DocumentNode)null);
            }
            string rootDirectory = Path.Combine(project.ProjectRoot.Path, "Themes");

            foreach (string currentTheme in ThemeContentProvider.GetThemeNames(projectContext))
            {
                DocumentReference fileThemeReference = ThemeContentProvider.GetFileThemeReference(rootDirectory, currentTheme);
                IProjectItem      projectItem        = project.FindItem(fileThemeReference);
                if (projectItem != null)
                {
                    ResourceDictionaryContentProvider resourceDictionary = this.designerContext.ResourceManager.GetContentProviderForResourceDictionary(projectItem);
                    if (resourceDictionary != null)
                    {
                        DocumentNode projectResource = this.FindProjectResource(project, resourceDictionary, projectItem.DocumentReference.Path, resourceKey, out auxillaryResources);
                        if (projectResource != null)
                        {
                            return(projectResource);
                        }
                    }
                }
            }
            return((DocumentNode)null);
        }
コード例 #3
0
 protected override bool UpdateAssets()
 {
     if (this.originalDocumentProvider == null)
     {
         Encoding encoding;
         this.originalDocumentProvider = new ResourceDictionaryContentProvider(this.designerContext, this.themeManager.GetTheme(DocumentReferenceLocator.GetDocumentLocator(this.documentReference), false, (IDocumentContext)null, ThemeContentProvider.LoadReference(this.documentReference, this.designerContext.TextBufferService, out encoding), encoding));
         this.ContentProvider          = this.GetProvider(this.designerContext.ActiveProject);
     }
     return(base.UpdateAssets());
 }
コード例 #4
0
        private ResourceDictionaryContentProvider GetProvider(IProject activeProject)
        {
            ResourceDictionaryContentProvider dictionaryContentProvider = (ResourceDictionaryContentProvider)null;
            bool         canInsert;
            IProjectItem existingItem = this.FindExistingItem(activeProject, out canInsert);

            if (existingItem != null)
            {
                dictionaryContentProvider = this.designerContext.ResourceManager.GetContentProviderForResourceDictionary(existingItem);
            }
            return(dictionaryContentProvider);
        }
コード例 #5
0
ファイル: BindingEditor.cs プロジェクト: radtek/Shopdrawing
        private bool EnsureDataSourceReachable(SceneNode targetNode, DataSourceNode dataSource)
        {
            if (!targetNode.ViewModel.Document.HasOpenTransaction || new ExpressionEvaluator(targetNode.ViewModel.DocumentRootResolver).EvaluateResource(targetNode.DocumentNodePath, ResourceReferenceType.Static, dataSource.ResourceKey) != null)
            {
                return(true);
            }
            IProjectDocument projectDocument = targetNode.ProjectContext.OpenDocument(dataSource.DocumentNode.Context.DocumentUrl);

            if (projectDocument == null || projectDocument.DocumentType != ProjectDocumentType.ResourceDictionary)
            {
                return(false);
            }
            SceneDocument   resourceDictionary1 = projectDocument.Document as SceneDocument;
            ResourceManager resourceManager     = targetNode.ViewModel.DesignerContext.ResourceManager;
            ResourceDictionaryContentProvider resourceDictionary2 = resourceManager.FindContentProviderForResourceDictionary(resourceDictionary1);
            ResourceContainer resourceContainer = resourceManager.FindResourceContainer(targetNode.DocumentContext.DocumentUrl);

            return(resourceDictionary2.EnsureLinked(targetNode.ViewModel, resourceContainer));
        }
コード例 #6
0
        private DocumentNode FindProjectResource(IProject project, ResourceDictionaryContentProvider currentThemeProvider, string currentThemePath, object resourceKey, out IList <DocumentCompositeNode> auxillaryResources)
        {
            List <string> resolvedUris = new List <string>();

            return(ThemeContentProvider.FindResource(currentThemeProvider, currentThemePath, (Func <ResourceDictionaryContentProvider, Func <DocumentNode, object> >)(provider => (Func <DocumentNode, object>)(resourceKeyNode =>
            {
                DocumentNode rootNode = currentThemeProvider.Document.RootNode;
                using (StandaloneInstanceBuilderContext instanceBuilderContext = new StandaloneInstanceBuilderContext(rootNode.Context, this.designerContext))
                {
                    using (instanceBuilderContext.DisablePostponedResourceEvaluation())
                    {
                        instanceBuilderContext.ViewNodeManager.RootNodePath = new DocumentNodePath(rootNode, resourceKeyNode);
                        instanceBuilderContext.ViewNodeManager.Instantiate(instanceBuilderContext.ViewNodeManager.Root);
                        return instanceBuilderContext.ViewNodeManager.ValidRootInstance;
                    }
                }
            })), (Func <Uri, string, string>)((relativeUri, sourcePath) =>
            {
                Uri uri = project.MakeDesignTimeUri(relativeUri, sourcePath);
                if (!(uri != (Uri)null))
                {
                    return (string)null;
                }
                string originalString = uri.OriginalString;
                if (resolvedUris.Contains(originalString))
                {
                    return (string)null;
                }
                resolvedUris.Add(originalString);
                return originalString;
            }), (Func <string, ResourceDictionaryContentProvider>)(resolvedUri =>
            {
                if (!string.IsNullOrEmpty(resolvedUri))
                {
                    IProjectItem projectItem = project.FindItem(DocumentReference.Create(resolvedUri));
                    if (projectItem != null)
                    {
                        return this.designerContext.ResourceManager.GetContentProviderForResourceDictionary(projectItem);
                    }
                }
                return (ResourceDictionaryContentProvider)null;
            }), resourceKey, out auxillaryResources));
        }
コード例 #7
0
        public void OnProjectChanged(IProject newProject)
        {
            if (this.originalDocumentProvider == null)
            {
                return;
            }
            ResourceDictionaryContentProvider provider = this.GetProvider(newProject);

            if (this.ContentProvider == provider)
            {
                return;
            }
            this.ContentProvider = provider;
            if (this.Assets.Count <= 0)
            {
                return;
            }
            this.Assets.Clear();
            this.NeedsUpdate = true;
        }
コード例 #8
0
ファイル: AssetTypeHelper.cs プロジェクト: radtek/Shopdrawing
        internal static ResourceDictionaryUsage GetResourceDictionaryUsage(ResourceDictionaryContentProvider contentProvider)
        {
            ResourceDictionaryUsage resourceDictionaryUsage = ResourceDictionaryUsage.Unknown;

            if (contentProvider != null && contentProvider.Document != null && contentProvider.Document.RootNode != null)
            {
                DocumentCompositeNode documentCompositeNode = contentProvider.Document.RootNode as DocumentCompositeNode;
                if (documentCompositeNode != null)
                {
                    if (documentCompositeNode.GetValue <bool>(DesignTimeProperties.IsSketchFlowStyleProperty))
                    {
                        resourceDictionaryUsage |= ResourceDictionaryUsage.PrototypingStyles;
                    }
                    if (documentCompositeNode.GetValue <bool>(DesignTimeProperties.IsSketchFlowDefaultStyleProperty))
                    {
                        resourceDictionaryUsage |= ResourceDictionaryUsage.PrototypingDefaultStyles;
                    }
                }
            }
            return(resourceDictionaryUsage);
        }
コード例 #9
0
 public ResourceDictionaryAssetProvider(ResourceDictionaryContentProvider provider)
 {
     this.ContentProvider = provider;
 }
コード例 #10
0
        private static DocumentNode FindResource(ResourceDictionaryContentProvider themeContent, string originalThemePath, Func <ResourceDictionaryContentProvider, Func <DocumentNode, object> > provideInstanceForThemeContent, Func <Uri, string, string> provideResolvedUriForMergedDictionary, Func <string, ResourceDictionaryContentProvider> provideContentForMergedDictionary, object resourceKey, out IList <DocumentCompositeNode> auxillaryResources)
        {
            DocumentNode root = (DocumentNode)null;

            auxillaryResources = (IList <DocumentCompositeNode>)null;
            Func <DocumentNode, object> func = provideInstanceForThemeContent(themeContent);

            foreach (DocumentNode documentNode1 in themeContent.Items)
            {
                DocumentCompositeNode entryNode = documentNode1 as DocumentCompositeNode;
                if (entryNode != null)
                {
                    DocumentNode documentNode2 = ResourceNodeHelper.GetResourceEntryKey(entryNode);
                    if (documentNode2 == null)
                    {
                        DocumentCompositeNode documentCompositeNode = entryNode.Properties[DictionaryEntryNode.ValueProperty] as DocumentCompositeNode;
                        if (documentCompositeNode != null)
                        {
                            if (documentCompositeNode.Type.Metadata.ImplicitDictionaryKeyProperty != null)
                            {
                                documentNode2 = documentCompositeNode.Properties[documentCompositeNode.Type.Metadata.ImplicitDictionaryKeyProperty];
                            }
                            if (documentNode2 == null && documentCompositeNode.TypeResolver.IsCapabilitySet(PlatformCapability.NameSupportedAsKey))
                            {
                                documentNode2 = documentCompositeNode.Properties[(IPropertyId)documentCompositeNode.Type.Metadata.NameProperty];
                            }
                        }
                    }
                    if (documentNode2 != null)
                    {
                        object objB = func(documentNode2);
                        if (object.Equals(resourceKey, objB))
                        {
                            root = entryNode.Properties[DictionaryEntryNode.ValueProperty];
                            break;
                        }
                    }
                }
            }
            if (root == null && originalThemePath != null)
            {
                foreach (DocumentNode documentNode in themeContent.Items)
                {
                    DocumentCompositeNode documentCompositeNode = documentNode as DocumentCompositeNode;
                    if (documentCompositeNode != null && PlatformTypes.ResourceDictionary.IsAssignableFrom((ITypeId)documentCompositeNode.Type))
                    {
                        Uri uriValue = documentCompositeNode.GetUriValue(ResourceDictionaryNode.SourceProperty);
                        if (uriValue != (Uri)null)
                        {
                            string originalThemePath1 = provideResolvedUriForMergedDictionary(uriValue, originalThemePath);
                            if (originalThemePath1 != null)
                            {
                                ResourceDictionaryContentProvider themeContent1 = provideContentForMergedDictionary(originalThemePath1);
                                if (themeContent1 != null)
                                {
                                    root = ThemeContentProvider.FindResource(themeContent1, originalThemePath1, provideInstanceForThemeContent, provideResolvedUriForMergedDictionary, provideContentForMergedDictionary, resourceKey, out auxillaryResources);
                                    if (root != null)
                                    {
                                        return(root);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (root != null)
            {
                auxillaryResources = Microsoft.Expression.DesignSurface.Utility.ResourceHelper.FindReferencedResources(root);
            }
            return(root);
        }