예제 #1
0
        public static void ApplyToControlA(object c0, MyColorTheme mycolortheme)
        {
            ApplyToControl(c0, mycolortheme);

            if (c0 is ToolStripMenuItem)
            {
                ToolStripMenuItem ti = c0 as ToolStripMenuItem;
                foreach (var c1 in ti.DropDownItems)
                {
                    ApplyToControlA(c1, mycolortheme);
                }
                return;
            }
            if (c0 is ToolStripDropDownButton)
            {
                ToolStripDropDownButton tdb = c0 as ToolStripDropDownButton;
                foreach (var c1 in tdb.DropDownItems)
                {
                    ApplyToControlA(c1, mycolortheme);
                }
                return;
            }

            Control c = null;

            if (c0 is Control)
            {
                c = c0 as Control;
            }
            if (c == null)
            {
                return;
            }

            if (c is ContainerControl || c is Panel)
            {
                foreach (Control c1 in c.Controls)
                {
                    ApplyToControlA(c1, mycolortheme);
                }
                return;
            }
            if (c is ToolStrip)
            {
                ToolStrip ts = c as ToolStrip;
                foreach (var c1 in ts.Items)
                {
                    ApplyToControlA(c1, mycolortheme);
                }
                return;
            }
            if (c is TabControl)
            {
                var tabc = c as TabControl;
                foreach (var page in tabc.TabPages)
                {
                    ApplyToControlA(page, mycolortheme);
                }
                return;
            }
            if (c is TabPage)
            {
                foreach (var c1 in c.Controls)
                {
                    ApplyToControlA(c1, mycolortheme);
                }
                return;
            }
        }
