Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public DocumentNode GetThemeResourceFromPlatform(IPlatform platform, object resourceKey, out IList <DocumentCompositeNode> auxillaryResources)
        {
            auxillaryResources = (IList <DocumentCompositeNode>)null;
            FolderBasedThemeManager basedThemeManager = platform.ThemeManager as FolderBasedThemeManager;

            if (basedThemeManager == null)
            {
                return((DocumentNode)null);
            }
            using (TemporaryCursor.SetWaitCursor())
            {
                Dictionary <ThemeContentProvider.PlatformSpecificDocumentReference, ThemeContentProvider.SystemThemeContentProvider> orCreateCache = DesignSurfacePlatformCaches.GetOrCreateCache <Dictionary <ThemeContentProvider.PlatformSpecificDocumentReference, ThemeContentProvider.SystemThemeContentProvider> >(platform.Metadata, DesignSurfacePlatformCaches.ThemeContentProviderCache);
                DocumentReference fileThemeReference = ThemeContentProvider.GetFileThemeReference(basedThemeManager.ThemeFolder, basedThemeManager.CurrentTheme);
                return(this.GetResourceInternal(orCreateCache, (ThemeManager)basedThemeManager, (IProjectContext)null, fileThemeReference, (IAssembly)null, (string)null, resourceKey, out auxillaryResources));
            }
        }