Apply dark theme partially to history form

This commit is contained in:
Jaex 2019-06-17 09:35:21 +03:00
parent 62a1016e1b
commit 299b29c386
4 changed files with 69 additions and 49 deletions

View file

@ -49,6 +49,9 @@ public static string UserAgent
public static Image Logo => Resources.ShareX_Logo; public static Image Logo => Resources.ShareX_Logo;
public static Image LogoBlack => Resources.ShareX_Logo_Black; public static Image LogoBlack => Resources.ShareX_Logo_Black;
public static Color BackgroundColor => UseDarkTheme ? DarkBackgroundColor : SystemColors.Window;
public static Color TextColor => UseDarkTheme ? DarkTextColor : SystemColors.ControlText;
public static Color DarkBackgroundColor { get; } = Color.FromArgb(42, 47, 56); public static Color DarkBackgroundColor { get; } = Color.FromArgb(42, 47, 56);
public static Color DarkTextColor { get; } = Color.FromArgb(235, 235, 235); public static Color DarkTextColor { get; } = Color.FromArgb(235, 235, 235);
public static Color DarkBorderColor { get; } = Color.FromArgb(28, 32, 38); public static Color DarkBorderColor { get; } = Color.FromArgb(28, 32, 38);
@ -56,5 +59,40 @@ public static string UserAgent
public static int CheckerSize { get; } = 15; public static int CheckerSize { get; } = 15;
public static Color CheckerColor1 => UseDarkTheme ? Color.FromArgb(60, 60, 60) : SystemColors.ControlLightLight; 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 Color CheckerColor2 => UseDarkTheme ? Color.FromArgb(50, 50, 50) : SystemColors.ControlLight;
public static void ApplyTheme(Control parent)
{
foreach (Control control in parent.Controls)
{
if (control is Label || control is CheckBox || control is RichTextBox)
{
control.ForeColor = TextColor;
control.BackColor = BackgroundColor;
}
if (control is Button)
{
control.ForeColor = SystemColors.ControlText;
}
if (control is GroupBox)
{
control.ForeColor = TextColor;
}
if (control is Form)
{
control.BackColor = BackgroundColor;
}
if (control is SplitContainer sc)
{
sc.Panel1.BackColor = BackgroundColor;
sc.Panel2.BackColor = BackgroundColor;
}
ApplyTheme(control);
}
}
} }
} }

View file