예제 #2
0
        public static void ApplyToControl(object c0, MyColorTheme mycolortheme)
        {
            //if (c0 is ToolStripSeparator) return;

            if (c0 is ToolStripMenuItem)
            {
                ToolStripMenuItem tmi = c0 as ToolStripMenuItem;
                tmi.ForeColor = mycolortheme.GetColor(tmi.ForeColor, mycolortheme.ControlTextColor);
                tmi.BackColor = mycolortheme.GetColor(tmi.BackColor, mycolortheme.ControlColor);
                ToolStripDropDownMenu tdd = tmi.DropDown as ToolStripDropDownMenu;
                if (tdd != null)
                {
                    tdd.ForeColor = mycolortheme.GetColor(tdd.ForeColor, mycolortheme.ControlTextColor);
                    //tdd.BackColor = mycolortheme.GetColor(tdd.BackColor, mycolortheme.ControlColorDark);
                }
                return;
            }
            if (c0 is ToolStripItem)
            {
                ToolStripItem tsi = c0 as ToolStripItem;
                tsi.ForeColor = mycolortheme.GetColor(tsi.ForeColor, mycolortheme.ControlTextColor);
                tsi.BackColor = mycolortheme.GetColor(tsi.BackColor, mycolortheme.ControlColor);
                return;
            }

            Control c = null;

            if (c0 is Control)
            {
                c = c0 as Control;
            }
            if (c == null)
            {
                return;
            }

            if (c is Form)
            {
                c.ForeColor = mycolortheme.GetColor(c.ForeColor, mycolortheme.ControlTextColor);
                c.BackColor = mycolortheme.GetColor(c.BackColor, mycolortheme.ControlColor);
            }
            else if (c is MdiClient)
            {
                c.BackColor = mycolortheme.GetColor(c.BackColor, mycolortheme.ControlColor);
            }
            else if (c is UserControl)
            {
                c.BackColor = mycolortheme.GetColor(c.BackColor, mycolortheme.ControlColor);
            }
            else if (c is MenuStrip)
            {
                MenuStrip ms = c as MenuStrip;
                if (ms.Renderer != MyToolStripRenderer)
                {
                    ms.Renderer = MyToolStripRenderer;
                }
                c.ForeColor = mycolortheme.GetColor(c.ForeColor, mycolortheme.ControlTextColor);
                c.BackColor = mycolortheme.GetColor(c.BackColor, mycolortheme.ControlColor);
            }
            else if (c is ToolStrip)
            {
                var tsp = c as ToolStrip;
                if (tsp.Renderer != MyToolStripRenderer)
                {
                    tsp.Renderer = MyToolStripRenderer;
                }
                c.ForeColor = mycolortheme.GetColor(c.ForeColor, mycolortheme.ControlTextColor);
                c.BackColor = mycolortheme.GetColor(c.BackColor, mycolortheme.ControlColor);
            }
            else if (c is TabPage)
            {
                c.ForeColor = mycolortheme.GetColor(c.ForeColor, mycolortheme.ControlTextColor);
                c.BackColor = mycolortheme.GetColor(c.BackColor, mycolortheme.ControlColor);
            }
            else if (c is Label)
            {
                c.ForeColor = mycolortheme.GetColor(c.ForeColor, mycolortheme.ControlTextColor);
            }
            else if (c is MyTextBox)
            {
                c.ForeColor = mycolortheme.GetColor(c.ForeColor, mycolortheme.WindowTextColor);
                c.BackColor = mycolortheme.GetColor(c.BackColor, mycolortheme.WindowColor);
                (c as MyTextBox).BorderColor = mycolortheme.GetColor((c as MyTextBox).BorderColor, mycolortheme.BorderColor);
            }
            else if (c is TextBox)
            {
                c.ForeColor = mycolortheme.GetColor(c.ForeColor, mycolortheme.WindowTextColor);
                c.BackColor = mycolortheme.GetColor(c.BackColor, mycolortheme.WindowColor);
            }
            else if (c is FlatComboBox)
            {
                c.ForeColor = mycolortheme.GetColor(c.ForeColor, mycolortheme.WindowTextColor);
                c.BackColor = mycolortheme.GetColor(c.BackColor, mycolortheme.WindowColor);
                (c as FlatComboBox).BorderColor = mycolortheme.GetColor((c as FlatComboBox).BorderColor, mycolortheme.BorderColor);
            }
            else if (c is ComboBox)
            {
                c.ForeColor = mycolortheme.GetColor(c.ForeColor, mycolortheme.WindowTextColor);
                c.BackColor = mycolortheme.GetColor(c.BackColor, mycolortheme.WindowColor);
            }
            else if (c is ListBox)
            {
                c.ForeColor = mycolortheme.GetColor(c.ForeColor, mycolortheme.WindowTextColor);
                c.BackColor = mycolortheme.GetColor(c.BackColor, mycolortheme.WindowColor);
            }
            else if (c is ListView)
            {
                c.ForeColor = mycolortheme.GetColor(c.ForeColor, mycolortheme.WindowTextColor);
                c.BackColor = mycolortheme.GetColor(c.BackColor, mycolortheme.WindowColor);
            }
            else if (c is PropertyGrid)
            {
                var prgr = c as PropertyGrid;
                prgr.BackColor         = mycolortheme.GetColor(prgr.BackColor, mycolortheme.WindowColor);
                prgr.ViewBackColor     = prgr.BackColor;
                prgr.ViewForeColor     = mycolortheme.GetColor(prgr.ViewForeColor, mycolortheme.ControlTextColor);
                prgr.LineColor         = mycolortheme.GetColor(prgr.LineColor, mycolortheme.ControlColorDark);
                prgr.CategoryForeColor = prgr.BackColor;
                //prgr.CategorySplitterColor = prgr.ViewForeColor;
                //prgr.CategoryForeColor = mycolortheme.GetColor(prgr.CategoryForeColor, mycolortheme.ForeColor);
                //prgr.CategorySplitterColor = mycolortheme.GetColor(prgr.CategorySplitterColor, mycolortheme.ControlColor);
            }
            else if (c is DataGridView)
            {
                var dgv = c as DataGridView;
                dgv.BackColor = mycolortheme.GetColor(dgv.BackColor, mycolortheme.ControlColor);

                dgv.BackgroundColor = mycolortheme.GetColor(dgv.BackColor, mycolortheme.ControlColor);

                dgv.GridColor = mycolortheme.GetColor(dgv.GridColor, mycolortheme.ControlColorDark);

                dgv.DefaultCellStyle.BackColor =
                    mycolortheme.GetColor(dgv.DefaultCellStyle.BackColor, mycolortheme.WindowColor);

                dgv.DefaultCellStyle.ForeColor =
                    mycolortheme.GetColor(dgv.DefaultCellStyle.ForeColor, mycolortheme.WindowTextColor);

                dgv.ColumnHeadersDefaultCellStyle.BackColor =
                    mycolortheme.GetColor(dgv.ColumnHeadersDefaultCellStyle.BackColor, mycolortheme.ControlColor);

                dgv.ColumnHeadersDefaultCellStyle.ForeColor =
                    mycolortheme.GetColor(dgv.ColumnHeadersDefaultCellStyle.ForeColor, mycolortheme.ControlTextColor);

                dgv.RowHeadersDefaultCellStyle.BackColor =
                    mycolortheme.GetColor(dgv.RowHeadersDefaultCellStyle.BackColor, mycolortheme.ControlColor);

                dgv.RowHeadersDefaultCellStyle.ForeColor =
                    mycolortheme.GetColor(dgv.RowHeadersDefaultCellStyle.ForeColor, mycolortheme.ControlTextColor);
            }

            /*else if (c is MyGrid)
             * {
             *  var mygrid = c as MyGrid;
             *  mygrid.ApplyColorTheme(mycolortheme);
             * }*/
        }
예제 #3
0
 public static void ApplyToForm(Form f, MyColorTheme mycolortheme)
 {
     ApplyToControlA(f, mycolortheme);
 }
 public MyColorTable()
 {
     MyColorTheme    = ColorThemeHelper.ColorTheme_System;
     UseSystemColors = false;
 }
 public MyColorTable(MyColorTheme theme)
 {
     MyColorTheme    = theme;
     UseSystemColors = false;
 }
 public MyToolStripRenderer(MyColorTheme theme)
     : base(new MyColorTable(theme))
 {
     SetUp();
 }
        public void SetColorTheme(MyColorTheme thene)
        {
            MyColorTable mc = this.ColorTable as MyColorTable;

            mc.MyColorTheme = thene;
        }