public virtual void ReloadThemeFromStorage() { Theme theme = (Theme)null; bool flag = this.OwnerThemeManager == null || !this.OwnerThemeManager.IsDesignMode && this.ownerThemeManager.LoadedThemes.Count == 0; if ((object)this.callingAssembly == null) { this.callingAssembly = Assembly.GetCallingAssembly(); } if (flag && ThemeSource.locationsAlreadyLoaded[(object)(this.callingAssembly.FullName + this.ThemeLocation)] == ThemeSource.locationLoadedMarker) { return; } if (this.StorageType == ThemeStorageType.File) { theme = Theme.ReadXML(this.ThemeLocation); ThemeRepository.Add(theme); } else if ((object)this.callingAssembly != null) { if (this.ownerThemeManager != null && this.ownerThemeManager.Site != null && this.ownerThemeManager.Site.DesignMode) { theme = this.LoadThemeInDesingMode(this); this.loadSucceeded = true; } else { Stream stream = this.callingAssembly.GetManifestResourceStream(this.ThemeLocation) ?? Assembly.GetExecutingAssembly().GetManifestResourceStream(this.ThemeLocation); if (stream == null) { Assembly entryAssembly = Assembly.GetEntryAssembly(); if ((object)entryAssembly != null) { stream = entryAssembly.GetManifestResourceStream(this.ThemeLocation); } } if (stream != null) { using (stream) { theme = new XMLThemeReader().Read(stream); ThemeRepository.Add(theme); } } } } if (theme != null) { this.theme = theme; if (!string.IsNullOrEmpty(theme.Name)) { this.loadSucceeded = true; } } if (!flag || !this.loadSucceeded) { return; } ThemeSource.locationsAlreadyLoaded[(object)(this.callingAssembly.FullName + this.ThemeLocation)] = ThemeSource.locationLoadedMarker; }
public static void RegisterThemeFromStorage(ThemeStorageType storageType, string themeLocation) { XMLThemeReader xmlThemeReader = new XMLThemeReader(); if (storageType == ThemeStorageType.File) { Theme theme = xmlThemeReader.Read(themeLocation); if (theme == null) { return; } ThemeRepository.Add(theme); } else { using (Stream manifestResourceStream = Assembly.GetCallingAssembly().GetManifestResourceStream(themeLocation)) { Theme theme = xmlThemeReader.Read(manifestResourceStream); if (theme == null || string.IsNullOrEmpty(theme.Name)) { return; } ThemeRepository.Add(theme); } } }
public static bool LoadPackageFile(string filePath, bool throwOnError) { if (!File.Exists(filePath)) { if (throwOnError) { throw new FileNotFoundException("File '" + filePath + "' does not exist."); } return(false); } if (new FileInfo(filePath).Extension != ".tssp") { if (throwOnError) { throw new ArgumentException("Provided file is not a valid RadThemePackage"); } return(false); } Theme theme = new TSSPThemeReader().Read(filePath); if (theme == null) { return(false); } ThemeRepository.Add(theme); return(true); }
private Theme LoadThemeInDesingMode(ThemeSource themeSource) { ProjectManagement managementInstance = ProjectManagement.GetProjectManagementInstance((IServiceProvider)themeSource.OwnerThemeManager.Site); string activeProjectFullPath = managementInstance.Services.GetActiveProjectFullPath(); if (!themeSource.SettingsAreValid) { return(this.theme); } string configurationPropertyValue = (string)managementInstance.Services.GetProjectConfigurationPropertyValue("OutputPath"); if (string.IsNullOrEmpty(activeProjectFullPath) || string.IsNullOrEmpty(configurationPropertyValue)) { return((Theme)null); } string path1 = Path.Combine(activeProjectFullPath, configurationPropertyValue); string str = (string)null; if (themeSource.StorageType == ThemeStorageType.File) { if (Path.IsPathRooted(themeSource.ThemeLocation)) { return((Theme)null); } string themeLocation = themeSource.ThemeLocation; if (path1 != null && !string.IsNullOrEmpty(themeLocation)) { string path2 = themeLocation.Replace("~\\", "").Replace("~", ""); str = Path.Combine(path1, path2); if (!File.Exists(str)) { themeSource.loadError = "Path not found: " + str; return(this.theme); } } } else if (themeSource.StorageType == ThemeStorageType.Resource) { string themeLocation = themeSource.ThemeLocation; string[] fileNameParts = themeLocation.Split('.'); str = ThemeSource.SearchFile(activeProjectFullPath, fileNameParts); if (str == null) { themeSource.loadError = string.Format("Unable locate Resource file '{0}' in the project folder '{1}'", (object)string.Join(Path.DirectorySeparatorChar.ToString(), themeLocation.Split('.')), (object)activeProjectFullPath); return(this.theme); } } if (str == null) { themeSource.loadError = "Unable to determine active project path."; return(this.theme); } Theme theme = Theme.ReadXML(str); ThemeRepository.Add(theme); return(theme); }
public static Theme EnsureThemeRegistered(string themeName) { Theme theme = ThemeRepository.FindTheme(themeName); if (theme == null) { theme = new Theme(themeName); ThemeRepository.Add(theme); } return(theme); }
public static bool LoadPackageFile(string filePath) { Theme theme = new TSSPThemeReader().Read(filePath); if (theme == null) { return(false); } ThemeRepository.Add(theme); return(true); }
public static bool LoadPackageResource( ThemeResolutionService.ResourceParams resourceParams, bool throwOnError) { Assembly assembly = resourceParams.UserAssembly; string resourcePath = resourceParams.ResourcePath; if ((object)assembly == null) { assembly = resourceParams.CallingAssembly; if ((object)assembly == null) { assembly = Assembly.GetCallingAssembly(); } } Stream manifestResourceStream = assembly.GetManifestResourceStream(resourcePath); if (manifestResourceStream == null) { Assembly executingAssembly = resourceParams.ExecutingAssembly; if ((object)executingAssembly == null) { executingAssembly = Assembly.GetExecutingAssembly(); } manifestResourceStream = executingAssembly.GetManifestResourceStream(resourcePath); } if (manifestResourceStream == null) { if (throwOnError) { throw new ArgumentException("Specified resource does not exist in the provided assembly."); } return(false); } using (manifestResourceStream) { Theme theme = new TSSPThemeReader().Read(manifestResourceStream); if (theme != null) { ThemeRepository.Add(theme); return(true); } } return(false); }
protected virtual bool LoadResource(Assembly resourceAssembly, string resourcePath) { try { using (Stream manifestResourceStream = resourceAssembly.GetManifestResourceStream(resourcePath)) { if (manifestResourceStream != null) { Theme theme = new TSSPThemeReader().Read(manifestResourceStream); if (theme != null) { ThemeRepository.Add(theme); return(true); } } } } catch { int num = (int)MessageBox.Show(string.Format("Failed to load {0} theme.", (object)resourcePath)); } return(false); }
public static void Add(Theme theme) { ThemeRepository.Add(theme, true); }