private void LoadPreviewImage(int imageNumber) { ThemeConfig theme = ThemeManager.themeSettings[selectedIndex - 1]; int imageId = ThemeManager.GetThemeImageList(theme)[imageNumber - 1]; string imageFilename = theme.imageFilename.Replace("*", imageId.ToString()); LoadPreviewImage(new Bitmap(Path.Combine("themes", theme.themeId, imageFilename))); previewImage = imageNumber; }
private int GetMaxImageNumber() { int max = 1; if (selectedIndex > 0) { ThemeConfig theme = ThemeManager.themeSettings[selectedIndex - 1]; max = ThemeManager.GetThemeImageList(theme).Count; } return(max); }
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); }
private void UpdateSelectedItem() { if (imageListView1.SelectedItems.Count > 0) { selectedIndex = imageListView1.SelectedItems[0].Index; int imageNumber = 1; bool themeDownloaded = true; if (selectedIndex > 0) { string themeId = (string)imageListView1.Items[selectedIndex].Tag; selectedIndex = ThemeManager.themeSettings.FindIndex( t => t.themeId == themeId) + 1; ThemeConfig theme = ThemeManager.themeSettings[selectedIndex - 1]; themeDownloaded = ThemeManager.IsThemeDownloaded(theme); if (themeDownloaded) { SolarData solarData = SunriseSunsetService.GetSolarData(DateTime.Today); imageNumber = ThemeManager.GetThemeImageList(theme).IndexOf( AppContext.wpEngine.GetImageData(solarData, theme).Item1) + 1; } else { LoadPreviewImage((Image)Properties.Resources.ResourceManager.GetObject( themeId + "_thumbnail")); } } SetThemeDownloaded(themeDownloaded); creditsLabel.Text = GetCreditsText(themeDownloaded); if (themeDownloaded) { maxImageNumber = GetMaxImageNumber(); LoadPreviewImage(imageNumber); } applyButton.Enabled = true; } else { applyButton.Enabled = false; } }
private void UpdateSelectedItem() { if (imageListView1.SelectedItems.Count > 0) { selectedIndex = imageListView1.SelectedItems[0].Index; int imageNumber = 1; bool themeDownloaded = true; if (selectedIndex > 0) { string themeId = (string)imageListView1.Items[selectedIndex].Tag; selectedIndex = ThemeManager.themeSettings.FindIndex(t => t.themeId == themeId) + 1; ThemeConfig theme = ThemeManager.themeSettings[selectedIndex - 1]; nameLabel.Text = ThemeManager.GetThemeName(theme); themeDownloaded = ThemeManager.IsThemeDownloaded(theme); if (themeDownloaded) { SolarData solarData = SunriseSunsetService.GetSolarData(DateTime.Today); imageNumber = ThemeManager.GetThemeImageList(theme).IndexOf( AppContext.wpEngine.GetImageData(solarData, theme).imageId) + 1; LoadPreviewImage(imageNumber); } else { LoadPreviewImage((Image)Properties.Resources.ResourceManager.GetObject(themeId + "_thumbnail")); } } else { nameLabel.Text = _("Windows Default"); LoadPreviewImage(new Bitmap(windowsWallpaper)); } creditsLabel.Text = GetCreditsText(); downloadLabel.Visible = selectedIndex > 0 && !themeDownloaded; previewLinkLabel.Visible = selectedIndex > 0 && themeDownloaded; applyButton.Enabled = true; } else { applyButton.Enabled = false; } }
public static ThemeResult ValidateFull(ThemeConfig theme) { string themePath = Path.Combine("themes", theme.themeId); if (Directory.GetFiles(themePath, theme.imageFilename).Length == 0) { return(new ThemeResult(new NoImagesMatchingPattern(theme.themeId, theme.imageFilename))); } foreach (int imageId in ThemeManager.GetThemeImageList(theme)) { string imageFilename = theme.imageFilename.Replace("*", imageId.ToString()); if (!File.Exists(Path.Combine(themePath, imageFilename))) { return(new ThemeResult(new InvalidImageInThemeJSON(theme.themeId, imageId, imageFilename))); } } return(new ThemeResult(theme)); }
private void LoadPreviewImage(int imageNumber) { if (selectedIndex == 0) { LoadPreviewImage(new Bitmap(windowsWallpaper)); } else { ThemeConfig theme = ThemeManager.themeSettings[selectedIndex - 1]; int imageId = ThemeManager.GetThemeImageList(theme)[imageNumber - 1]; string imageFilename = theme.imageFilename.Replace("*", imageId.ToString()); LoadPreviewImage(new Bitmap(Path.Combine("themes", theme.themeId, imageFilename))); } imageNumberLabel.Text = string.Format(_("Image {0} of {1}"), imageNumber, maxImageNumber); firstButton.Enabled = imageNumber > 1; previousButton.Enabled = imageNumber > 1; nextButton.Enabled = imageNumber < maxImageNumber; lastButton.Enabled = imageNumber < maxImageNumber; previewImage = imageNumber; }
private void LoadPreviewImage(int imageNumber) { int width = pictureBox1.Size.Width; int height = pictureBox1.Size.Height; Rectangle screen = Screen.FromControl(this).Bounds; if ((screen.Y / (double)screen.X) <= (height / (double)width)) { height = width * 9 / 16; } else { width = height * 16 / 9; } if (selectedIndex == 0) { pictureBox1.Image = ShrinkImage(windowsWallpaper, width, height); } else { ThemeConfig theme = ThemeManager.themeSettings[selectedIndex - 1]; int imageId = ThemeManager.GetThemeImageList(theme)[imageNumber - 1]; string imageFilename = theme.imageFilename.Replace("*", imageId.ToString()); pictureBox1.Image = ShrinkImage(Path.Combine("themes", theme.themeId, imageFilename), width, height); } imageNumberLabel.Text = string.Format(_("Image {0} of {1}"), imageNumber, maxImageNumber); firstButton.Enabled = imageNumber > 1; previousButton.Enabled = imageNumber > 1; nextButton.Enabled = imageNumber < maxImageNumber; lastButton.Enabled = imageNumber < maxImageNumber; previewImage = imageNumber; }