/// <summary> /// Reload the image icons to adapt DPI changes /// </summary> /// <param name="iconHeight">The height of toolbar icons</param> public void ReloadIcons(int iconHeight) { ToolbarIcons.ViewPreviousImage.Refresh(iconHeight); ToolbarIcons.ViewNextImage.Refresh(iconHeight); ToolbarIcons.RotateLeft.Refresh(iconHeight); ToolbarIcons.RotateRight.Refresh(iconHeight); ToolbarIcons.FlipHorz.Refresh(iconHeight); ToolbarIcons.FlipVert.Refresh(iconHeight); ToolbarIcons.Delete.Refresh(iconHeight); ToolbarIcons.Edit.Refresh(iconHeight); ToolbarIcons.Crop.Refresh(iconHeight); ToolbarIcons.ColorPicker.Refresh(iconHeight); ToolbarIcons.ZoomIn.Refresh(iconHeight); ToolbarIcons.ZoomOut.Refresh(iconHeight); ToolbarIcons.ScaleToFit.Refresh(iconHeight); ToolbarIcons.ActualSize.Refresh(iconHeight); ToolbarIcons.LockRatio.Refresh(iconHeight); ToolbarIcons.AutoZoom.Refresh(iconHeight); ToolbarIcons.ScaleToWidth.Refresh(iconHeight); ToolbarIcons.ScaleToHeight.Refresh(iconHeight); ToolbarIcons.ScaleToFill.Refresh(iconHeight); ToolbarIcons.AdjustWindowSize.Refresh(iconHeight); ToolbarIcons.OpenFile.Refresh(iconHeight); ToolbarIcons.Refresh.Refresh(iconHeight); ToolbarIcons.GoToImage.Refresh(iconHeight); ToolbarIcons.ThumbnailBar.Refresh(iconHeight); ToolbarIcons.Checkerboard.Refresh(iconHeight); ToolbarIcons.FullScreen.Refresh(iconHeight); ToolbarIcons.Slideshow.Refresh(iconHeight); ToolbarIcons.Convert.Refresh(iconHeight); ToolbarIcons.Print.Refresh(iconHeight); ToolbarIcons.Settings.Refresh(iconHeight); ToolbarIcons.About.Refresh(iconHeight); ToolbarIcons.Menu.Refresh(iconHeight); ToolbarIcons.ViewFirstImage.Refresh(iconHeight); ToolbarIcons.ViewLastImage.Refresh(iconHeight); #region Navigation arrows (derived from toolbar) var arrowHeight = (int)(DPIScaling.Transform(Constants.DEFAULT_TOOLBAR_ICON_HEIGHT) * NavArrowMultiplier); var navArrowTemp = new ThemeImage(ToolbarIcons.ViewPreviousImage.Filename, arrowHeight); navArrowTemp.Refresh(arrowHeight); NavArrowLeft = navArrowTemp.Image; navArrowTemp = new ThemeImage(ToolbarIcons.ViewNextImage.Filename, arrowHeight); navArrowTemp.Refresh(arrowHeight); NavArrowRight = navArrowTemp.Image; #endregion }
/// <summary> /// Read theme data from theme configuration file (Version 1.5+). /// Return TRUE if successful, FALSE if the theme format is invalid /// </summary> /// <param name="iconHeight">The height of toolbar icons</param> /// <param name="themeFolderPath">The absolute path of theme folder.</param> /// <returns></returns> public bool LoadTheme(int iconHeight, string themeFolderPath) { // check and process legacy config filename this.ConfigFilePath = ProcessLegacyTheme(themeFolderPath); this.FolderName = Path.GetFileName(themeFolderPath); // get folder name var dir = Path.GetDirectoryName(this.ConfigFilePath); var doc = new XmlDocument(); doc.Load(this.ConfigFilePath); var root = doc.DocumentElement; XmlElement nType = null; XmlElement n = null; try { //Load theme version 1.5+ as default nType = (XmlElement)root.SelectNodes("Theme")[0]; //<Theme> n = (XmlElement)nType.SelectNodes("Info")[0]; //<Info> } catch { this.IsValid = false; } #region Theme <Info> try { Name = n.GetAttribute("name"); } catch { } try { Version = n.GetAttribute("version"); } catch { } try { Author = n.GetAttribute("author"); } catch { } try { Email = n.GetAttribute("email"); } catch { } try { Website = n.GetAttribute("website"); } catch { } try { Description = n.GetAttribute("description"); } catch { } try { Type = n.GetAttribute("type"); } catch { } try { ConfigVersion = n.GetAttribute("configversion"); ConfigVersion = string.IsNullOrWhiteSpace(ConfigVersion) ? CONFIG_VERSION : ConfigVersion; } catch { } #endregion #region Theme <main> PreviewImage = LoadThemeImage(dir, n, "preview", iconHeight); n = (XmlElement)nType.SelectNodes("main")[0]; //<main> ToolbarBackgroundImage = LoadThemeImage(dir, n, "topbar", iconHeight); var color = FetchColorAttribute(n, "topbarcolor"); if (color != Color.Transparent) { ToolbarBackgroundColor = color; } ThumbnailBackgroundImage = LoadThemeImage(dir, n, "bottombar", iconHeight); color = FetchColorAttribute(n, "bottombarcolor"); if (color != Color.Transparent) { ThumbnailBackgroundColor = color; } color = FetchColorAttribute(n, "backcolor"); if (color != Color.Transparent) { BackgroundColor = color; } color = FetchColorAttribute(n, "statuscolor"); if (color != Color.Transparent) { TextInfoColor = color; } color = FetchColorAttribute(n, "menubackgroundcolor"); if (color != Color.Transparent) { MenuBackgroundColor = color; } color = FetchColorAttribute(n, "menubackgroundhovercolor"); if (color != Color.Transparent) { MenuBackgroundHoverColor = color; } color = FetchColorAttribute(n, "menutextcolor"); if (color != Color.Transparent) { MenuTextColor = color; } color = FetchColorAttribute(n, "menutexthovercolor"); if (color != Color.Transparent) { MenuTextHoverColor = color; } // For 7.6: add ability to control the size of the navigation arrows // Minimum value is 1.0, default is 2.0. try { var colorString = n.GetAttribute("navarrowsize"); if (!string.IsNullOrWhiteSpace(colorString)) { if (!double.TryParse(colorString, out var val)) { val = 2.0; } val = Math.Max(val, 1.0); NavArrowMultiplier = val; } } catch { } // v8.0: Accent colors color = FetchColorAttribute(n, "accentcolor"); if (color != Color.Transparent) { AccentColor = color; } color = FetchColorAttribute(n, "accentlightcolor"); if (color != Color.Transparent) { AccentLightColor = color; } color = FetchColorAttribute(n, "accentdarkcolor"); if (color != Color.Transparent) { AccentDarkColor = color; } // v8.0: Form icon Logo = LoadThemeImage(dir, n, "logo", 128); if (Logo.Image is null) { Logo.Image = Properties.Resources.DefaultLogo; } // v8.0: Show icon on title bar if (bool.TryParse(n.GetAttribute("isshowtitlebarlogo"), out var showLogo)) { IsShowTitlebarLogo = showLogo; } #endregion #region Theme <toolbar_icon> n = (XmlElement)nType.SelectNodes("toolbar_icon")[0]; //<toolbar_icon> ToolbarIcons.ViewPreviousImage = LoadThemeImage(dir, n, "back", iconHeight); ToolbarIcons.ViewNextImage = LoadThemeImage(dir, n, "next", iconHeight); ToolbarIcons.RotateLeft = LoadThemeImage(dir, n, "leftrotate", iconHeight); ToolbarIcons.RotateRight = LoadThemeImage(dir, n, "rightrotate", iconHeight); ToolbarIcons.FlipHorz = LoadThemeImage(dir, n, "fliphorz", iconHeight); ToolbarIcons.FlipVert = LoadThemeImage(dir, n, "flipvert", iconHeight); ToolbarIcons.Delete = LoadThemeImage(dir, n, "delete", iconHeight); ToolbarIcons.Edit = LoadThemeImage(dir, n, "edit", iconHeight); ToolbarIcons.Crop = LoadThemeImage(dir, n, "crop", iconHeight); ToolbarIcons.ColorPicker = LoadThemeImage(dir, n, "colorpicker", iconHeight); ToolbarIcons.ZoomIn = LoadThemeImage(dir, n, "zoomin", iconHeight); ToolbarIcons.ZoomOut = LoadThemeImage(dir, n, "zoomout", iconHeight); ToolbarIcons.ScaleToFit = LoadThemeImage(dir, n, "zoomtofit", iconHeight); ToolbarIcons.ActualSize = LoadThemeImage(dir, n, "scaletofit", iconHeight); ToolbarIcons.LockRatio = LoadThemeImage(dir, n, "zoomlock", iconHeight); ToolbarIcons.AutoZoom = LoadThemeImage(dir, n, "autozoom", iconHeight); ToolbarIcons.ScaleToWidth = LoadThemeImage(dir, n, "scaletowidth", iconHeight); ToolbarIcons.ScaleToHeight = LoadThemeImage(dir, n, "scaletoheight", iconHeight); ToolbarIcons.ScaleToFill = LoadThemeImage(dir, n, "scaletofill", iconHeight); ToolbarIcons.AdjustWindowSize = LoadThemeImage(dir, n, "autosizewindow", iconHeight); ToolbarIcons.OpenFile = LoadThemeImage(dir, n, "open", iconHeight); ToolbarIcons.Refresh = LoadThemeImage(dir, n, "refresh", iconHeight); ToolbarIcons.GoToImage = LoadThemeImage(dir, n, "gotoimage", iconHeight); ToolbarIcons.ThumbnailBar = LoadThemeImage(dir, n, "thumbnail", iconHeight); ToolbarIcons.Checkerboard = LoadThemeImage(dir, n, "checkerboard", iconHeight); ToolbarIcons.FullScreen = LoadThemeImage(dir, n, "fullscreen", iconHeight); ToolbarIcons.Slideshow = LoadThemeImage(dir, n, "slideshow", iconHeight); ToolbarIcons.Convert = LoadThemeImage(dir, n, "convert", iconHeight); ToolbarIcons.Print = LoadThemeImage(dir, n, "print", iconHeight); ToolbarIcons.Settings = LoadThemeImage(dir, n, "settings", iconHeight); ToolbarIcons.About = LoadThemeImage(dir, n, "about", iconHeight); ToolbarIcons.Menu = LoadThemeImage(dir, n, "menu", iconHeight); ToolbarIcons.ViewFirstImage = LoadThemeImage(dir, n, "gofirst", iconHeight); ToolbarIcons.ViewLastImage = LoadThemeImage(dir, n, "golast", iconHeight); #endregion #region Arrow cursors (derived from toolbar) var arrowHeight = (int)(DPIScaling.Transform(iconHeight) * NavArrowMultiplier); var navArrowTemp = new ThemeImage(ToolbarIcons.ViewPreviousImage.Filename, arrowHeight); navArrowTemp.Refresh(arrowHeight); NavArrowLeft = navArrowTemp.Image; NavArrowRight = new ThemeImage(ToolbarIcons.ViewNextImage.Filename, arrowHeight).Image; #endregion this.IsValid = true; return(this.IsValid);