public static string GeneratePreviewHtml(ThemeConfig theme) { string htmlText = Properties.Resources.preview_html; Dictionary <string, string> replacers = new Dictionary <string, string>(); replacers.Add("basePath", new Uri(Environment.CurrentDirectory).AbsoluteUri); if (theme != null) { replacers.Add("themeName", ThemeManager.GetThemeName(theme)); replacers.Add("themeAuthor", ThemeManager.GetThemeAuthor(theme)); replacers.Add("previewMessage", string.Format(_("Previewing {0}"), "<span id=\"previewText\"></span>")); SolarData solarData = SunriseSunsetService.GetSolarData(DateTime.Today); SchedulerState wpState = AppContext.wpEngine.GetImageData(solarData, theme); if (ThemeManager.IsThemeDownloaded(theme)) { // TODO Why are images flickering? ThemeImageData imageData = GetThemeImageData(theme); int activeImage = imageData.FindIndex(entry => entry.Item2 == wpState.daySegment4) + wpState.imageNumber; replacers.Add("downloadMessage", ""); replacers.Add("carouselIndicators", GetCarouselIndicators(imageData.Count, activeImage)); replacers.Add("carouselItems", GetCarouselItems(imageData, activeImage, theme)); } else { replacers.Add("downloadMessage", string.Format("<div id=\"bottomCenterPanel\">{0}</div>", _("Theme is not downloaded. Click Download button to enable full preview."))); replacers.Add("carouselIndicators", ""); replacers.Add("carouselItems", GetCarouselItems(wpState, theme)); } } else { replacers.Add("themeAuthor", "Microsoft"); int startCarouselIndex = htmlText.IndexOf("<!--"); int endCarouselIndex = htmlText.LastIndexOf("-->") + 3; string imageTag = string.Format("<img src=\"{0}\">", (new Uri(ThemeThumbLoader.GetWindowsWallpaper())).AbsoluteUri); htmlText = htmlText.Substring(0, startCarouselIndex) + imageTag + htmlText.Substring(endCarouselIndex + 1); } return(RenderTemplate(htmlText, replacers)); }
private string GetCreditsText() { string themeAuthor; if (selectedIndex > 0) { themeAuthor = ThemeManager.GetThemeAuthor(ThemeManager.themeSettings[selectedIndex - 1]); } else { themeAuthor = "Microsoft"; } return((themeAuthor != null) ? string.Format(_("Image Credits: {0}"), themeAuthor) : ""); }
private static string GeneratePreviewHtml(ThemeConfig theme, int activeImage) { string htmlText = Properties.Resources.preview_html; htmlText = htmlText.Replace("{{themeName}}", ThemeManager.GetThemeName(theme)); htmlText = htmlText.Replace("{{themeAuthor}}", ThemeManager.GetThemeAuthor(theme)); List <int> imageList = ThemeManager.GetThemeImageList(theme); htmlText = htmlText.Replace("{{carouselIndicators}}", GetCarouselIndicators(imageList, activeImage)); htmlText = htmlText.Replace("{{carouselItems}}", GetCarouselItems(imageList, activeImage, theme)); string filename = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".html"); File.WriteAllText(filename, htmlText); return(filename); }