Skip to content

Commit

Permalink
Add dark theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Palvenok committed Dec 5, 2022
1 parent bc314ca commit 5737da3
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 20 deletions.
3 changes: 3 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<setting name="CopyToClipboard" serializeAs="String">
<value>True</value>
</setting>
<setting name="DarkTheme" serializeAs="String">
<value>False</value>
</setting>
</Dropper.Properties.Settings>
</userSettings>
<appSettings>
Expand Down
5 changes: 4 additions & 1 deletion Dropper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Form1.ThemeChanger.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="KeyModifier.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down Expand Up @@ -143,7 +146,7 @@
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.8 %28x86 and x64%29</ProductName>
<ProductName>Microsoft .NET Framework 4.8 %28x86 и x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
Expand Down
31 changes: 26 additions & 5 deletions Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions Form1.ThemeChanger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System.Drawing;

namespace Dropper
{
partial class Form1
{
private Color _lightBG = Color.WhiteSmoke;
private Color _lightFG = Color.FromArgb(23, 23, 23);

private Color _darkBG = Color.FromArgb(23, 23, 23); //#2b2b2b
private Color _darkFG = Color.FromArgb(230, 230, 230); //#f1f1f1f

public void SetDarkTheme(bool enable)
{
if (enable)
SetColors(_darkBG, _darkFG);
else
SetColors(_lightBG, _lightFG);
}

private void SetColors(Color bg, Color fg)
{
this.BackColor = bg;
this.ForeColor = fg;

panel1.BackColor = bg;
CloseButton.BackColor = bg;
CloseButton.ForeColor = fg;
TitleBar.BackColor = bg;
TitleLable.BackColor = bg;
TitleLable.ForeColor = fg;

foreach(var item in textBoxes)
{
item.BackColor = bg;
item.ForeColor = fg;
}
}
}
}
31 changes: 17 additions & 14 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,12 @@ public partial class Form1 : Form
public Form1()
{
InitializeComponent();
LoadSettings();
TrayMenuInit();
TitleInit();
InteropServicesInit();

Region = System.Drawing.Region.FromHrgn(Utils.CreateRoundRectRgn(0, 0, Width, Height, 15, 15));

LoadSettings();

int id = 0;
Utils.RegisterHotKey(Handle, id, (int)KeyModifier.Alt + (int)KeyModifier.Shift, Keys.C.GetHashCode());
id = 1;
Utils.RegisterHotKey(Handle, id, (int)KeyModifier.Alt + (int)KeyModifier.Shift, Keys.H.GetHashCode());
SetDarkTheme(DarkThemeCheck.Checked);
}

protected override void WndProc(ref Message m)
Expand Down Expand Up @@ -67,6 +62,13 @@ private void VisualStateUpdate()
Hide();
}

private void LoadSettings()
{
this.CollapseCheck.Checked = Properties.Settings.Default.CollapseCheck;
this.CopyCheck.Checked = Properties.Settings.Default.CopyToClipboard;
this.DarkThemeCheck.Checked = Properties.Settings.Default.DarkTheme;
}

#region Notify menu button methods

private void MenuShowHistory_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -98,13 +100,13 @@ private void SettingsChanged(object sender, EventArgs e)
Properties.Settings.Default.CopyToClipboard = this.CopyCheck.Checked;
Properties.Settings.Default.Save();
break;
case "DarkThemeCheck":
Properties.Settings.Default.DarkTheme = this.DarkThemeCheck.Checked;
Properties.Settings.Default.Save();
SetDarkTheme(DarkThemeCheck.Checked);
break;
}
}
private void LoadSettings()
{
this.CollapseCheck.Checked = Properties.Settings.Default.CollapseCheck;
this.CopyCheck.Checked = Properties.Settings.Default.CopyToClipboard;
}

#endregion
#region Title bar methods
Expand Down Expand Up @@ -135,7 +137,8 @@ private void TitleMouseDown(object sender, MouseEventArgs e)
_startPoint = e.Location;
_isDrag = true;
}
#endregion

#endregion //==============================================

private void GetButtonColor(object sender, EventArgs e)
{
Expand Down
12 changes: 12 additions & 0 deletions Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
<Setting Name="CopyToClipboard" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="DarkTheme" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
Binary file modified Resources/icon.ico
Binary file not shown.

0 comments on commit 5737da3

Please sign in to comment.