DevExpress13.2.9 控件使用经验总结

2018-01-12 08:20:05来源:cnblogs.com作者:大饼酥人点击

分享

一.换肤功能

  1. 添加 DevExpress.OfficeSkins 和 DevExpress.BonusSkins 两个引用

  2. 皮肤注册

DevExpress.UserSkins.BonusSkins.Register();DevExpress.Skins.SkinManager.EnableFormSkins();

  3. 加载皮肤列表,调用 SkinTools.LoadSkinList 函数

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows.Forms;using psi.Common;using psi.Interfaces;using DevExpress.Skins;using DevExpress.LookAndFeel;/*************************************************************************  * 程序说明: 设置皮肤工具 **************************************************************************/namespace psi.Library{    /// <summary>    /// 设置皮肤工具    /// </summary>    public class SkinTools    {        private static ToolStripMenuItem _CurrentSkinList = null;        /// <summary>        /// 加载皮肤列表        /// </summary>        public static void LoadSkinList(ToolStripMenuItem owner)        {            _CurrentSkinList = owner;            int skinCount = DevExpress.Skins.SkinManager.Default.Skins.Count;            ToolStripItem[] itemArr = new ToolStripItem[skinCount];            int index = 0;            foreach (DevExpress.Skins.SkinContainer skin in DevExpress.Skins.SkinManager.Default.Skins)            {                ToolStripMenuItem item = new ToolStripMenuItem();                item.Text = skin.SkinName;                item.Name = skin.SkinName;                item.Checked = skin.SkinName == SystemConfig.CurrentConfig.SkinName;                item.Click += new System.EventHandler(OnSetSkinClick);                itemArr[index] = item;                ++index;            }            owner.DropDownItems.AddRange(itemArr);        }        /// <summary>        /// 设置皮肤        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private static void OnSetSkinClick(object sender, EventArgs e)        {            ToolStripMenuItem clickItem = sender as ToolStripMenuItem;            SetSkin(clickItem.Name);            if (_CurrentSkinList != null)            {                foreach (ToolStripMenuItem item in _CurrentSkinList.DropDownItems)                {                    item.Checked = false;                }            }            clickItem.Checked = true;        }        public static void SetSkin(string skinName)        {            //设置所有窗体的皮肤            for (int i = 0; i < Application.OpenForms.Count - 1; i++)            {                Form form = Application.OpenForms[i];                if (form is IFormBase) (form as IFormBase).SetSkin(skinName);            }        }    }}

  4. 效果如下图

最新文章

123

最新摄影

闪念基因

微信扫一扫

第七城市微信公众平台