public ThemeDialog() { InitializeComponent(); Localization.TranslateForm(this); this.Font = SystemFonts.MessageBoxFont; this.FormClosing += OnFormClosing; this.FormClosed += OnFormClosed; Rectangle bounds = Screen.FromControl(this).Bounds; Size thumbnailSize = ThemeThumbLoader.GetThumbnailSize(this); int newWidth = thumbnailSize.Width + SystemInformation.VerticalScrollBarWidth; int oldWidth = this.listView1.Size.Width; using (Graphics g = this.CreateGraphics()) { newWidth += (int)Math.Ceiling(46 * g.DpiX / 96); } this.previewerHost.Anchor &= ~AnchorStyles.Left; this.listView1.Width = newWidth; this.downloadButton.Left += (newWidth - oldWidth) / 2; this.applyButton.Left += (newWidth - oldWidth) / 2; this.closeButton.Left += (newWidth - oldWidth) / 2; this.Width += (newWidth - oldWidth); this.previewerHost.Anchor |= AnchorStyles.Left; int heightDiff = this.Height - this.previewerHost.Height; int widthDiff = this.Width - this.previewerHost.Width; int bestHeight = bounds.Height * 5 / 8; int bestWidth = (bestHeight - heightDiff) * bounds.Width / bounds.Height + widthDiff; this.Size = new Size(bestWidth, bestHeight); this.CenterToScreen(); }
private void ThemeDialog_Load(object sender, EventArgs e) { previewer = new WPF.ThemePreviewer(); previewerHost.Child = previewer; listView1.ContextMenuStrip = contextMenuStrip1; listView1.ListViewItemSorter = new CompareByItemText(listView1); SetWindowTheme(listView1.Handle, "Explorer", null); ImageList imageList = new ImageList(); imageList.ColorDepth = ColorDepth.Depth32Bit; Size thumbnailSize = ThemeThumbLoader.GetThumbnailSize(this); imageList.ImageSize = thumbnailSize; listView1.LargeImageList = imageList; imageList.Images.Add(ThemeThumbLoader.ScaleImage(windowsWallpaper, thumbnailSize)); listView1.Items.Add(_("None"), 0); string activeTheme = ThemeManager.currentTheme?.themeId; if (activeTheme == null && (JsonConfig.firstRun || JsonConfig.settings.themeName != null)) { activeTheme = "Mojave_Desert"; } Task.Run(new Action(() => LoadThemes(ThemeManager.themeSettings, (activeTheme != null) ? activeTheme : ""))); }
public ThemeDialog() { if (!Cef.IsInitialized) { var settings = new CefSharp.WinForms.CefSettings(); settings.CefCommandLineArgs.Add("disable-extensions"); settings.CefCommandLineArgs.Add("disable-gpu"); Cef.Initialize(settings); } InitializeComponent(); Localization.TranslateForm(this); this.Font = SystemFonts.MessageBoxFont; this.FormClosing += OnFormClosing; Rectangle bounds = Screen.FromControl(this).Bounds; Size thumbnailSize = ThemeThumbLoader.GetThumbnailSize(this); int newWidth = thumbnailSize.Width + SystemInformation.VerticalScrollBarWidth + 46; int oldWidth = this.listView1.Size.Width; this.chromiumWebBrowser1.Anchor &= ~AnchorStyles.Left; this.listView1.Width = newWidth; this.downloadButton.Left += (newWidth - oldWidth) / 2; this.applyButton.Left += (newWidth - oldWidth) / 2; this.closeButton.Left += (newWidth - oldWidth) / 2; this.Width += (newWidth - oldWidth); this.chromiumWebBrowser1.Anchor |= AnchorStyles.Left; this.Size = new Size(bounds.Width * 5 / 8, bounds.Height * 5 / 8); this.CenterToScreen(); }
public ThemeDialog() { if (!Cef.IsInitialized) { var settings = new CefSharp.WinForms.CefSettings(); settings.BrowserSubprocessPath = Path.Combine(Environment.CurrentDirectory, @"cef\CefSharp.BrowserSubprocess.exe"); settings.Locale = Localization.GetCefLocale(); #if !DEBUG settings.LogSeverity = LogSeverity.Fatal; #endif Cef.Initialize(settings); } InitializeComponent(); Localization.TranslateForm(this); this.Font = SystemFonts.MessageBoxFont; this.FormClosing += OnFormClosing; Rectangle bounds = Screen.FromControl(this).Bounds; Size thumbnailSize = ThemeThumbLoader.GetThumbnailSize(this); int newWidth = thumbnailSize.Width + SystemInformation.VerticalScrollBarWidth + 46; int oldWidth = this.listView1.Size.Width; this.chromiumWebBrowser1.Anchor &= ~AnchorStyles.Left; this.listView1.Width = newWidth; this.downloadButton.Left += (newWidth - oldWidth) / 2; this.applyButton.Left += (newWidth - oldWidth) / 2; this.closeButton.Left += (newWidth - oldWidth) / 2; this.Width += (newWidth - oldWidth); this.chromiumWebBrowser1.Anchor |= AnchorStyles.Left; this.Size = new Size(bounds.Width * 5 / 8, bounds.Height * 5 / 8); this.CenterToScreen(); }
private void ThemeDialog_Load(object sender, EventArgs e) { imageListView1.ContextMenuStrip = contextMenuStrip1; imageListView1.SetRenderer(new ThemeListViewRenderer()); Size thumbnailSize = ThemeThumbLoader.GetThumbnailSize(this); imageListView1.ThumbnailSize = thumbnailSize; imageListView1.Items.Add(_("None"), ThemeThumbLoader.ScaleImage(windowsWallpaper, thumbnailSize)); string currentTheme = ThemeManager.currentTheme?.themeId; ImageListViewItem focusItem = null; if (currentTheme == null) { if (JsonConfig.firstRun || JsonConfig.settings.themeName != null) { currentTheme = "Mojave_Desert"; } else { focusItem = imageListView1.Items[0]; } } Task.Run(new Action(() => { for (int i = 0; i < ThemeManager.themeSettings.Count; i++) { ThemeConfig theme = ThemeManager.themeSettings[i]; string themeName = ThemeManager.GetThemeName(theme); themeNames.Add(themeName); themeNames.Sort(); int itemIndex = themeNames.IndexOf(themeName) + 1; using (Image thumbnailImage = ThemeThumbLoader.GetThumbnailImage(theme, thumbnailSize, true)) { this.Invoke(new Action(() => { imageListView1.Items.Insert(itemIndex, themeName, thumbnailImage); imageListView1.Items[itemIndex].Tag = theme.themeId; })); } if (theme.themeId == currentTheme) { focusItem = imageListView1.Items[itemIndex]; } } if (focusItem != null) { this.Invoke(new Action(() => { focusItem.Selected = true; imageListView1.EnsureVisible(focusItem.Index); })); } ThemeThumbLoader.CacheThumbnails(imageListView1.Items); })); }
private void LoadThemes(List <ThemeConfig> themes, string activeTheme = null) { Size thumbnailSize = ThemeThumbLoader.GetThumbnailSize(this); ListViewItem focusedItem = null; foreach (ThemeConfig theme in themes.ToList()) { try { using (Image thumbnailImage = ThemeThumbLoader.GetThumbnailImage(theme, thumbnailSize, true)) { this.Invoke(new Action(() => { listView1.LargeImageList.Images.Add(thumbnailImage); string itemText = ThemeManager.GetThemeName(theme); if (JsonConfig.settings.favoriteThemes != null && JsonConfig.settings.favoriteThemes.Contains(theme.themeId)) { itemText = "★ " + itemText; } ListViewItem newItem = listView1.Items.Add(itemText, listView1.LargeImageList.Images.Count - 1); newItem.Tag = theme.themeId; if (activeTheme == null || activeTheme == theme.themeId) { focusedItem = newItem; } })); } } catch (OutOfMemoryException) { ThemeLoader.HandleError(new FailedToCreateThumbnail(theme.themeId)); } } this.Invoke(new Action(() => { listView1.Sort(); if (focusedItem == null) { focusedItem = listView1.Items[0]; } focusedItem.Selected = true; listView1.EnsureVisible(focusedItem.Index); ThemeThumbLoader.CacheThumbnails(listView1); })); }
public ThemeDialog() { InitializeComponent(); Localization.TranslateForm(this); this.Font = SystemFonts.MessageBoxFont; this.FormClosing += OnFormClosing; int bestWidth = (ThemeThumbLoader.GetThumbnailSize(this).Width + 30) * 2 + SystemInformation.VerticalScrollBarWidth; int oldWidth = this.imageListView1.Size.Width; this.imageListView1.Size = new Size(bestWidth, this.imageListView1.Height); this.Size = new Size(this.Width + bestWidth - oldWidth, this.Height); this.CenterToScreen(); }
public ThemeDialog() { InitializeComponent(); Localization.TranslateForm(this); this.Font = SystemFonts.MessageBoxFont; this.FormClosing += OnFormClosing; Size thumbnailSize = ThemeThumbLoader.GetThumbnailSize(this); int newWidth = (thumbnailSize.Width + 35) * 3 + SystemInformation.VerticalScrollBarWidth; int newHeight = (thumbnailSize.Height + this.Font.Height + 40) * 2; int oldWidth = this.imageListView1.Size.Width; int oldHeight = this.imageListView1.Size.Height; this.Size = new Size(this.Width + newWidth - this.imageListView1.Size.Width, this.Height + newHeight - this.imageListView1.Size.Height); this.CenterToScreen(); }
private void LoadImportedThemes(List <ThemeConfig> themes, ImportDialog importDialog) { themes.Sort((t1, t2) => t1.themeId.CompareTo(t2.themeId)); Size thumbnailSize = ThemeThumbLoader.GetThumbnailSize(this); ImageListViewItem newItem = null; Task.Run(() => { for (int i = 0; i < themes.Count; i++) { this.Invoke(new Action(() => EnsureThemeNotDuplicated(themes[i].themeId))); string themeName = ThemeManager.GetThemeName(themes[i]); themeNames.Add(themeName); themeNames.Sort(); int itemIndex = themeNames.IndexOf(themeName) + 1; using (Image thumbnailImage = ThemeThumbLoader.GetThumbnailImage(themes[i], thumbnailSize, false)) { this.Invoke(new Action(() => { imageListView1.Items.Insert(itemIndex, ThemeManager.GetThemeName(themes[i]), thumbnailImage); newItem = imageListView1.Items[itemIndex]; newItem.Tag = themes[i].themeId; })); } } if (newItem != null) { this.Invoke(new Action(() => { imageListView1.ClearSelection(); newItem.Selected = true; imageListView1.EnsureVisible(newItem.Index); })); } ThemeThumbLoader.CacheThumbnails(imageListView1.Items); importDialog.thumbnailsLoaded = true; this.Invoke(new Action(() => importDialog.Close())); }); }
private void ThemeDialog_Load(object sender, EventArgs e) { previewer = new WPF.ThemePreviewer(); previewerHost.Child = previewer; listView1.ContextMenuStrip = contextMenuStrip1; listView1.ListViewItemSorter = new CompareByItemText(); SetWindowTheme(listView1.Handle, "Explorer", null); ImageList imageList = new ImageList(); imageList.ColorDepth = ColorDepth.Depth32Bit; Size thumbnailSize = ThemeThumbLoader.GetThumbnailSize(this); imageList.ImageSize = thumbnailSize; listView1.LargeImageList = imageList; imageList.Images.Add(ThemeThumbLoader.ScaleImage(windowsWallpaper, thumbnailSize)); listView1.Items.Add(_("None"), 0); string[] displayNames = DisplayDevices.GetAllMonitorsFriendlyNames().ToArray(); for (int i = 0; i < displayNames.Length; i++) { displayComboBox.Items.Add(string.Format(_("Display {0} - {1}"), i + 1, displayNames[i])); } displayComboBox.Enabled = UwpDesktop.IsMultiDisplaySupported(); displayComboBox.SelectedIndex = 0; string activeTheme = ThemeManager.currentTheme?.themeId; if (!JsonConfig.IsNullOrEmpty(JsonConfig.settings.multiDisplayThemes)) { displayComboBox.SelectedIndex = 1; activeTheme = JsonConfig.settings.multiDisplayThemes[0]; } else if (activeTheme == null && (JsonConfig.firstRun || JsonConfig.settings.themeName != null)) { activeTheme = "Mojave_Desert"; } Task.Run(new Action(() => LoadThemes(ThemeManager.themeSettings, (activeTheme != null) ? activeTheme : ""))); }
private void LoadThemes(List <ThemeConfig> themes, string activeTheme = null) { Size thumbnailSize = ThemeThumbLoader.GetThumbnailSize(this); ListViewItem focusedItem = null; foreach (ThemeConfig theme in themes) { using (Image thumbnailImage = ThemeThumbLoader.GetThumbnailImage(theme, thumbnailSize, true)) { this.Invoke(new Action(() => { listView1.LargeImageList.Images.Add(thumbnailImage); ListViewItem newItem = listView1.Items.Add(ThemeManager.GetThemeName(theme), listView1.LargeImageList.Images.Count - 1); newItem.Tag = theme.themeId; if (activeTheme == null || activeTheme == theme.themeId) { focusedItem = newItem; } })); } } this.Invoke(new Action(() => { listView1.Sort(); if (focusedItem == null) { focusedItem = listView1.Items[0]; } focusedItem.Selected = true; listView1.EnsureVisible(focusedItem.Index); ThemeThumbLoader.CacheThumbnails(listView1); })); }
public ThemeDialog() { InitializeComponent(); Localization.TranslateForm(this); this.Font = SystemFonts.MessageBoxFont; this.FormClosing += OnFormClosing; this.FormClosed += OnFormClosed; Rectangle bounds = Screen.FromControl(this).Bounds; Size thumbnailSize = ThemeThumbLoader.GetThumbnailSize(this); int newWidth = thumbnailSize.Width + SystemInformation.VerticalScrollBarWidth + 46; int oldWidth = this.listView1.Size.Width; this.previewerHost.Anchor &= ~AnchorStyles.Left; this.listView1.Width = newWidth; this.downloadButton.Left += (newWidth - oldWidth) / 2; this.applyButton.Left += (newWidth - oldWidth) / 2; this.closeButton.Left += (newWidth - oldWidth) / 2; this.Width += (newWidth - oldWidth); this.previewerHost.Anchor |= AnchorStyles.Left; this.Size = new Size(bounds.Width * 5 / 8, bounds.Height * 5 / 8); this.CenterToScreen(); }