@ -31,13 +31,13 @@ private void InitializeComponent()
{ {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HistoryForm)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HistoryForm));
this.scMain = new ShareX.HelpersLib.SplitContainerCustomSplitter(); this.scMain = new ShareX.HelpersLib.SplitContainerCustomSplitter();
this.pStats = new System.Windows.Forms.Panel();
this.rtbStats = new System.Windows.Forms.RichTextBox(); this.rtbStats = new System.Windows.Forms.RichTextBox();
this.lvHistory = new ShareX.HelpersLib.MyListView(); this.lvHistory = new ShareX.HelpersLib.MyListView();
this.chIcon = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chIcon = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chDateTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chDateTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chFilename = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chFilename = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chURL = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chURL = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.panel1 = new System.Windows.Forms.Panel();
this.btnShowStats = new System.Windows.Forms.Button(); this.btnShowStats = new System.Windows.Forms.Button();
this.pbThumbnail = new ShareX.HelpersLib.MyPictureBox(); this.pbThumbnail = new ShareX.HelpersLib.MyPictureBox();
this.gbFilters = new System.Windows.Forms.GroupBox(); this.gbFilters = new System.Windows.Forms.GroupBox();
@ -56,14 +56,12 @@ private void InitializeComponent()
this.cbDateFilter = new System.Windows.Forms.CheckBox(); this.cbDateFilter = new System.Windows.Forms.CheckBox();
this.dtpFilterTo = new System.Windows.Forms.DateTimePicker(); this.dtpFilterTo = new System.Windows.Forms.DateTimePicker();
this.txtFilenameFilter = new System.Windows.Forms.TextBox(); this.txtFilenameFilter = new System.Windows.Forms.TextBox();
this.pStats = new System.Windows.Forms.Panel();
((System.ComponentModel.ISupportInitialize)(this.scMain)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.scMain)).BeginInit();
this.scMain.Panel1.SuspendLayout(); this.scMain.Panel1.SuspendLayout();
this.scMain.Panel2.SuspendLayout(); this.scMain.Panel2.SuspendLayout();
this.scMain.SuspendLayout(); this.scMain.SuspendLayout();
this.panel1.SuspendLayout();
this.gbFilters.SuspendLayout();
this.pStats.SuspendLayout(); this.pStats.SuspendLayout();
this.gbFilters.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// scMain // scMain
@ -79,11 +77,19 @@ private void InitializeComponent()
// //
// scMain.Panel2 // scMain.Panel2
// //
this.scMain.Panel2.Controls.Add(this.panel1); this.scMain.Panel2.Controls.Add(this.btnShowStats);
this.scMain.Panel2.Controls.Add(this.pbThumbnail);
this.scMain.Panel2.Controls.Add(this.gbFilters);
this.scMain.SplitterColor = System.Drawing.Color.White; this.scMain.SplitterColor = System.Drawing.Color.White;
this.scMain.SplitterLineColor = System.Drawing.Color.FromArgb(((int)(((byte)(189)))), ((int)(((byte)(189)))), ((int)(((byte)(189))))); this.scMain.SplitterLineColor = System.Drawing.Color.FromArgb(((int)(((byte)(189)))), ((int)(((byte)(189)))), ((int)(((byte)(189)))));
this.scMain.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.scMain_SplitterMoved); this.scMain.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.scMain_SplitterMoved);
// //
// pStats
//
this.pStats.Controls.Add(this.rtbStats);
resources.ApplyResources(this.pStats, "pStats");
this.pStats.Name = "pStats";
//
// rtbStats // rtbStats
// //
this.rtbStats.BorderStyle = System.Windows.Forms.BorderStyle.None; this.rtbStats.BorderStyle = System.Windows.Forms.BorderStyle.None;
@ -128,14 +134,6 @@ private void InitializeComponent()
// //
resources.ApplyResources(this.chURL, "chURL"); resources.ApplyResources(this.chURL, "chURL");
// //
// panel1
//
this.panel1.Controls.Add(this.btnShowStats);
this.panel1.Controls.Add(this.pbThumbnail);
this.panel1.Controls.Add(this.gbFilters);
resources.ApplyResources(this.panel1, "panel1");
this.panel1.Name = "panel1";
//
// btnShowStats // btnShowStats
// //
resources.ApplyResources(this.btnShowStats, "btnShowStats"); resources.ApplyResources(this.btnShowStats, "btnShowStats");
@ -260,12 +258,6 @@ private void InitializeComponent()
resources.ApplyResources(this.txtFilenameFilter, "txtFilenameFilter"); resources.ApplyResources(this.txtFilenameFilter, "txtFilenameFilter");
this.txtFilenameFilter.Name = "txtFilenameFilter"; this.txtFilenameFilter.Name = "txtFilenameFilter";
// //
// pStats
//
this.pStats.Controls.Add(this.rtbStats);
resources.ApplyResources(this.pStats, "pStats");
this.pStats.Name = "pStats";
//
// HistoryForm // HistoryForm
// //
resources.ApplyResources(this, "$this"); resources.ApplyResources(this, "$this");
@ -281,10 +273,9 @@ private void InitializeComponent()
this.scMain.Panel2.ResumeLayout(false); this.scMain.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.scMain)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.scMain)).EndInit();
this.scMain.ResumeLayout(false); this.scMain.ResumeLayout(false);
this.panel1.ResumeLayout(false); this.pStats.ResumeLayout(false);
this.gbFilters.ResumeLayout(false); this.gbFilters.ResumeLayout(false);
this.gbFilters.PerformLayout(); this.gbFilters.PerformLayout();
this.pStats.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@ -297,7 +288,6 @@ private void InitializeComponent()
private System.Windows.Forms.ColumnHeader chURL; private System.Windows.Forms.ColumnHeader chURL;
private System.Windows.Forms.ColumnHeader chIcon; private System.Windows.Forms.ColumnHeader chIcon;
private ShareX.HelpersLib.SplitContainerCustomSplitter scMain; private ShareX.HelpersLib.SplitContainerCustomSplitter scMain;
private System.Windows.Forms.Panel panel1;
private HelpersLib.MyPictureBox pbThumbnail; private HelpersLib.MyPictureBox pbThumbnail;
private System.Windows.Forms.GroupBox gbFilters; private System.Windows.Forms.GroupBox gbFilters;
private System.Windows.Forms.ComboBox cbHostFilterSelection; private System.Windows.Forms.ComboBox cbHostFilterSelection;

View file

