diff --git a/Taskplay/Icons/BackwardDark.ico b/Taskplay/Icons/BackwardDark.ico new file mode 100644 index 0000000..a030c8b Binary files /dev/null and b/Taskplay/Icons/BackwardDark.ico differ diff --git a/Taskplay/Icons/ForwardDark.ico b/Taskplay/Icons/ForwardDark.ico new file mode 100644 index 0000000..826fa58 Binary files /dev/null and b/Taskplay/Icons/ForwardDark.ico differ diff --git a/Taskplay/Icons/PauseDark.ico b/Taskplay/Icons/PauseDark.ico new file mode 100644 index 0000000..d6c7529 Binary files /dev/null and b/Taskplay/Icons/PauseDark.ico differ diff --git a/Taskplay/Icons/PlayDark.ico b/Taskplay/Icons/PlayDark.ico new file mode 100644 index 0000000..add73d0 Binary files /dev/null and b/Taskplay/Icons/PlayDark.ico differ diff --git a/Taskplay/Icons/StopDark.ico b/Taskplay/Icons/StopDark.ico new file mode 100644 index 0000000..d98cf22 Binary files /dev/null and b/Taskplay/Icons/StopDark.ico differ diff --git a/Taskplay/Program.cs b/Taskplay/Program.cs index c83cb35..94cbf4f 100644 --- a/Taskplay/Program.cs +++ b/Taskplay/Program.cs @@ -8,6 +8,11 @@ static class Program { static bool _isMusicPlaying = false; // Bool to keep in check if the user is playing music + static bool IsDarkModeOn => GetSettingState("DarkMode"); + static bool AreChangeSongButtonsShown => GetSettingState("ShowChangeSongButtons"); + + static readonly Action restartAction = (b) => Application.Restart(); + /// /// The main entry point for the application. /// @@ -33,21 +38,21 @@ static void Main() contextMenu.MenuItems.Add(contextItemSettings); contextMenu.MenuItems.Add(contextItemExit); //Setup nextIcon - nextIcon.Icon = Properties.Resources.Forward; + nextIcon.Icon = IsDarkModeOn ? Properties.Resources.ForwardDark : Properties.Resources.Forward; nextIcon.Text = "Next"; - nextIcon.Visible = true; + nextIcon.Visible = AreChangeSongButtonsShown; nextIcon.MouseClick += new MouseEventHandler(nextIcon_MouseClick); nextIcon.ContextMenu = contextMenu; //Setup playIcon - playIcon.Icon = Properties.Resources.Play; + playIcon.Icon = IsDarkModeOn ? Properties.Resources.PlayDark : Properties.Resources.Play; playIcon.Text = "Play / Pause"; playIcon.Visible = true; playIcon.MouseClick += new MouseEventHandler(playIcon_MouseClick); playIcon.ContextMenu = contextMenu; //Setup previousIcon - previousIcon.Icon = Properties.Resources.Backward; + previousIcon.Icon = IsDarkModeOn ? Properties.Resources.BackwardDark : Properties.Resources.Backward; previousIcon.Text = "Previous"; - previousIcon.Visible = true; + previousIcon.Visible = AreChangeSongButtonsShown; previousIcon.MouseClick += new MouseEventHandler(previousIcon_MouseClick); previousIcon.ContextMenu = contextMenu; @@ -79,13 +84,13 @@ private static void playIcon_MouseClick(object sender, MouseEventArgs e) if (_isMusicPlaying == false) { // Start playing music and show the pause-icon - playIcon.Icon = Properties.Resources.Pause; + playIcon.Icon = IsDarkModeOn ? Properties.Resources.PauseDark : Properties.Resources.Pause; _isMusicPlaying = true; } else { // Pause the music and display the Play-icon - playIcon.Icon = Properties.Resources.Play; + playIcon.Icon = IsDarkModeOn ? Properties.Resources.PlayDark : Properties.Resources.Play; _isMusicPlaying = false; } } @@ -108,7 +113,8 @@ private static void nextIcon_MouseClick(object sender, MouseEventArgs e) private static void contextMenuSettings_Click(object sender, System.EventArgs e) { //Show Settings form - new SettingsForm().ShowDialog(); + var settingsForm = new SettingsForm(IsDarkModeOn, AreChangeSongButtonsShown, restartAction); + settingsForm.ShowDialog(); } private static void contextMenuExit_Click(object sender, System.EventArgs e) @@ -117,6 +123,21 @@ private static void contextMenuExit_Click(object sender, System.EventArgs e) Application.Exit(); } + private static bool GetSettingState(string settingName) + { + var subKey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Taskplay"); + + var keyValue = subKey.GetValue(settingName); + + if (keyValue == null) + { + subKey.SetValue(settingName, 0); + return false; + } + + return (int)keyValue == 1; + } + [DllImport("user32.dll", SetLastError = true)] public static extern void keybd_event(byte virtualKey, byte scanCode, uint flags, IntPtr extraInfo); } diff --git a/Taskplay/Properties/AssemblyInfo.cs b/Taskplay/Properties/AssemblyInfo.cs index 07f48be..177a9e9 100644 --- a/Taskplay/Properties/AssemblyInfo.cs +++ b/Taskplay/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.1.0")] +[assembly: AssemblyFileVersion("1.0.1.0")] diff --git a/Taskplay/Properties/Resources.Designer.cs b/Taskplay/Properties/Resources.Designer.cs index 73157ae..09d48f6 100644 --- a/Taskplay/Properties/Resources.Designer.cs +++ b/Taskplay/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace Taskplay.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -70,6 +70,16 @@ internal static System.Drawing.Icon Backward { } } + /// + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// + internal static System.Drawing.Icon BackwardDark { + get { + object obj = ResourceManager.GetObject("BackwardDark", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). /// @@ -80,6 +90,16 @@ internal static System.Drawing.Icon Forward { } } + /// + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// + internal static System.Drawing.Icon ForwardDark { + get { + object obj = ResourceManager.GetObject("ForwardDark", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). /// @@ -90,6 +110,16 @@ internal static System.Drawing.Icon Pause { } } + /// + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// + internal static System.Drawing.Icon PauseDark { + get { + object obj = ResourceManager.GetObject("PauseDark", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). /// @@ -100,6 +130,16 @@ internal static System.Drawing.Icon Play { } } + /// + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// + internal static System.Drawing.Icon PlayDark { + get { + object obj = ResourceManager.GetObject("PlayDark", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). /// @@ -109,5 +149,15 @@ internal static System.Drawing.Icon Stop { return ((System.Drawing.Icon)(obj)); } } + + /// + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// + internal static System.Drawing.Icon StopDark { + get { + object obj = ResourceManager.GetObject("StopDark", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } } } diff --git a/Taskplay/Properties/Resources.resx b/Taskplay/Properties/Resources.resx index 0a4d049..fc7fe00 100644 --- a/Taskplay/Properties/Resources.resx +++ b/Taskplay/Properties/Resources.resx @@ -133,4 +133,19 @@ ..\icons\stop.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Icons\BackwardDark.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Icons\ForwardDark.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Icons\PauseDark.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Icons\PlayDark.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Icons\StopDark.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/Taskplay/SettingsForm.Designer.cs b/Taskplay/SettingsForm.Designer.cs index 921d87e..59633fa 100644 --- a/Taskplay/SettingsForm.Designer.cs +++ b/Taskplay/SettingsForm.Designer.cs @@ -31,6 +31,7 @@ private void InitializeComponent() System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SettingsForm)); this.tabControl = new System.Windows.Forms.TabControl(); this.tabPageGeneral = new System.Windows.Forms.TabPage(); + this.checkBoxDarkMode = new System.Windows.Forms.CheckBox(); this.checkBoxAutorun = new System.Windows.Forms.CheckBox(); this.tabPageAbout = new System.Windows.Forms.TabPage(); this.linkLabelGitHub = new System.Windows.Forms.LinkLabel(); @@ -38,9 +39,9 @@ private void InitializeComponent() this.labelSuggestions = new System.Windows.Forms.Label(); this.labelVersion = new System.Windows.Forms.Label(); this.labelTaskplay = new System.Windows.Forms.Label(); - this.buttonApply = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button(); this.buttonOK = new System.Windows.Forms.Button(); + this.checkBoxShowSongChangeButtons = new System.Windows.Forms.CheckBox(); this.tabControl.SuspendLayout(); this.tabPageGeneral.SuspendLayout(); this.tabPageAbout.SuspendLayout(); @@ -60,21 +61,33 @@ private void InitializeComponent() // // tabPageGeneral // + this.tabPageGeneral.Controls.Add(this.checkBoxShowSongChangeButtons); + this.tabPageGeneral.Controls.Add(this.checkBoxDarkMode); this.tabPageGeneral.Controls.Add(this.checkBoxAutorun); - this.tabPageGeneral.Location = new System.Drawing.Point(4, 22); + this.tabPageGeneral.Location = new System.Drawing.Point(4, 32); this.tabPageGeneral.Name = "tabPageGeneral"; this.tabPageGeneral.Padding = new System.Windows.Forms.Padding(3); - this.tabPageGeneral.Size = new System.Drawing.Size(297, 156); + this.tabPageGeneral.Size = new System.Drawing.Size(297, 146); this.tabPageGeneral.TabIndex = 0; this.tabPageGeneral.Text = "General"; this.tabPageGeneral.UseVisualStyleBackColor = true; // + // checkBoxDarkMode + // + this.checkBoxDarkMode.AutoSize = true; + this.checkBoxDarkMode.Location = new System.Drawing.Point(6, 39); + this.checkBoxDarkMode.Name = "checkBoxDarkMode"; + this.checkBoxDarkMode.Size = new System.Drawing.Size(120, 27); + this.checkBoxDarkMode.TabIndex = 1; + this.checkBoxDarkMode.Text = "Dark mode"; + this.checkBoxDarkMode.UseVisualStyleBackColor = true; + // // checkBoxAutorun // this.checkBoxAutorun.AutoSize = true; this.checkBoxAutorun.Location = new System.Drawing.Point(6, 6); this.checkBoxAutorun.Name = "checkBoxAutorun"; - this.checkBoxAutorun.Size = new System.Drawing.Size(173, 17); + this.checkBoxAutorun.Size = new System.Drawing.Size(249, 27); this.checkBoxAutorun.TabIndex = 0; this.checkBoxAutorun.Text = "Start Taskplay with Windows"; this.checkBoxAutorun.UseVisualStyleBackColor = true; @@ -86,10 +99,10 @@ private void InitializeComponent() this.tabPageAbout.Controls.Add(this.labelSuggestions); this.tabPageAbout.Controls.Add(this.labelVersion); this.tabPageAbout.Controls.Add(this.labelTaskplay); - this.tabPageAbout.Location = new System.Drawing.Point(4, 22); + this.tabPageAbout.Location = new System.Drawing.Point(4, 32); this.tabPageAbout.Name = "tabPageAbout"; this.tabPageAbout.Padding = new System.Windows.Forms.Padding(3); - this.tabPageAbout.Size = new System.Drawing.Size(297, 156); + this.tabPageAbout.Size = new System.Drawing.Size(297, 146); this.tabPageAbout.TabIndex = 1; this.tabPageAbout.Text = "About"; this.tabPageAbout.UseVisualStyleBackColor = true; @@ -101,7 +114,7 @@ private void InitializeComponent() this.linkLabelGitHub.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline; this.linkLabelGitHub.Location = new System.Drawing.Point(214, 134); this.linkLabelGitHub.Name = "linkLabelGitHub"; - this.linkLabelGitHub.Size = new System.Drawing.Size(44, 13); + this.linkLabelGitHub.Size = new System.Drawing.Size(64, 23); this.linkLabelGitHub.TabIndex = 8; this.linkLabelGitHub.TabStop = true; this.linkLabelGitHub.Text = "GitHub"; @@ -113,7 +126,7 @@ private void InitializeComponent() this.labelContribute.AutoSize = true; this.labelContribute.Location = new System.Drawing.Point(6, 134); this.labelContribute.Name = "labelContribute"; - this.labelContribute.Size = new System.Drawing.Size(215, 13); + this.labelContribute.Size = new System.Drawing.Size(318, 23); this.labelContribute.TabIndex = 7; this.labelContribute.Text = "Feel free to contribute to the project on "; // @@ -123,7 +136,7 @@ private void InitializeComponent() this.labelSuggestions.AutoSize = true; this.labelSuggestions.Location = new System.Drawing.Point(6, 117); this.labelSuggestions.Name = "labelSuggestions"; - this.labelSuggestions.Size = new System.Drawing.Size(183, 13); + this.labelSuggestions.Size = new System.Drawing.Size(268, 23); this.labelSuggestions.TabIndex = 5; this.labelSuggestions.Text = "Got a suggestion or found a bug?"; // @@ -132,7 +145,7 @@ private void InitializeComponent() this.labelVersion.AutoSize = true; this.labelVersion.Location = new System.Drawing.Point(6, 24); this.labelVersion.Name = "labelVersion"; - this.labelVersion.Size = new System.Drawing.Size(60, 13); + this.labelVersion.Size = new System.Drawing.Size(90, 23); this.labelVersion.TabIndex = 4; this.labelVersion.Text = "Version {0}"; // @@ -141,24 +154,14 @@ private void InitializeComponent() this.labelTaskplay.AutoSize = true; this.labelTaskplay.Location = new System.Drawing.Point(6, 7); this.labelTaskplay.Name = "labelTaskplay"; - this.labelTaskplay.Size = new System.Drawing.Size(49, 13); + this.labelTaskplay.Size = new System.Drawing.Size(72, 23); this.labelTaskplay.TabIndex = 2; this.labelTaskplay.Text = "Taskplay"; // - // buttonApply - // - this.buttonApply.Location = new System.Drawing.Point(235, 192); - this.buttonApply.Name = "buttonApply"; - this.buttonApply.Size = new System.Drawing.Size(75, 23); - this.buttonApply.TabIndex = 1; - this.buttonApply.Text = "Apply"; - this.buttonApply.UseVisualStyleBackColor = true; - this.buttonApply.Click += new System.EventHandler(this.buttonApply_Click); - // // buttonCancel // this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(154, 192); + this.buttonCancel.Location = new System.Drawing.Point(228, 192); this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Size = new System.Drawing.Size(75, 23); this.buttonCancel.TabIndex = 2; @@ -168,7 +171,7 @@ private void InitializeComponent() // // buttonOK // - this.buttonOK.Location = new System.Drawing.Point(73, 192); + this.buttonOK.Location = new System.Drawing.Point(147, 192); this.buttonOK.Name = "buttonOK"; this.buttonOK.Size = new System.Drawing.Size(75, 23); this.buttonOK.TabIndex = 3; @@ -176,16 +179,25 @@ private void InitializeComponent() this.buttonOK.UseVisualStyleBackColor = true; this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); // + // checkBoxShowSongChangeButtons + // + this.checkBoxShowSongChangeButtons.AutoSize = true; + this.checkBoxShowSongChangeButtons.Location = new System.Drawing.Point(6, 72); + this.checkBoxShowSongChangeButtons.Name = "checkBoxShowSongChangeButtons"; + this.checkBoxShowSongChangeButtons.Size = new System.Drawing.Size(259, 27); + this.checkBoxShowSongChangeButtons.TabIndex = 4; + this.checkBoxShowSongChangeButtons.Text = "Show song changing buttons"; + this.checkBoxShowSongChangeButtons.UseVisualStyleBackColor = true; + // // SettingsForm // this.AcceptButton = this.buttonOK; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 23F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.buttonCancel; this.ClientSize = new System.Drawing.Size(315, 220); this.Controls.Add(this.buttonOK); this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonApply); this.Controls.Add(this.tabControl); this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; @@ -215,8 +227,9 @@ private void InitializeComponent() private System.Windows.Forms.Label labelSuggestions; private System.Windows.Forms.Label labelVersion; private System.Windows.Forms.LinkLabel linkLabelGitHub; - private System.Windows.Forms.Button buttonApply; private System.Windows.Forms.Button buttonCancel; private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.CheckBox checkBoxDarkMode; + private System.Windows.Forms.CheckBox checkBoxShowSongChangeButtons; } } \ No newline at end of file diff --git a/Taskplay/SettingsForm.cs b/Taskplay/SettingsForm.cs index b63883e..9b595f8 100644 --- a/Taskplay/SettingsForm.cs +++ b/Taskplay/SettingsForm.cs @@ -6,16 +6,28 @@ namespace Taskplay public partial class SettingsForm : Form { Microsoft.Win32.RegistryKey autorun; - public SettingsForm() + Microsoft.Win32.RegistryKey settings; + private readonly bool isDarkModeOn; + private readonly bool areChangeSongButtonsShown; + private readonly Action restartAction; + private bool isRestartNeeded = false; + + public SettingsForm(bool isDarkModeOn, bool areChangeSongButtonsShown, Action restartAction) { InitializeComponent(); autorun = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true); + settings = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Taskplay"); + this.isDarkModeOn = isDarkModeOn; + this.restartAction = restartAction; + this.areChangeSongButtonsShown = areChangeSongButtonsShown; } private void SettingsForm_Load(object sender, EventArgs e) { labelVersion.Text = String.Format("Version {0}", Application.ProductVersion); checkBoxAutorun.Checked = (autorun.GetValue("Taskplay") != null); + checkBoxDarkMode.Checked = isDarkModeOn; + checkBoxShowSongChangeButtons.Checked = areChangeSongButtonsShown; } private void SaveSettings() @@ -24,6 +36,12 @@ private void SaveSettings() autorun.SetValue("Taskplay", Application.ExecutablePath); else autorun.DeleteValue("Taskplay", false); + + settings.SetValue("DarkMode", checkBoxDarkMode.Checked ? 1 : 0); + settings.SetValue("ShowChangeSongButtons", checkBoxShowSongChangeButtons.Checked ? 1 : 0); + + isRestartNeeded = checkBoxDarkMode.Checked != isDarkModeOn + || checkBoxShowSongChangeButtons.Checked != areChangeSongButtonsShown; } private void linkLabelGitHub_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) @@ -31,11 +49,6 @@ private void linkLabelGitHub_LinkClicked(object sender, LinkLabelLinkClickedEven System.Diagnostics.Process.Start("https://github.com/evilpro/Taskplay"); } - private void buttonApply_Click(object sender, EventArgs e) - { - SaveSettings(); - } - private void buttonCancel_Click(object sender, EventArgs e) { Close(); @@ -45,6 +58,8 @@ private void buttonOK_Click(object sender, EventArgs e) { SaveSettings(); Close(); + if (isRestartNeeded) + restartAction(true); } } } diff --git a/Taskplay/Taskplay.csproj b/Taskplay/Taskplay.csproj index c6e8235..5d19468 100644 --- a/Taskplay/Taskplay.csproj +++ b/Taskplay/Taskplay.csproj @@ -116,10 +116,15 @@ + + + + + \ No newline at end of file