Exemple #1
0
        public void CheckMyFontAndColors()
        {
            this.Font = Settings.FormFont;
            foreach (Control c in this.Controls)
            {
                if (c is ToolStrip || c is MenuStrip)
                {
                    c.Font = this.Font;
                    foreach (var ti in (c as ToolStrip).Items)
                    {
                        if (ti is ToolStripComboBox)
                        {
                            (ti as ToolStripComboBox).Font = this.Font;
                        }
                    }
                }
                else
                {
                    if (!c.Font.Equals(this.Font))
                    {
                        c.Font = new Font(
                            this.Font.FontFamily,
                            this.Font.SizeInPoints,
                            c.Font.Style);
                    }
                }
            }
            MyColorTheme cth = Settings.ColorTheme;

            ColorThemeHelper.ApplyToForm(this, cth);
        }
Exemple #2
0
 public MyColorTable()
 {
     MyColorTheme    = ColorThemeHelper.ColorTheme_System;
     UseSystemColors = false;
 }
Exemple #3
0
 public MyColorTable(MyColorTheme theme)
 {
     MyColorTheme    = theme;
     UseSystemColors = false;
 }
Exemple #4
0
 public MyToolStripRenderer(MyColorTheme theme)
     : base(new MyColorTable(theme))
 {
     SetUp();
 }
Exemple #5
0
        public void SetColorTheme(MyColorTheme thene)
        {
            MyColorTable mc = this.ColorTable as MyColorTable;

            mc.MyColorTheme = thene;
        }
Exemple #6
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 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 MyLabel)
            {
                c.ForeColor = mycolortheme.GetColor(c.ForeColor, mycolortheme.ControlTextColor);
                (c as MyLabel).BorderColor = mycolortheme.GetColor((c as MyLabel).BorderColor, mycolortheme.BorderColor);
            }
            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 MyMcFlatComboBox)
            {
                c.ForeColor = mycolortheme.GetColor(c.ForeColor, mycolortheme.WindowTextColor);
                c.BackColor = mycolortheme.GetColor(c.BackColor, mycolortheme.WindowColor);
                (c as MyMcFlatComboBox).BorderColor = mycolortheme.GetColor((c as MyMcFlatComboBox).BorderColor, mycolortheme.BorderColor);
                (c as MyMcFlatComboBox).GridLineColor = mycolortheme.GetColor((c as MyMcFlatComboBox).GridLineColor, mycolortheme.ControlTextColor);
            }
            else if (c is MyMcComboBox)
            {
                c.ForeColor = mycolortheme.GetColor(c.ForeColor, mycolortheme.WindowTextColor);
                c.BackColor = mycolortheme.GetColor(c.BackColor, mycolortheme.WindowColor);
                (c as MyMcComboBox).GridLineColor = mycolortheme.GetColor((c as MyMcComboBox).GridLineColor, mycolortheme.ControlTextColor);
            }
            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 ListBox)
            {
                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);
            }
        }
Exemple #7
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;
            }
        }
Exemple #8
0
 public static void ApplyToForm(Form f, MyColorTheme mycolortheme)
 {
     ApplyToControlA(f, mycolortheme);
 }
Exemple #9
0
 protected void SetColorTheme(MyColorTheme theme)
 {
     ColorThemeHelper.ApplyToForm(this, theme);
 }