public async Task <ResourceDictionary> TryLoadResourceDictionary(AppTheme theme) { StorageFile file; if (theme?.Path == null) { return(null); } if (theme.AbsolutePath.Contains(ImportedThemesFolder.Path)) { file = await ImportedThemesFolder.GetFileAsync(theme.Path); theme.IsImportedTheme = true; } else { file = await ThemeFolder.GetFileAsync(theme.Path); theme.IsImportedTheme = false; } var code = await FileIO.ReadTextAsync(file); var xaml = XamlReader.Load(code) as ResourceDictionary; xaml.Add("CustomThemeID", theme.Key); return(xaml); }
public async Task <ResourceDictionary> TryLoadResourceDictionary(AppTheme theme) { StorageFile file; if (theme?.Path == null) { return(null); } if (theme.IsFromOptionalPackage) { if (OptionalPackageThemesFolder != null) { file = await OptionalPackageThemesFolder.GetFileAsync(theme.Path); } else { return(null); } } else { file = await ThemeFolder.GetFileAsync(theme.Path); } var code = await FileIO.ReadTextAsync(file); var xaml = XamlReader.Load(code) as ResourceDictionary; xaml.Add("CustomThemeID", theme.Key); return(xaml); }
public async Task <bool> TryLoadThemeAsync(AppTheme theme) { try { StorageFile file; if (theme.IsFromOptionalPackage) { if (OptionalPackageThemeFolder != null) { file = await OptionalPackageThemeFolder.GetFileAsync(theme.Path); } else { return(false); } } else { file = await ThemeFolder.GetFileAsync(theme.Path); } CurrentThemeResources = await FileIO.ReadTextAsync(file); var xaml = XamlReader.Load(CurrentThemeResources) as ResourceDictionary; xaml.Add("CustomThemeID", theme.Key); App.Current.Resources.MergedDictionaries.Add(xaml); return(true); } catch (Exception) { return(false); } }
private async void LoadOtherThemesAsync() { try { foreach (var file in (await ThemeFolder.GetFilesAsync()).Where(x => x.FileType == ".xaml")) { Themes.Add(file.Name); } } catch (Exception) { Debug.WriteLine($"Error loading themes"); } }
public async Task <bool> TryLoadThemeAsync(string name) { try { var file = await ThemeFolder.GetFileAsync(name); CurrentThemeResources = await FileIO.ReadTextAsync(file); var xaml = XamlReader.Load(CurrentThemeResources) as ResourceDictionary; App.Current.Resources.MergedDictionaries.Add(xaml); return(true); } catch (Exception) { return(false); } }
public static List <KeyValuePair <string, string> > GetHostThemes() { string ThemeRoot = "Themes"; var themes = new List <KeyValuePair <string, string> >(); string root = Globals.HostMapPath + ThemeRoot; if (Directory.Exists(root)) { foreach (string ThemeFolder in Directory.GetDirectories(root)) { if (!ThemeFolder.EndsWith(Globals.glbHostThemeFolder)) { AddThemeFiles(themes, ThemeRoot, ThemeFolder, false); } } } return(themes); }
protected override void OnInit(EventArgs e) { base.OnInit(e); if (ModSettings.Settings().ContainsKey("themefolder") && ModSettings.Settings()["themefolder"] != "") { ThemeFolder = ModSettings.Settings()["themefolder"]; } if (ThemeFolder == "") { ThemeFolder = StoreSettings.Current.ThemeFolder; } if (ModSettings.Settings().ContainsKey("razortemplate") && ModSettings.Settings()["razortemplate"] != "") { RazorTemplate = ModSettings.Settings()["razortemplate"]; } // insert page header text NBrightBuyUtils.RazorIncludePageHeader(ModuleId, Page, "frontofficepageheader.cshtml", ControlPath, ThemeFolder, ModSettings.Settings()); if (ModuleContext.Configuration != null) { if (String.IsNullOrEmpty(RazorTemplate)) { RazorTemplate = ModuleConfiguration.DesktopModule.ModuleName + ".cshtml"; } // insert page header text NBrightBuyUtils.RazorIncludePageHeader(ModuleId, Page, Path.GetFileNameWithoutExtension(RazorTemplate) + "_head" + Path.GetExtension(RazorTemplate), ControlPath, ThemeFolder, ModSettings.Settings()); } var strOut = "<span class='container_" + ThemeFolder + "_" + RazorTemplate + "'>"; Controls.AddAt(0, new LiteralControl("<div class='container_" + ThemeFolder.ToLower().Replace(" ", "_") + "_" + RazorTemplate.ToLower().Replace(".cshtml", "").Replace(" ", "_") + "'>")); Controls.AddAt(Controls.Count, new LiteralControl("</div>")); }
protected override void OnInit(EventArgs e) { base.OnInit(e); _controlPath = ControlPath; if (ModSettings.Settings().ContainsKey("themefolder") && ModSettings.Settings()["themefolder"] != "") { ThemeFolder = ModSettings.Settings()["themefolder"]; } if (ThemeFolder == "") { ThemeFolder = StoreSettings.Current.ThemeFolder; } if (ModSettings.Settings().ContainsKey("razortemplate") && ModSettings.Settings()["razortemplate"] != "") { RazorTemplate = ModSettings.Settings()["razortemplate"]; } if (RazorTemplate == "" && ModSettings.Settings().ContainsKey("razorlisttemplate") && ModSettings.Settings()["razorlisttemplate"] != "") { RazorTemplate = ModSettings.Settings()["razorlisttemplate"]; } if (RazorTemplate == "" && ModSettings.Settings().ContainsKey("razordetailtemplate") && ModSettings.Settings()["razordetailtemplate"] != "") { RazorTemplate = ModSettings.Settings()["razordetailtemplate"]; } if (ModSettings != null) { // check if we're using a provider controlpath for the templates. var providercontrolpath = ModSettings.Get("providercontrolpath"); if (providercontrolpath != "") { _controlPath = "/DesktopModules/NBright/" + providercontrolpath + "/"; } } // insert page header text NBrightBuyUtils.RazorIncludePageHeader(ModuleId, Page, "FrontOfficePageHeader.cshtml", _controlPath, ThemeFolder, ModSettings.Settings()); // insert text in body. NBrightBuyUtils.RazorIncludePageBody(ModuleId, Page, "FrontOfficePageBody.cshtml", _controlPath, ThemeFolder, ModSettings.Settings()); if (ModuleContext.Configuration != null) { if (String.IsNullOrEmpty(RazorTemplate)) { RazorTemplate = ModuleConfiguration.DesktopModule.ModuleName + ".cshtml"; } // insert page header text NBrightBuyUtils.RazorIncludePageHeader(ModuleId, Page, Path.GetFileNameWithoutExtension(RazorTemplate) + "_head" + Path.GetExtension(RazorTemplate), _controlPath, ThemeFolder, ModSettings.Settings()); // insert page body text for template name. NBrightBuyUtils.RazorIncludePageBody(ModuleId, Page, Path.GetFileNameWithoutExtension(RazorTemplate) + "_pageinject" + Path.GetExtension(RazorTemplate), _controlPath, ThemeFolder, ModSettings.Settings()); } var strOut = "<span class='container_" + ThemeFolder + "_" + RazorTemplate + "'>"; Controls.AddAt(0, new LiteralControl("<div class='container_" + ThemeFolder.ToLower().Replace(" ", "_") + "_" + RazorTemplate.ToLower().Replace(".cshtml", "").Replace(" ", "_") + "'>")); Controls.AddAt(Controls.Count, new LiteralControl("</div>")); }