利用DotNetBar控件打造漂亮的皮肤系统

利用DotNetBar控件打造漂亮的皮肤系统

利用DotNetBar控件打造漂亮的皮肤系统

利用DotNetBar控件打造漂亮的皮肤系统

利用DotNetBar控件打造漂亮的皮肤系统

 

以上是几个预览图片

 

使用的方法:1添加ribbonContro控件。2 添加引用和环境变量。3 右键添加button控件并设计IteamAlignment属性为 far 。3添加三个方法用于当鼠标移入颜色容器时将鼠标当前所在颜色设为窗体风格
具体步骤如下:
①添加添加ribbonContro控件    ②添加引用
using DevComponents.DotNetBar;
using DevComponents.DotNetBar.Controls;
using DevComponents.DotNetBar.Rendering;
③添加环境变量用于设计皮肤风格的字段,并用控件继承窗体。具体的位置如下:
public partial class Form1 : DevComponents.DotNetBar.Office2007RibbonForm
    {
        private bool _MColorSelected;
        private eOffice2007ColorScheme _MBaseColorScheme = eOffice2007ColorScheme.Blue;

④右键ribbonContro添加button控件并设计IteamAlignment属性为 far,并右键button添加9个子button控件用于设计窗体风格按钮在添加Color Picker控件(详见代码)
⑤分别双击9个button控件并加入相关代码:
private void Office2007Blue_Click(object sender, EventArgs e)
        {
            styleManager1.ManagerStyle = eStyle.Office2007Blue;
            
        }
private void Office2007Silver_Click(object sender, EventArgs e)
        {
            styleManager1.ManagerStyle = eStyle.Office2007Silver;
         
        }

        private void Office2007Black_Click(object sender, EventArgs e)
        {
            styleManager1.ManagerStyle = eStyle.Office2007Black;
        }

        private void Office2007VistaGlass_Click(object sender, EventArgs e)
        {
            styleManager1.ManagerStyle = eStyle.Office2007VistaGlass;
        }
        private void Office2010Blue_Click(object sender, EventArgs e)
        {
            styleManager1.ManagerStyle = eStyle.Office2010Blue;
        }

        private void Office2010Silver_Click(object sender, EventArgs e)
        {
            styleManager1.ManagerStyle = eStyle.Office2010Silver;
        }

        private void Office2010Black_Click(object sender, EventArgs e)
        {
            styleManager1.ManagerStyle = eStyle.Office2010Black;
        }

        private void VisualStudio2010Blue_Click(object sender, EventArgs e)
        {
            styleManager1.ManagerStyle = eStyle.VisualStudio2010Blue;
        }

        private void Windows7Blue_Click(object sender, EventArgs e)
        {
            styleManager1.ManagerStyle = eStyle.Windows7Blue;
        }
⑥双击Color Picker控件加入如下代码:
private void colorPickerDropDown1_SelectedColorChanged(object sender, EventArgs e)
        {
            _MColorSelected = true;

            RibbonPredefinedColorSchemes.ChangeOffice2007ColorTable(_MBaseColorScheme, colorPickerDropDown1.SelectedColor);
        }
⑦添加二个方法ColorPickerDropDown1_ColorPreview和ColorPickerDropDown1_ExpandChange用于当鼠标移入颜色容器时将鼠标当前所在颜色设为窗体风格
private void ColorPickerDropDown1_ColorPreview(object sender, ColorPreviewEventArgs e)
        {
            RibbonPredefinedColorSchemes.ChangeOffice2007ColorTable(_MBaseColorScheme, e.Color);
        }
        private void ColorPickerDropDown1_ExpandChange(object sender, EventArgs e)
        {
            if (colorPickerDropDown1.Expanded)
            {
               

                _MColorSelected = false;
                _MBaseColorScheme = ((Office2007Renderer)GlobalManager.Renderer).ColorTable.InitialColorScheme;
            }
            else
            {
                if (_MColorSelected == false)
                    RibbonPredefinedColorSchemes.ChangeOffice2007ColorTable(_MBaseColorScheme);
            }
        }
⑧选中Color Picker在事件中按照如下方法设计:
Colorpreview事件选中为 ColorPickerDropDown1_ColorPreview
ExpandChange事件选中为ColorPickerDropDown1_ExpandChange
⑨为了使选中的button右侧显示一个勾 分别设计9个button按钮的OptionGroup属性为style

 

 

 

 

你可能感兴趣的:(C#,窗体,皮肤)