zoukankan      html  css  js  c++  java
  • 公共事件,修改主窗体和子窗体的(主题)样式

    主窗体修改主题样式时,同时修改子窗体的主题样式

    系统展示效果:

    一、项目结构

    二、代码分析

      SetAllFormStyle 界面对象参数

      

      

        /// <summary>
        /// 编写:yj
        /// 日期:2014-08-14
        /// 描述:系统界面参数
        /// </summary>
        public class SetAllFormStyle: System.EventArgs
        {
            public C1.Win.C1Ribbon.VisualStyle autoStyle { get; set; }
        }
    

       CommonStyle 全部公共对象

        /// <summary>
        /// 编写:yj
        /// 日期:2014-08-14
        /// 功能:公共静态事件
        /// </summary>
        public static class CommonStyle
        {
            public static C1.Win.C1Ribbon.VisualStyle AllFormSytle = C1.Win.C1Ribbon.VisualStyle.Office2007Blue;
    
            public static event EventHandler<SetAllFormStyle> RFIDReaderClick;
    
            public static void OnRFIDReaderClick(object sender, SetAllFormStyle e)
            {
                if (RFIDReaderClick != null)
                {
                    RFIDReaderClick(sender, e);
                }
            }
        }
    

      BaseForm.cs 基类文件

      

            private void BaseFrom_Load(object sender, EventArgs e)
            {
                CommonStyle.RFIDReaderClick += new EventHandler<SetAllFormStyle>(CommonStyle_RFIDReaderClick);
            }
    
            void CommonStyle_RFIDReaderClick(object sender, SetAllFormStyle e)
            {
                this.VisualStyle = e.autoStyle;
            }
    

       说明:在load方法中,注册公共事件。

      

      

      Form1.cs为设置窗体样式窗体

            private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
            {
                if (comboBox1.Text == "Office2010Blue")
                {
                    this.VisualStyle = C1.Win.C1Ribbon.VisualStyle.Office2010Blue;
                }
                else if (comboBox1.Text == "Office2010Silver")
                {
                    this.VisualStyle = C1.Win.C1Ribbon.VisualStyle.Office2010Silver;
                }
                else if (comboBox1.Text == "Office2010Black")
                {
                    this.VisualStyle = C1.Win.C1Ribbon.VisualStyle.Office2010Black;
                }
                else if (comboBox1.Text == "Office2007Blue")
                {
                    this.VisualStyle = C1.Win.C1Ribbon.VisualStyle.Office2007Blue;
                }
    
                SetAllFormStyle safs = new SetAllFormStyle();
                safs.autoStyle = this.VisualStyle;
                CommonStyle.OnRFIDReaderClick(sender, safs);
            }
    

         From2,Form3所有窗体都继承BaseForm,这样就可以实现,修改Form1的主题时,所有窗体的主题样式都改变了。

      

  • 相关阅读:
    尝试一个“建立知识”的过程
    webscheduler 开源定时服务和延迟服务
    两款自定义表单设计器
    IIS应用池保持激活工具开发
    写文章 使用conda管理python环境
    conda 虚拟环境
    Java设计模式
    转:数据标准化/归一化normalization
    转:理解矩阵
    转:为何梯度反方向是函数值下降最快的方向
  • 原文地址:https://www.cnblogs.com/ancient-sir/p/3912963.html
Copyright © 2011-2022 走看看