Exemple #1
0
        public static bool BindSkin(this FormMain form, ToolStripDropDownButton btn, ToolStripStatusLabel lbl)
        {
            //初始化所有皮肤
            string[] skinFiles = Directory.GetFiles(Path.Combine(Application.StartupPath, "Data/Skins"));
            Array.ForEach(skinFiles, s =>
            {
                btn.DropDownItems.Add(Path.GetFileNameWithoutExtension(s), null, btn_Click);
            });
            _btn  = btn;
            _skin = new Sunisoft.IrisSkin.SkinEngine();
            _skin.AddForm(form);
            //读取配置文件,是否打开皮肤
            bool isopen = true;

            if (SettingHelper.ValueExists(section, Open))
            {
                isopen = SettingHelper.ReadBool(section, Open, true);
            }
            else
            {
                SettingHelper.WriteBool(section, Open, isopen);
            }
            _skin.Active      = isopen;
            _skin.SkinAllForm = false;

            string skinName = string.Empty;

            if (SettingHelper.ValueExists(section, Id))
            {
                skinName = SettingHelper.ReadString(section, Id, string.Empty);
                string skinFilePath = Path.Combine(Application.StartupPath, "Data/Skins", skinName + ".ssk");
                if (File.Exists(skinFilePath))
                {
                    _skin.SkinFile = skinFilePath;
                }
                else
                {
                    MessageBox.Show("皮肤文件缺失,请选择其他皮肤");
                }
            }
            else
            {
                skinName = "DeepCyan";
                SettingHelper.WriteString(section, Id, skinName);
                string skinFilePath = Path.Combine(Application.StartupPath, "Data/Skins", skinName + ".ssk");
                _skin.SkinFile = skinFilePath;
            }
            _btn.Text = skinName;
            SetSkinEnable(form, btn, isopen, lbl);
            return(isopen);
        }