public static void SetTheme(ThemeDescription theme, Form theForm = null) { try { foreach (var form in theForm == null ? Application.OpenForms.Cast <Form>() : new[] { theForm }) { form.BackColor = theme.BackColor; form.ForeColor = theme.ForeColor; foreach (Control control in form.Controls) { if (!(control is LinkLabel)) { continue; } var link = control as LinkLabel; link.ForeColor = theme.ForeColor; link.LinkColor = theme.ForeColor; } } } catch { // ignore } }
public static void SetTheme(ThemeDescription theme, Form theForm = null) { try { foreach (var form in theForm == null ? Application.OpenForms.Cast <Form>() : new[] { theForm }) { form.BackColor = theme.BackColor; form.ForeColor = theme.ForeColor; foreach (Control control in form.Controls) { if (control is LinkLabel) { var link = control as LinkLabel; link.ForeColor = theme.ForeColor; link.LinkColor = theme.ForeColor; } else if (control is NumericUpDown) { control.BackColor = theme.BackColor; control.ForeColor = theme.ForeColor; } } } } catch (Exception ex) { util.Logger.Warn(ex); // ignore } }
private static void UpdateTheme(Button src, ThemeType type) { var theme = new ThemeDescription { ForeColor = src.ForeColor, BackColor = src.BackColor }; ThemeUtil.SetTheme(theme); Settings.Theme.Type = type; }