Beispiel #1
0
        /// <summary>
        /// 根据皮肤ID加载窗体皮肤
        /// </summary>
        public static void LoadSkin(string skinID)
        {
            try
            {
                string skinPath = AppDomain.CurrentDomain.BaseDirectory + Constant.THEMES_PATH + skinID + @"\";
                if (Directory.Exists(skinPath))
                {
                    string skinXmlFile = skinPath + Constant.SKIN_XML;
                    if (File.Exists(skinXmlFile))
                    {
                        Skin skin = new Skin();
                        skin.SkinID = skinID;
                        skin.Name = XmlUtil.ReadValue(skinXmlFile, Constant.SKIN_XPATH_SKIN_NAME);
                        skin.FrameBkgName = XmlUtil.ReadValue(skinXmlFile, Constant.SKIN_XPATH_FRAME_BKG);
                        skin.FrameBkg = Image.FromFile(skinPath + skin.FrameBkgName);
                        skin.SkinViewName = XmlUtil.ReadValue(skinXmlFile, Constant.SKIN_XPATH_SKIN_VIEW);
                        skin.SkinView = Image.FromFile(skinPath + skin.SkinViewName);

                        // Icon Text Color
                        skin.IconTextColor = ColorTranslator.FromHtml(XmlUtil.ReadValue(skinXmlFile, Constant.SKIN_XPATH_ICON_TEXT_COLOR));

                        FormInstanceManager.Instance.FormMain.LoadSkin(skin);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                FormInstanceManager.Instance.FormMain.LoadSkin(new Skin(defaultFrameBkg, defaultIconTextColor));
            }
        }
Beispiel #2
0
        /// <summary>
        /// 加载皮肤
        /// </summary>
        public void LoadSkin(Skin skin)
        {
            if (skin != null)
            {
                // 设置窗体背景图片
                if (skin.FrameBkg != null)
                {
                    this.BackgroundImage = skin.FrameBkg;
                }

                // 设置窗体头部按钮文字颜色
                foreach (var headerBtn in this.headerPanel.HeaderButtons)
                {
                    headerBtn.ForeColor = skin.IconTextColor;
                }
            }

            // 保存当前皮肤
            Config.SkinID = skin.SkinID;
        }