@ -78,9 +78,16 @@ public HistoryForm(string historyPath, HistorySettings settings, Action<string>
scMain.SplitterDistance = Settings.SplitterDistance; scMain.SplitterDistance = Settings.SplitterDistance;
} }
UpdateTheme();
Settings.WindowState.AutoHandleFormState(this); Settings.WindowState.AutoHandleFormState(this);
} }
public void UpdateTheme()
{
ShareXResources.ApplyTheme(this);
}
private void RefreshHistoryItems() private void RefreshHistoryItems()
{ {
allHistoryItems = GetHistoryItems(); allHistoryItems = GetHistoryItems();

View file

@ -252,6 +252,9 @@
<data name="btnShowStats.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms"> <data name="btnShowStats.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left</value> <value>Bottom, Left</value>
</data> </data>
<data name="btnShowStats.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="btnShowStats.Location" type="System.Drawing.Point, System.Drawing"> <data name="btnShowStats.Location" type="System.Drawing.Point, System.Drawing">
<value>8, 608</value> <value>8, 608</value>
</data> </data>
@ -271,7 +274,7 @@
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<data name="&gt;&gt;btnShowStats.Parent" xml:space="preserve"> <data name="&gt;&gt;btnShowStats.Parent" xml:space="preserve">
<value>panel1</value> <value>scMain.Panel2</value>
</data> </data>
<data name="&gt;&gt;btnShowStats.ZOrder" xml:space="preserve"> <data name="&gt;&gt;btnShowStats.ZOrder" xml:space="preserve">
<value>0</value> <value>0</value>
@ -295,7 +298,7 @@
<value>ShareX.HelpersLib.MyPictureBox, ShareX.HelpersLib, Version=13.0.0.0, Culture=neutral, PublicKeyToken=null</value> <value>ShareX.HelpersLib.MyPictureBox, ShareX.HelpersLib, Version=13.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data> </data>
<data name="&gt;&gt;pbThumbnail.Parent" xml:space="preserve"> <data name="&gt;&gt;pbThumbnail.Parent" xml:space="preserve">
<value>panel1</value> <value>scMain.Panel2</value>
</data> </data>
<data name="&gt;&gt;pbThumbnail.ZOrder" xml:space="preserve"> <data name="&gt;&gt;pbThumbnail.ZOrder" xml:space="preserve">
<value>1</value> <value>1</value>
@ -306,6 +309,9 @@
<data name="lblURLFilter.AutoSize" type="System.Boolean, mscorlib"> <data name="lblURLFilter.AutoSize" type="System.Boolean, mscorlib">
<value>True</value> <value>True</value>
</data> </data>
<data name="lblURLFilter.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="lblURLFilter.Location" type="System.Drawing.Point, System.Drawing"> <data name="lblURLFilter.Location" type="System.Drawing.Point, System.Drawing">
<value>13, 48</value> <value>13, 48</value>
</data> </data>
@ -354,6 +360,9 @@
<data name="lblFilenameFilter.AutoSize" type="System.Boolean, mscorlib"> <data name="lblFilenameFilter.AutoSize" type="System.Boolean, mscorlib">
<value>True</value> <value>True</value>
</data> </data>
<data name="lblFilenameFilter.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="lblFilenameFilter.Location" type="System.Drawing.Point, System.Drawing"> <data name="lblFilenameFilter.Location" type="System.Drawing.Point, System.Drawing">
<value>13, 24</value> <value>13, 24</value>
</data> </data>
@ -706,35 +715,11 @@
<value>System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<data name="&gt;&gt;gbFilters.Parent" xml:space="preserve"> <data name="&gt;&gt;gbFilters.Parent" xml:space="preserve">
<value>panel1</value> <value>scMain.Panel2</value>
</data> </data>
<data name="&gt;&gt;gbFilters.ZOrder" xml:space="preserve"> <data name="&gt;&gt;gbFilters.ZOrder" xml:space="preserve">
<value>2</value> <value>2</value>
</data> </data>
<data name="panel1.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="panel1.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 0</value>
</data>
<data name="panel1.Size" type="System.Drawing.Size, System.Drawing">
<value>425, 641</value>
</data>
<data name="panel1.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="&gt;&gt;panel1.Name" xml:space="preserve">
<value>panel1</value>
</data>
<data name="&gt;&gt;panel1.Type" xml:space="preserve">
<value>System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;panel1.Parent" xml:space="preserve">
<value>scMain.Panel2</value>
</data>
<data name="&gt;&gt;panel1.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="&gt;&gt;scMain.Panel2.Name" xml:space="preserve"> <data name="&gt;&gt;scMain.Panel2.Name" xml:space="preserve">
<value>scMain.Panel2</value> <value>scMain.Panel2</value>
</data> </data>