Exemplo n.º 1
0
        private void HandleControl(Control control, Dictionary <Type, ColorSet> colorSet)
        {
            FirefoxButton   button    = control as FirefoxButton;
            PanelBox        pb        = control as PanelBox;
            LinkLabel       linkLabel = control as LinkLabel;
            FirefoxCheckBox cb        = control as FirefoxCheckBox;

            if (button != null && colorSet.ContainsKey(button.GetType()))
            {
                var colorset = colorSet[button.GetType()];
                button.BackColor         = colorset.BackColor.Value;
                button.BackColorOverride = colorset.BackColor.Value;
                button.ForeColor         = colorset.ForeColor.Value;
                button.HoverColor        = colorset.HoverColor.Value;
                button.HoverForeColor    = colorset.HoverForeColor.Value;
            }
            else if (pb != null && colorSet.ContainsKey(pb.GetType()))
            {
                var colorset = colorSet[pb.GetType()];
                pb.BackColor   = colorset.BackColor.Value;
                pb.ForeColor   = colorset.ForeColor.Value;
                pb.HeaderColor = colorset.HeaderColor.Value;
            }
            else if (linkLabel != null && colorSet.ContainsKey(linkLabel.GetType()))
            {
                var colorset = colorSet[linkLabel.GetType()];
                linkLabel.BackColor = colorset.BackColor.Value;
                linkLabel.ForeColor = colorset.ForeColor.Value;
                linkLabel.LinkColor = colorset.LinkColor.Value;
            }
            else
            {
                if (colorSet.ContainsKey(control.GetType()))
                {
                    var colorset = colorSet[control.GetType()];
                    control.BackColor = colorset.BackColor ?? control.BackColor;
                    control.ForeColor = colorset.ForeColor ?? control.ForeColor;
                }
                else
                {
                    var colorset = colorSet[typeof(Control)];
                    control.BackColor = colorset.BackColor ?? control.BackColor;
                    control.ForeColor = colorset.ForeColor ?? control.ForeColor;
                }
            }

            if (cb != null)
            {
                cb.IsDarkMode = !_isLightMode;
            }

            control.Invalidate();
            control.Update();
        }