Also apply dark theme to task settings, hotkey settings and about forms

This commit is contained in:
Jaex 2019-06-17 10:43:13 +03:00
parent 9253d3ff1c
commit 888f640714
6 changed files with 29 additions and 13 deletions

View file

@ -43,6 +43,7 @@ public static string UserAgent
public static bool UseDarkTheme { get; set; }
public static bool UseWhiteIcon { get; set; }
public static bool ApplyTheme { get; set; } = true;
public static Icon Icon => UseWhiteIcon ? Resources.ShareX_Icon_White : Resources.ShareX_Icon;
@ -51,16 +52,29 @@ public static string UserAgent
public static Color BackgroundColor => UseDarkTheme ? DarkBackgroundColor : SystemColors.Window;
public static Color TextColor => UseDarkTheme ? DarkTextColor : SystemColors.ControlText;
public static Color BorderColor => UseDarkTheme ? DarkBorderColor : ProfessionalColors.SeparatorDark;
public static Color CheckerColor1 => UseDarkTheme ? DarkCheckerColor1 : SystemColors.ControlLightLight;
public static Color CheckerColor2 => UseDarkTheme ? DarkCheckerColor2 : SystemColors.ControlLight;
public static Color DarkBackgroundColor { get; } = Color.FromArgb(42, 47, 56);
public static Color DarkTextColor { get; } = Color.FromArgb(235, 235, 235);
public static Color DarkBorderColor { get; } = Color.FromArgb(28, 32, 38);
public static Color DarkCheckerColor1 { get; } = Color.FromArgb(60, 60, 60);
public static Color DarkCheckerColor2 { get; } = Color.FromArgb(50, 50, 50);
public static int CheckerSize { get; } = 15;
public static Color CheckerColor1 => UseDarkTheme ? Color.FromArgb(60, 60, 60) : SystemColors.ControlLightLight;
public static Color CheckerColor2 => UseDarkTheme ? Color.FromArgb(50, 50, 50) : SystemColors.ControlLight;
public static void ApplyTheme(Control control)
public static void ApplyThemeToForm(Form form)
{
form.Icon = Icon;
if (ApplyTheme)
{
ApplyThemeToControl(form);
}
}
private static void ApplyThemeToControl(Control control)
{
if (control is Label ||
control is CheckBox ||
@ -85,7 +99,8 @@ public static void ApplyTheme(Control control)
control.ForeColor = TextColor;
}
if (control is Form || control is TabPage)
if (control is Form ||
control is TabPage)
{
control.BackColor = BackgroundColor;
}
@ -98,7 +113,7 @@ public static void ApplyTheme(Control control)
foreach (Control child in control.Controls)
{
ApplyTheme(child);
ApplyThemeToControl(child);
}
}
}

View file

@ -52,7 +52,8 @@ public HistoryForm(string historyPath, HistorySettings settings, Action<string>
Settings = settings;
InitializeComponent();
Icon = ShareXResources.Icon;
ShareXResources.ApplyThemeToForm(this);
defaultTitle = Text;
UpdateTitle();
@ -78,8 +79,6 @@ public HistoryForm(string historyPath, HistorySettings settings, Action<string>
scMain.SplitterDistance = Settings.SplitterDistance;
}
ShareXResources.ApplyTheme(this);
Settings.WindowState.AutoHandleFormState(this);
}

View file

@ -37,7 +37,8 @@ public partial class AboutForm : Form
public AboutForm()
{
InitializeComponent();
Icon = ShareXResources.Icon;
ShareXResources.ApplyThemeToForm(this);
lblProductName.Text = Program.Title;
pbLogo.Image = ShareXResources.Logo;

View file

@ -42,8 +42,7 @@ public partial class ApplicationSettingsForm : Form
public ApplicationSettingsForm()
{
InitializeControls();
Icon = ShareXResources.Icon;
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyThemeToForm(this);
}
private void SettingsForm_Shown(object sender, EventArgs e)

View file

@ -42,7 +42,8 @@ public partial class HotkeySettingsForm : Form
public HotkeySettingsForm(HotkeyManager hotkeyManager)
{
InitializeComponent();
Icon = ShareXResources.Icon;
ShareXResources.ApplyThemeToForm(this);
PrepareHotkeys(hotkeyManager);
}

View file

@ -48,7 +48,8 @@ public partial class TaskSettingsForm : Form
public TaskSettingsForm(TaskSettings hotkeySetting, bool isDefault = false)
{
InitializeComponent();
Icon = ShareXResources.Icon;
ShareXResources.ApplyThemeToForm(this);
TaskSettings = hotkeySetting;
IsDefault = isDefault;