示例#1
0
        /// <summary>
        /// Get the height of toolbar icon after applying DPI calculation
        /// </summary>
        /// <returns></returns>
        public static int GetCorrectIconHeight()
        {
            //Get Scaling factor
            double scaleFactor = DPIScaling.GetDPIScaleFactor();
            int    iconHeight  = (int)((int)Constants.TOOLBAR_ICON_HEIGHT * scaleFactor);

            return(iconHeight);
        }
示例#2
0
        /// <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="file"></param>
        /// <returns></returns>
        public bool LoadTheme(string file)
        {
            if (!File.Exists(file))
            {
                file = Path.Combine(GlobalSetting.StartUpDir, @"DefautTheme\config.xml");
            }

            string      dir = Path.GetDirectoryName(file);
            XmlDocument doc = new XmlDocument();

            doc.Load(file);

            XmlElement 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
            {
                return(false);
            }

            //Get Scaling factor
            double scaleFactor = DPIScaling.GetDPIScaleFactor();
            int    iconHeight  = (int)((int)Constants.TOOLBAR_ICON_HEIGHT * scaleFactor);

            #region Theme <Info>
            try { name = n.GetAttribute("name"); }
            catch (Exception ex) { };
            try { version = n.GetAttribute("version"); }
            catch (Exception ex) { };
            try { author = n.GetAttribute("author"); }
            catch (Exception ex) { };
            try { email = n.GetAttribute("email"); }
            catch (Exception ex) { };
            try { website = n.GetAttribute("website"); }
            catch (Exception ex) { };
            try { description = n.GetAttribute("description"); }
            catch (Exception ex) { };
            try { type = n.GetAttribute("type"); }
            catch (Exception ex) { };
            try { compatibility = n.GetAttribute("compatibility"); }
            catch (Exception ex) { };
            #endregion

            #region Theme <main>
            try
            {
                var imgFile = Path.Combine(dir, n.GetAttribute("preview"));
                PreviewImage = new ThemeImage(imgFile);
            }
            catch (Exception ex) { };

            n = (XmlElement)nType.SelectNodes("main")[0]; //<main>

            try
            {
                var imgFile = Path.Combine(dir, n.GetAttribute("topbar"));
                ToolbarBackgroundImage = new ThemeImage(imgFile);
            }
            catch (Exception ex) { };

            try
            {
                ToolbarBackgroundColor = Color.FromArgb(int.Parse(n.GetAttribute("topbarcolor")));
            }
            catch (Exception ex) { };

            try
            {
                var imgFile = Path.Combine(dir, n.GetAttribute("bottombar"));
                ThumbnailBackgroundImage = new ThemeImage(imgFile);
            }
            catch (Exception ex) { };

            try
            {
                ThumbnailBackgroundColor = Color.FromArgb(int.Parse(n.GetAttribute("bottombarcolor")));
            }
            catch (Exception ex) { };

            try
            {
                BackgroundColor = Color.FromArgb(int.Parse(n.GetAttribute("backcolor")));
            }
            catch (Exception ex) { };

            try
            {
                TextInfoColor = Color.FromArgb(int.Parse(n.GetAttribute("statuscolor")));
            }
            catch (Exception ex) { };
            #endregion

            #region Theme <toolbar_icon>
            n = (XmlElement)nType.SelectNodes("toolbar_icon")[0]; //<toolbar_icon>
            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("back"));
                ToolbarIcons.ViewPreviousImage = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("next"));
                ToolbarIcons.ViewNextImage = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("leftrotate"));
                ToolbarIcons.RotateLeft = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("rightrotate"));
                ToolbarIcons.RotateRight = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("zoomin"));
                ToolbarIcons.ZoomIn = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("zoomout"));
                ToolbarIcons.ZoomOut = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("scaletofit"));
                ToolbarIcons.ActualSize = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("zoomlock"));
                ToolbarIcons.LockRatio = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("scaletowidth"));
                ToolbarIcons.ScaleToWidth = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("scaletoheight"));
                ToolbarIcons.ScaleToHeight = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("autosizewindow"));
                ToolbarIcons.AdjustWindowSize = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("open"));
                ToolbarIcons.OpenFile = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("refresh"));
                ToolbarIcons.Refresh = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("gotoimage"));
                ToolbarIcons.GoToImage = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("thumbnail"));
                ToolbarIcons.ThumbnailBar = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("checkedbackground"));
                ToolbarIcons.CheckedBackground = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("fullscreen"));
                ToolbarIcons.FullScreen = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("slideshow"));
                ToolbarIcons.Slideshow = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("convert"));
                ToolbarIcons.Convert = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("print"));
                ToolbarIcons.Print = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("uploadfb"));
                ToolbarIcons.Sharing = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("extension"));
                ToolbarIcons.Plugins = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("settings"));
                ToolbarIcons.Settings = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("about"));
                ToolbarIcons.About = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };

            try
            {
                var iconFile = Path.Combine(dir, n.GetAttribute("menu"));
                ToolbarIcons.Menu = new ThemeImage(iconFile, iconHeight, iconHeight);
            }
            catch (Exception ex) { };
            #endregion

            return(true);
        }