From b511e0268379a35f5ba63f0523eb88310cdc37ae Mon Sep 17 00:00:00 2001 From: Jonas Kohl Date: Fri, 26 Feb 2021 13:55:34 +0100 Subject: [PATCH] Version 3.10.0.0 --- .../CapsLockIndicatorV3.csproj | 16 ++ .../DownloadDialog.Designer.cs | 1 - CapsLockIndicatorV3/DownloadDialog.cs | 42 +++- .../FirstRunDialog.Designer.cs | 231 +++++++++++++++++ CapsLockIndicatorV3/FirstRunDialog.cs | 83 ++++++ CapsLockIndicatorV3/FirstRunDialog.resx | 123 +++++++++ .../IndSettingsWindow.Designer.cs | 75 +++++- CapsLockIndicatorV3/IndSettingsWindow.cs | 101 ++++++++ .../IndicatorOverlay.Designer.cs | 7 +- CapsLockIndicatorV3/IndicatorOverlay.cs | 163 +++++++----- CapsLockIndicatorV3/MColorPicker.cs | 220 ++++++++++++++++ CapsLockIndicatorV3/MFontPicker.cs | 238 ++++++++++++++++++ CapsLockIndicatorV3/MainForm.Designer.cs | 98 +++++--- CapsLockIndicatorV3/MainForm.cs | 87 ++++++- CapsLockIndicatorV3/MainForm.resx | 3 + CapsLockIndicatorV3/Native.cs | 8 +- CapsLockIndicatorV3/Program.cs | 66 +++-- .../Properties/AssemblyInfo.cs | 6 +- .../Resources/defaultSettings.txt | 11 +- .../Resources/logo_dark.Image.png | Bin 0 -> 999 bytes CapsLockIndicatorV3/SettingsManager.cs | 30 ++- CapsLockIndicatorV3/UpdateDialog.cs | 33 ++- CapsLockIndicatorV3/VersionCheck.cs | 2 +- CapsLockIndicatorV3/resources.Designer.cs | 56 +++-- CapsLockIndicatorV3/resources.resx | 3 + CapsLockIndicatorV3/strings.Designer.cs | 81 ++++++ CapsLockIndicatorV3/strings.de.resx | 29 ++- CapsLockIndicatorV3/strings.resx | 36 +++ 28 files changed, 1666 insertions(+), 183 deletions(-) create mode 100644 CapsLockIndicatorV3/FirstRunDialog.Designer.cs create mode 100644 CapsLockIndicatorV3/FirstRunDialog.cs create mode 100644 CapsLockIndicatorV3/FirstRunDialog.resx create mode 100644 CapsLockIndicatorV3/MColorPicker.cs create mode 100644 CapsLockIndicatorV3/MFontPicker.cs create mode 100644 CapsLockIndicatorV3/Resources/logo_dark.Image.png diff --git a/CapsLockIndicatorV3/CapsLockIndicatorV3.csproj b/CapsLockIndicatorV3/CapsLockIndicatorV3.csproj index 72b3f46..29b59dd 100644 --- a/CapsLockIndicatorV3/CapsLockIndicatorV3.csproj +++ b/CapsLockIndicatorV3/CapsLockIndicatorV3.csproj @@ -82,6 +82,12 @@ + + Form + + + FirstRunDialog.cs + Form @@ -114,6 +120,12 @@ MainForm.cs + + Component + + + Component + Form @@ -157,6 +169,9 @@ DownloadDialog.cs + + FirstRunDialog.cs + HelpWindow.cs @@ -193,6 +208,7 @@ + diff --git a/CapsLockIndicatorV3/DownloadDialog.Designer.cs b/CapsLockIndicatorV3/DownloadDialog.Designer.cs index e3b3bd6..5b3773a 100644 --- a/CapsLockIndicatorV3/DownloadDialog.Designer.cs +++ b/CapsLockIndicatorV3/DownloadDialog.Designer.cs @@ -116,7 +116,6 @@ private void InitializeComponent() this.Controls.Add(this.statusLabel); this.Controls.Add(this.downloadProgress); this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "DownloadDialog"; diff --git a/CapsLockIndicatorV3/DownloadDialog.cs b/CapsLockIndicatorV3/DownloadDialog.cs index 46de86c..6e0bd42 100644 --- a/CapsLockIndicatorV3/DownloadDialog.cs +++ b/CapsLockIndicatorV3/DownloadDialog.cs @@ -2,7 +2,9 @@ using System; using System.ComponentModel; using System.Diagnostics; +using System.Drawing; using System.IO; +using System.Linq; using System.Net; using System.Threading; using System.Windows.Forms; @@ -27,10 +29,41 @@ protected override void WndProc(ref Message message) public DownloadDialog() { InitializeComponent(); - } + if (SettingsManager.Get("beta_enableDarkMode")) + { + HandleCreated += DownloadDialog_HandleCreated; + + statusLabel.ForeColor = + infoLabel.ForeColor = + Color.White; + + BackColor = Color.FromArgb(255, 32, 32, 32); + ForeColor = Color.White; + + ControlScheduleSetDarkMode(downloadProgress); + ControlScheduleSetDarkMode(restartButton); + ControlScheduleSetDarkMode(closeButton); + ControlScheduleSetDarkMode(cancelButton); + } + } + + private void DownloadDialog_HandleCreated(object sender, EventArgs e) + { + Native.UseImmersiveDarkModeColors(Handle, true); + } + + private void ControlScheduleSetDarkMode(Control control) + { + control.HandleCreated += (sender, e) => + { + Native.ControlSetDarkMode(control, true); + }; + } + public void Download(string url) - { + { +#if !DEBUG Uri uri = new Uri(url); string filename = Path.GetFileName(uri.LocalPath); string currentPath = Path.GetDirectoryName(Application.ExecutablePath); @@ -45,6 +78,7 @@ public void Download(string url) Client.DownloadFileAsync(new Uri(url), path); newPath = path; +#endif } private void DownloadProgressCallback(object sender, DownloadProgressChangedEventArgs e) @@ -100,11 +134,13 @@ private void restartButton_Click(object sender, EventArgs e) rk.SetValue("CapsLock Indicator", newPath); } - MainForm mainForm = (MainForm) Application.OpenForms["mainForm"]; + MainForm mainForm = Application.OpenForms.OfType().First(); mainForm.askCancel = false; Program.ReleaseMutex(); + Thread.Sleep(100); + Process.Start(newPath); Application.Exit(); } diff --git a/CapsLockIndicatorV3/FirstRunDialog.Designer.cs b/CapsLockIndicatorV3/FirstRunDialog.Designer.cs new file mode 100644 index 0000000..cd1d0f7 --- /dev/null +++ b/CapsLockIndicatorV3/FirstRunDialog.Designer.cs @@ -0,0 +1,231 @@ + +namespace CapsLockIndicatorV3 +{ + partial class FirstRunDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FirstRunDialog)); + this.headerLabel = new System.Windows.Forms.Label(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.flowLayoutPanel2 = new System.Windows.Forms.FlowLayoutPanel(); + this.exitButton = new System.Windows.Forms.Button(); + this.okButton = new System.Windows.Forms.Button(); + this.messageLabel = new System.Windows.Forms.Label(); + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.allowUpdatesCheckBox = new System.Windows.Forms.CheckBox(); + this.lnkLabel1 = new CapsLockIndicatorV3.LnkLabel(); + this.lnkLabel2 = new CapsLockIndicatorV3.LnkLabel(); + this.tableLayoutPanel1.SuspendLayout(); + this.flowLayoutPanel2.SuspendLayout(); + this.flowLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // headerLabel + // + this.headerLabel.AutoSize = true; + this.tableLayoutPanel1.SetColumnSpan(this.headerLabel, 2); + this.headerLabel.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.headerLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(51)))), ((int)(((byte)(153))))); + this.headerLabel.Location = new System.Drawing.Point(0, 0); + this.headerLabel.Margin = new System.Windows.Forms.Padding(0, 0, 0, 9); + this.headerLabel.Name = "headerLabel"; + this.headerLabel.Size = new System.Drawing.Size(227, 21); + this.headerLabel.TabIndex = 0; + this.headerLabel.Text = "Welcome to CapsLock Indicator"; + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 2; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.Controls.Add(this.lnkLabel2, 0, 3); + this.tableLayoutPanel1.Controls.Add(this.headerLabel, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.messageLabel, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 0, 2); + this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel2, 1, 3); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(9, 9); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 4; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.Size = new System.Drawing.Size(343, 239); + this.tableLayoutPanel1.TabIndex = 1; + // + // flowLayoutPanel2 + // + this.flowLayoutPanel2.Anchor = System.Windows.Forms.AnchorStyles.Right; + this.flowLayoutPanel2.AutoSize = true; + this.flowLayoutPanel2.Controls.Add(this.exitButton); + this.flowLayoutPanel2.Controls.Add(this.okButton); + this.flowLayoutPanel2.Location = new System.Drawing.Point(184, 210); + this.flowLayoutPanel2.Margin = new System.Windows.Forms.Padding(0); + this.flowLayoutPanel2.Name = "flowLayoutPanel2"; + this.flowLayoutPanel2.Size = new System.Drawing.Size(159, 29); + this.flowLayoutPanel2.TabIndex = 3; + // + // exitButton + // + this.exitButton.Anchor = System.Windows.Forms.AnchorStyles.Right; + this.exitButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.exitButton.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.exitButton.Location = new System.Drawing.Point(3, 3); + this.exitButton.Margin = new System.Windows.Forms.Padding(3, 3, 0, 3); + this.exitButton.Name = "exitButton"; + this.exitButton.Size = new System.Drawing.Size(75, 23); + this.exitButton.TabIndex = 3; + this.exitButton.Text = "&Exit"; + this.exitButton.UseVisualStyleBackColor = true; + // + // okButton + // + this.okButton.Anchor = System.Windows.Forms.AnchorStyles.Right; + this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.okButton.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.okButton.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold); + this.okButton.Location = new System.Drawing.Point(81, 3); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(75, 23); + this.okButton.TabIndex = 2; + this.okButton.Text = "&Let\'s go!"; + this.okButton.UseVisualStyleBackColor = true; + this.okButton.Click += new System.EventHandler(this.okButton_Click); + // + // messageLabel + // + this.messageLabel.AutoSize = true; + this.tableLayoutPanel1.SetColumnSpan(this.messageLabel, 2); + this.messageLabel.Dock = System.Windows.Forms.DockStyle.Top; + this.messageLabel.Location = new System.Drawing.Point(0, 30); + this.messageLabel.Margin = new System.Windows.Forms.Padding(0); + this.messageLabel.Name = "messageLabel"; + this.messageLabel.Size = new System.Drawing.Size(343, 75); + this.messageLabel.TabIndex = 1; + this.messageLabel.Text = resources.GetString("messageLabel.Text"); + // + // flowLayoutPanel1 + // + this.tableLayoutPanel1.SetColumnSpan(this.flowLayoutPanel1, 2); + this.flowLayoutPanel1.Controls.Add(this.allowUpdatesCheckBox); + this.flowLayoutPanel1.Controls.Add(this.lnkLabel1); + this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; + this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 111); + this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0, 6, 0, 0); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(343, 99); + this.flowLayoutPanel1.TabIndex = 3; + // + // allowUpdatesCheckBox + // + this.allowUpdatesCheckBox.Checked = true; + this.allowUpdatesCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; + this.allowUpdatesCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.allowUpdatesCheckBox.Location = new System.Drawing.Point(0, 0); + this.allowUpdatesCheckBox.Margin = new System.Windows.Forms.Padding(0); + this.allowUpdatesCheckBox.Name = "allowUpdatesCheckBox"; + this.allowUpdatesCheckBox.Size = new System.Drawing.Size(312, 38); + this.allowUpdatesCheckBox.TabIndex = 0; + this.allowUpdatesCheckBox.Text = "Allow CapsLock Indicator to periodically check for updates online (can be changed" + + " later)"; + this.allowUpdatesCheckBox.UseCompatibleTextRendering = true; + this.allowUpdatesCheckBox.UseVisualStyleBackColor = true; + this.allowUpdatesCheckBox.CheckedChanged += new System.EventHandler(this.allowUpdatesCheckBox_CheckedChanged); + // + // lnkLabel1 + // + this.lnkLabel1.AutoSize = true; + this.lnkLabel1.LinkColor = System.Drawing.SystemColors.HotTrack; + this.lnkLabel1.Location = new System.Drawing.Point(13, 38); + this.lnkLabel1.Margin = new System.Windows.Forms.Padding(13, 0, 0, 0); + this.lnkLabel1.Name = "lnkLabel1"; + this.lnkLabel1.Size = new System.Drawing.Size(168, 15); + this.lnkLabel1.TabIndex = 1; + this.lnkLabel1.TabStop = true; + this.lnkLabel1.Text = "What information will be sent?"; + this.lnkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkLabel1_LinkClicked); + // + // lnkLabel2 + // + this.lnkLabel2.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lnkLabel2.AutoSize = true; + this.lnkLabel2.LinkColor = System.Drawing.SystemColors.HotTrack; + this.lnkLabel2.Location = new System.Drawing.Point(0, 217); + this.lnkLabel2.Margin = new System.Windows.Forms.Padding(0); + this.lnkLabel2.Name = "lnkLabel2"; + this.lnkLabel2.Size = new System.Drawing.Size(64, 15); + this.lnkLabel2.TabIndex = 4; + this.lnkLabel2.TabStop = true; + this.lnkLabel2.Text = "Contribute"; + this.lnkLabel2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkLabel2_LinkClicked); + // + // FirstRunDialog + // + this.AcceptButton = this.okButton; + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.BackColor = System.Drawing.SystemColors.Window; + this.CancelButton = this.exitButton; + this.ClientSize = new System.Drawing.Size(361, 257); + this.ControlBox = false; + this.Controls.Add(this.tableLayoutPanel1); + this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.ForeColor = System.Drawing.SystemColors.WindowText; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "FirstRunDialog"; + this.Padding = new System.Windows.Forms.Padding(9); + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "CapsLock Indicator"; + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.flowLayoutPanel2.ResumeLayout(false); + this.flowLayoutPanel1.ResumeLayout(false); + this.flowLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label headerLabel; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label messageLabel; + private System.Windows.Forms.Button okButton; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; + private System.Windows.Forms.CheckBox allowUpdatesCheckBox; + private LnkLabel lnkLabel1; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel2; + private System.Windows.Forms.Button exitButton; + private LnkLabel lnkLabel2; + } +} \ No newline at end of file diff --git a/CapsLockIndicatorV3/FirstRunDialog.cs b/CapsLockIndicatorV3/FirstRunDialog.cs new file mode 100644 index 0000000..960b2f5 --- /dev/null +++ b/CapsLockIndicatorV3/FirstRunDialog.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Diagnostics; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace CapsLockIndicatorV3 +{ + public partial class FirstRunDialog : Form + { + public FirstRunDialog() + { + InitializeComponent(); + if (SettingsManager.Get("beta_enableDarkMode")) + { + HandleCreated += FirstRunDialog_HandleCreated; + + headerLabel.ForeColor = + messageLabel.ForeColor = + lnkLabel1.LinkColor = + lnkLabel2.LinkColor = + allowUpdatesCheckBox.ForeColor = + Color.White; + + allowUpdatesCheckBox.FlatStyle = FlatStyle.Standard; + + BackColor = Color.FromArgb(255, 32, 32, 32); + ForeColor = Color.White; + + ControlScheduleSetDarkMode(okButton); + ControlScheduleSetDarkMode(exitButton); + } + + headerLabel.Text = strings.firstRunHeading; + messageLabel.Text = strings.firstRunMessage; + allowUpdatesCheckBox.Text = strings.firstRunAllowUpdateCheck; + lnkLabel1.Text = strings.firstRunPrivacyInfoLinkLabel; + lnkLabel2.Text = strings.firstRunContribute; + okButton.Text = strings.firstRunStart; + exitButton.Text = strings.firstRunExit; + } + + private void FirstRunDialog_HandleCreated(object sender, EventArgs e) + { + Native.UseImmersiveDarkModeColors(Handle, true); + } + + private void ControlScheduleSetDarkMode(Control control) + { + control.HandleCreated += (sender, e) => + { + Native.ControlSetDarkMode(control, true); + }; + } + + private void allowUpdatesCheckBox_CheckedChanged(object sender, EventArgs e) + { + SettingsManager.Set("checkForUpdates", allowUpdatesCheckBox.Checked); + SettingsManager.Save(); + } + + private void lnkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + Process.Start("https://cli.jonaskohl.de/kb/?a=updatecheck"); + } + + private void okButton_Click(object sender, EventArgs e) + { + SettingsManager.Set("checkForUpdates", allowUpdatesCheckBox.Checked); + SettingsManager.Save(); + } + + private void lnkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + Process.Start("https://github.com/jonaskohl/CapsLockIndicator"); + } + } +} diff --git a/CapsLockIndicatorV3/FirstRunDialog.resx b/CapsLockIndicatorV3/FirstRunDialog.resx new file mode 100644 index 0000000..16fbaa1 --- /dev/null +++ b/CapsLockIndicatorV3/FirstRunDialog.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Thank you for choosing CapsLock Indicator! This program is open-source and free, always has been, always will be! Are you interested in contributing to CapsLock Indicator yourself? Visit the link below for more information! Also, please take a moment to review the settings below! + + \ No newline at end of file diff --git a/CapsLockIndicatorV3/IndSettingsWindow.Designer.cs b/CapsLockIndicatorV3/IndSettingsWindow.Designer.cs index bd880cf..68c23b3 100644 --- a/CapsLockIndicatorV3/IndSettingsWindow.Designer.cs +++ b/CapsLockIndicatorV3/IndSettingsWindow.Designer.cs @@ -47,10 +47,10 @@ private void InitializeComponent() this.foregroundColourActivatedButton = new System.Windows.Forms.Button(); this.backgroundColourActivatedPreview = new System.Windows.Forms.PictureBox(); this.backgroundColourActivatedButton = new System.Windows.Forms.Button(); - this.mainColourPicker = new System.Windows.Forms.ColorDialog(); + this.mainColourPicker = new CapsLockIndicatorV3.MColorPicker(); this.fontGroupBox = new System.Windows.Forms.GroupBox(); this.fontButton = new System.Windows.Forms.Button(); - this.indFontChooser = new System.Windows.Forms.FontDialog(); + this.indFontChooser = new CapsLockIndicatorV3.MFontPicker(); this.positionGroup = new System.Windows.Forms.GroupBox(); this.positionButtonLayout = new System.Windows.Forms.TableLayoutPanel(); this.positionBottomRight = new System.Windows.Forms.RadioButton(); @@ -65,6 +65,10 @@ private void InitializeComponent() this.opacityGroup = new System.Windows.Forms.GroupBox(); this.opacityLabel = new System.Windows.Forms.Label(); this.opacitySlider = new System.Windows.Forms.TrackBar(); + this.borderGroup = new System.Windows.Forms.GroupBox(); + this.bdSizeLabel = new System.Windows.Forms.Label(); + this.bdSizeSlider = new System.Windows.Forms.TrackBar(); + this.lnkLabel1 = new CapsLockIndicatorV3.LnkLabel(); this.displayTimeGroup.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.displayTimeSlider)).BeginInit(); this.coloursGroup.SuspendLayout(); @@ -79,6 +83,8 @@ private void InitializeComponent() this.positionButtonLayout.SuspendLayout(); this.opacityGroup.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.opacitySlider)).BeginInit(); + this.borderGroup.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.bdSizeSlider)).BeginInit(); this.SuspendLayout(); // // displayTimeGroup @@ -109,9 +115,9 @@ private void InitializeComponent() // this.displayTimeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Right))); - this.displayTimeLabel.Location = new System.Drawing.Point(159, 35); + this.displayTimeLabel.Location = new System.Drawing.Point(162, 22); this.displayTimeLabel.Name = "displayTimeLabel"; - this.displayTimeLabel.Size = new System.Drawing.Size(76, 40); + this.displayTimeLabel.Size = new System.Drawing.Size(76, 45); this.displayTimeLabel.TabIndex = 1; this.displayTimeLabel.Text = "500 ms"; this.displayTimeLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -511,6 +517,54 @@ private void InitializeComponent() this.opacitySlider.Value = 100; this.opacitySlider.Scroll += new System.EventHandler(this.opacitySlider_Scroll); // + // borderGroup + // + this.borderGroup.Controls.Add(this.bdSizeLabel); + this.borderGroup.Controls.Add(this.bdSizeSlider); + this.borderGroup.Location = new System.Drawing.Point(262, 248); + this.borderGroup.Name = "borderGroup"; + this.borderGroup.Size = new System.Drawing.Size(244, 70); + this.borderGroup.TabIndex = 3; + this.borderGroup.TabStop = false; + this.borderGroup.Text = "Border thickness"; + // + // bdSizeLabel + // + this.bdSizeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.bdSizeLabel.Location = new System.Drawing.Point(159, 35); + this.bdSizeLabel.Name = "bdSizeLabel"; + this.bdSizeLabel.Size = new System.Drawing.Size(76, 15); + this.bdSizeLabel.TabIndex = 1; + this.bdSizeLabel.Text = "4"; + this.bdSizeLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.bdSizeLabel.Click += new System.EventHandler(this.bdSizeLabel_Click); + // + // bdSizeSlider + // + this.bdSizeSlider.LargeChange = 10; + this.bdSizeSlider.Location = new System.Drawing.Point(6, 22); + this.bdSizeSlider.Maximum = 32; + this.bdSizeSlider.Name = "bdSizeSlider"; + this.bdSizeSlider.Size = new System.Drawing.Size(147, 45); + this.bdSizeSlider.TabIndex = 0; + this.bdSizeSlider.TickFrequency = 4; + this.bdSizeSlider.TickStyle = System.Windows.Forms.TickStyle.Both; + this.bdSizeSlider.Value = 32; + this.bdSizeSlider.Scroll += new System.EventHandler(this.bdSizeSlider_Scroll); + // + // lnkLabel1 + // + this.lnkLabel1.AutoSize = true; + this.lnkLabel1.LinkColor = System.Drawing.SystemColors.HotTrack; + this.lnkLabel1.Location = new System.Drawing.Point(264, 349); + this.lnkLabel1.Name = "lnkLabel1"; + this.lnkLabel1.Size = new System.Drawing.Size(104, 15); + this.lnkLabel1.TabIndex = 12; + this.lnkLabel1.TabStop = true; + this.lnkLabel1.Text = "Advanced settings"; + this.lnkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkLabel1_LinkClicked); + // // IndSettingsWindow // this.AcceptButton = this.saveButton; @@ -518,6 +572,8 @@ private void InitializeComponent() this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.BackColor = System.Drawing.SystemColors.Window; this.ClientSize = new System.Drawing.Size(518, 380); + this.Controls.Add(this.lnkLabel1); + this.Controls.Add(this.borderGroup); this.Controls.Add(this.opacityGroup); this.Controls.Add(this.positionGroup); this.Controls.Add(this.fontGroupBox); @@ -549,6 +605,9 @@ private void InitializeComponent() this.opacityGroup.ResumeLayout(false); this.opacityGroup.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.opacitySlider)).EndInit(); + this.borderGroup.ResumeLayout(false); + this.borderGroup.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.bdSizeSlider)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -567,7 +626,7 @@ private void InitializeComponent() private System.Windows.Forms.Button borderColourActivatedButton; private System.Windows.Forms.PictureBox foregroundColourActivatedPreview; private System.Windows.Forms.Button foregroundColourActivatedButton; - private System.Windows.Forms.ColorDialog mainColourPicker; + private CapsLockIndicatorV3.MColorPicker mainColourPicker; private System.Windows.Forms.PictureBox backgroundColourDeactivatedPreview; private System.Windows.Forms.Button backgroundColourDeactivatedButton; private System.Windows.Forms.GroupBox fontGroupBox; @@ -576,7 +635,7 @@ private void InitializeComponent() private System.Windows.Forms.Button foregroundColourDeactivatedButton; private System.Windows.Forms.PictureBox borderColourDeactivatedPreview; private System.Windows.Forms.Button borderColourDeactivatedButton; - private System.Windows.Forms.FontDialog indFontChooser; + private CapsLockIndicatorV3.MFontPicker indFontChooser; private System.Windows.Forms.GroupBox positionGroup; private System.Windows.Forms.TableLayoutPanel positionButtonLayout; private System.Windows.Forms.RadioButton positionBottomRight; @@ -592,5 +651,9 @@ private void InitializeComponent() private System.Windows.Forms.Label opacityLabel; private System.Windows.Forms.TrackBar opacitySlider; private System.Windows.Forms.CheckBox onlyShowWhenActiveCheckBox; + private System.Windows.Forms.GroupBox borderGroup; + private System.Windows.Forms.Label bdSizeLabel; + private System.Windows.Forms.TrackBar bdSizeSlider; + private LnkLabel lnkLabel1; } } diff --git a/CapsLockIndicatorV3/IndSettingsWindow.cs b/CapsLockIndicatorV3/IndSettingsWindow.cs index b469b9e..c125aad 100644 --- a/CapsLockIndicatorV3/IndSettingsWindow.cs +++ b/CapsLockIndicatorV3/IndSettingsWindow.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.Drawing; using System.Windows.Forms; @@ -10,6 +11,57 @@ public IndSettingsWindow() { InitializeComponent(); + if (SettingsManager.Get("beta_enableDarkMode")) + { + HandleCreated += IndSettingsWindow_HandleCreated; + + displayTimeGroup.ForeColor = + displayTimeLabel.ForeColor = + fontGroupBox.ForeColor = + fontButton.ForeColor = + positionGroup.ForeColor = + opacityGroup.ForeColor = + opacityLabel.ForeColor = + coloursGroup.ForeColor = + backgroundColourActivatedButton.ForeColor = + backgroundColourDeactivatedButton.ForeColor = + foregroundColourActivatedButton.ForeColor = + foregroundColourDeactivatedButton.ForeColor = + borderColourActivatedButton.ForeColor = + borderColourDeactivatedButton.ForeColor = + borderGroup.ForeColor = + bdSizeLabel.ForeColor = + lnkLabel1.LinkColor = + onlyShowWhenActiveCheckBox.ForeColor = + Color.White; + + onlyShowWhenActiveCheckBox.FlatStyle = FlatStyle.Standard; + + BackColor = Color.FromArgb(255, 32, 32, 32); + ForeColor = Color.White; + + ControlScheduleSetDarkMode(fontButton); + ControlScheduleSetDarkMode(backgroundColourActivatedButton); + ControlScheduleSetDarkMode(backgroundColourDeactivatedButton); + ControlScheduleSetDarkMode(foregroundColourActivatedButton); + ControlScheduleSetDarkMode(foregroundColourDeactivatedButton); + ControlScheduleSetDarkMode(borderColourActivatedButton); + ControlScheduleSetDarkMode(borderColourDeactivatedButton); + ControlScheduleSetDarkMode(positionTopLeft); + ControlScheduleSetDarkMode(positionTopCenter); + ControlScheduleSetDarkMode(positionTopRight); + ControlScheduleSetDarkMode(positionMiddleLeft); + ControlScheduleSetDarkMode(positionMiddleCenter); + ControlScheduleSetDarkMode(positionMiddleRight); + ControlScheduleSetDarkMode(positionBottomLeft); + ControlScheduleSetDarkMode(positionBottomCenter); + ControlScheduleSetDarkMode(positionBottomRight); + ControlScheduleSetDarkMode(displayTimeSlider); + ControlScheduleSetDarkMode(opacitySlider); + ControlScheduleSetDarkMode(bdSizeSlider); + ControlScheduleSetDarkMode(saveButton); + } + MaximumSize = new Size(int.MaxValue, Screen.FromControl(this).WorkingArea.Height); AutoScroll = true; @@ -19,6 +71,9 @@ public IndSettingsWindow() opacitySlider.Value = SettingsManager.Get("indOpacity"); opacityLabel.Text = string.Format("{0} %", opacitySlider.Value); + bdSizeSlider.Value = SettingsManager.Get("bdSize"); + bdSizeLabel.Text = string.Format("{0}", bdSizeSlider.Value); + backgroundColourActivatedPreview.BackColor = SettingsManager.Get("indBgColourActive"); backgroundColourDeactivatedPreview.BackColor = SettingsManager.Get("indBgColourInactive"); @@ -80,6 +135,24 @@ public IndSettingsWindow() foregroundColourDeactivatedButton.Text = strings.foregroundColourDeactivatedButton; positionGroup.Text = strings.overlayPositionGroup; onlyShowWhenActiveCheckBox.Text = strings.showOverlayOnlyWhenActive; + lnkLabel1.Text = strings.advancedSettings; + borderGroup.Text = strings.borderThicknessGroup; + } + + private void IndSettingsWindow_HandleCreated(object sender, EventArgs e) + { + Native.UseImmersiveDarkMode(Handle, true); + Native.UseImmersiveDarkModeColors(Handle, true); + + Native.UseImmersiveDarkModeColors(mainColourPicker.PInstance, true); + } + + private void ControlScheduleSetDarkMode(Control control) + { + control.HandleCreated += (sender, e) => + { + Native.ControlSetDarkMode(control, true); + }; } private void displayTimeSlider_Scroll(object sender, EventArgs e) @@ -212,5 +285,33 @@ private void onlyShowWhenActiveCheckBox_CheckedChanged(object sender, EventArgs { SettingsManager.Set("alwaysShowWhenActive", onlyShowWhenActiveCheckBox.Checked); } + + private void bdSizeLabel_Click(object sender, EventArgs e) + { + NumberInputDialog numberInputDialog = new NumberInputDialog(bdSizeSlider.Value, bdSizeSlider.Minimum, bdSizeSlider.Maximum); + if (numberInputDialog.ShowDialog() == DialogResult.OK) + { + bdSizeSlider.Value = numberInputDialog.Value; + SettingsManager.Set("bdSize", numberInputDialog.Value); + bdSizeLabel.Text = string.Format("{0}", bdSizeSlider.Value); + } + } + + private void bdSizeSlider_Scroll(object sender, EventArgs e) + { + SettingsManager.Set("bdSize", bdSizeSlider.Value); + bdSizeLabel.Text = string.Format("{0}", bdSizeSlider.Value); + } + + private void lnkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + if (!SettingsManager.Get("advSettingsWarnShown")) + { + if (MessageBox.Show("Before you edit the settings, please exit CapsLock Indicator completely. This message will only be shown once. Do you wish to proceed?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes) + return; + SettingsManager.Set("advSettingsWarnShown", true); + } + Process.Start("explorer", "/select,\"" + SettingsManager.GetActualPath() + "\""); + } } } diff --git a/CapsLockIndicatorV3/IndicatorOverlay.Designer.cs b/CapsLockIndicatorV3/IndicatorOverlay.Designer.cs index 32e30ed..541b1db 100644 --- a/CapsLockIndicatorV3/IndicatorOverlay.Designer.cs +++ b/CapsLockIndicatorV3/IndicatorOverlay.Designer.cs @@ -49,13 +49,13 @@ private void InitializeComponent() // // contentLabel // - this.contentLabel.Dock = System.Windows.Forms.DockStyle.Fill; - this.contentLabel.Location = new System.Drawing.Point(2, 2); + this.contentLabel.Location = new System.Drawing.Point(0, 0); this.contentLabel.Name = "contentLabel"; - this.contentLabel.Size = new System.Drawing.Size(172, 38); + this.contentLabel.Size = new System.Drawing.Size(0, 0); this.contentLabel.TabIndex = 0; this.contentLabel.Text = "{{{contentLabel}}"; this.contentLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.contentLabel.Visible = false; // // fadeTimer // @@ -84,7 +84,6 @@ private void InitializeComponent() this.Name = "IndicatorOverlay"; this.Padding = new System.Windows.Forms.Padding(2); this.ShowIcon = false; - this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "IndicatorOverlay"; this.ResumeLayout(false); diff --git a/CapsLockIndicatorV3/IndicatorOverlay.cs b/CapsLockIndicatorV3/IndicatorOverlay.cs index 7460f1b..07f896e 100644 --- a/CapsLockIndicatorV3/IndicatorOverlay.cs +++ b/CapsLockIndicatorV3/IndicatorOverlay.cs @@ -9,12 +9,12 @@ using System.Windows.Forms; namespace CapsLockIndicatorV3 -{ - /// - /// A form that indicates if a keystate has changed. - /// - public partial class IndicatorOverlay : Form - { +{ + /// + /// A form that indicates if a keystate has changed. + /// + public partial class IndicatorOverlay : Form + { [DllImport("user32.dll", SetLastError = true)] static extern uint GetWindowLong(IntPtr hWnd, int nIndex); [DllImport("user32.dll", EntryPoint = "SetWindowLong")] @@ -44,13 +44,15 @@ static float GetDisplayScaleFactor(IntPtr windowHandle) const uint WS_EX_LAYERED = 0x80000; const uint LWA_ALPHA = 0x2; const uint LWA_COLORKEY = 0x1; - const uint WS_EX_TRANSPARENT = 0x00000020; + const uint WS_EX_TRANSPARENT = 0x00000020; + const int WM_NCHITTEST = 0x84; + const int HTTRANSPARENT = -1; - private Size originalSize; - - private IndicatorDisplayPosition pos = IndicatorDisplayPosition.BottomRight; - - const int WINDOW_MARGIN = 16; + private Size originalSize; + + private IndicatorDisplayPosition pos = IndicatorDisplayPosition.BottomRight; + + const int WINDOW_MARGIN = 16; private double lastOpacity = 1; double opacity_timer_value = 2.0; @@ -60,28 +62,45 @@ static float GetDisplayScaleFactor(IntPtr windowHandle) 0x4D, 0xB4 ); + int BorderSize = 4; + + protected override void OnFormClosing(FormClosingEventArgs e) + { + fadeTimer.Stop(); + windowCloseTimer.Stop(); + positionUpdateTimer.Stop(); + base.OnFormClosing(e); + } - protected override bool ShowWithoutActivation - { - get { return true; } - } + protected override bool ShowWithoutActivation + { + get { return true; } + } - protected override CreateParams CreateParams - { - get - { - CreateParams cp = base.CreateParams; - cp.ExStyle |= 0x00000008 | 0x80; - return cp; - } - } - - protected override void OnShown(EventArgs e) - { + protected override CreateParams CreateParams + { + get + { + CreateParams cp = base.CreateParams; + cp.ExStyle |= 0x00000008 | 0x80; + return cp; + } + } + + protected override void WndProc(ref Message m) + { + if (m.Msg == WM_NCHITTEST) + m.Result = (IntPtr)HTTRANSPARENT; + else + base.WndProc(ref m); + } + + protected override void OnShown(EventArgs e) + { UpdatePosition(); - base.OnShown(e); - } + base.OnShown(e); + } protected override void OnLoad(EventArgs e) { @@ -140,33 +159,44 @@ void UpdatePosition() default: break; } - } - - protected override void OnPaint(PaintEventArgs e) - { - base.OnPaint(e); - e.Graphics.DrawRectangle(new Pen(BorderColour, 4), e.ClipRectangle); + } + + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + + if (BorderSize > 0) + e.Graphics.DrawRectangle(new Pen(BorderColour, BorderSize), e.ClipRectangle); + + using (var sf = new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }) + using (var b = new SolidBrush(contentLabel.ForeColor)) + e.Graphics.DrawString(contentLabel.Text, contentLabel.Font, b, ClientRectangle, sf); } private void ClickThroughWindow(double opacity = 1d) { - - IntPtr Handle = this.Handle; - uint windowLong = GetWindowLong(Handle, GWL_EXSTYLE); - SetWindowLong32(Handle, GWL_EXSTYLE, windowLong ^ WS_EX_LAYERED); - SetLayeredWindowAttributes(Handle, 0, (byte)(opacity * 255), LWA_ALPHA); - - var style = GetWindowLong(this.Handle, GWL_EXSTYLE); - SetWindowLong(this.Handle, GWL_EXSTYLE, style | WS_EX_LAYERED | WS_EX_TRANSPARENT); + //Opacity = opacity; + try + { + IntPtr Handle = this.Handle; + uint windowLong = GetWindowLong(Handle, GWL_EXSTYLE); + SetWindowLong32(Handle, GWL_EXSTYLE, windowLong ^ WS_EX_LAYERED); + SetLayeredWindowAttributes(Handle, 0, (byte)(opacity * 255), LWA_ALPHA); + + var style = GetWindowLong(this.Handle, GWL_EXSTYLE); + SetWindowLong(this.Handle, GWL_EXSTYLE, style | WS_EX_LAYERED | WS_EX_TRANSPARENT); + } + catch (ObjectDisposedException) + { } } - public IndicatorOverlay(string content) - { - InitializeComponent(); - - originalSize = Size; + public IndicatorOverlay(string content) + { + InitializeComponent(); - contentLabel.Text = content; + originalSize = Size; + + contentLabel.Text = content; ClickThroughWindow(); } @@ -180,9 +210,9 @@ public IndicatorOverlay(string content, int timeoutInMs, IndicatorDisplayPositio Application.DoEvents(); originalSize = Size; - if (timeoutInMs < 0) + if (timeoutInMs < 1) { - windowCloseTimer.Enabled = false; + windowCloseTimer.Enabled = false; fadeTimer.Enabled = false; } else @@ -193,7 +223,7 @@ public IndicatorOverlay(string content, int timeoutInMs, IndicatorDisplayPositio ClickThroughWindow(); } - public IndicatorOverlay(string content, int timeoutInMs, Color bgColour, Color fgColour, Color bdColour, Font font, IndicatorDisplayPosition position, int indOpacity, bool alwaysShow) + public IndicatorOverlay(string content, int timeoutInMs, Color bgColour, Color fgColour, Color bdColour, int bdSize, Font font, IndicatorDisplayPosition position, int indOpacity, bool alwaysShow) { pos = position; InitializeComponent(); @@ -201,8 +231,8 @@ public IndicatorOverlay(string content, int timeoutInMs, Color bgColour, Color f contentLabel.Text = content; Font = font; Application.DoEvents(); - originalSize = Size; - + originalSize = Size; + var op = indOpacity / 100d; lastOpacity = op; SetOpacity(op); @@ -219,6 +249,7 @@ public IndicatorOverlay(string content, int timeoutInMs, Color bgColour, Color f BackColor = bgColour; ForeColor = fgColour; BorderColour = bdColour; + BorderSize = bdSize; ClickThroughWindow(op); } @@ -226,8 +257,15 @@ private void SetOpacity(double op) { if (IsDisposed) return; - byte opb = (byte)Math.Min(255, op * 0xFF); - SetLayeredWindowAttributes(Handle, 0, opb, LWA_ALPHA); + + try + { + //Opacity = op; + byte opb = (byte)Math.Min(255, op * 0xFF); + SetLayeredWindowAttributes(Handle, 0, opb, LWA_ALPHA); + } + catch (ObjectDisposedException) + { } } public void UpdateIndicator(string content, IndicatorDisplayPosition position) @@ -265,7 +303,7 @@ public void UpdateIndicator(string content, int timeoutInMs, IndicatorDisplayPos UpdatePosition(); } - public void UpdateIndicator(string content, int timeoutInMs, Color bgColour, Color fgColour, Color bdColour, Font font, IndicatorDisplayPosition position, int indOpacity, bool alwaysShow) + public void UpdateIndicator(string content, int timeoutInMs, Color bgColour, Color fgColour, Color bdColour, int bdSize, Font font, IndicatorDisplayPosition position, int indOpacity, bool alwaysShow) { pos = position; var op = indOpacity / 100d; @@ -290,14 +328,15 @@ public void UpdateIndicator(string content, int timeoutInMs, Color bgColour, Col BackColor = bgColour; ForeColor = fgColour; BorderColour = bdColour; + BorderSize = bdSize; Invalidate(); UpdatePosition(); } - void WindowCloseTimerTick(object sender, EventArgs e) - { - Close(); - } + void WindowCloseTimerTick(object sender, EventArgs e) + { + Close(); + } private void fadeTimer_Tick(object sender, EventArgs e) { diff --git a/CapsLockIndicatorV3/MColorPicker.cs b/CapsLockIndicatorV3/MColorPicker.cs new file mode 100644 index 0000000..108d40d --- /dev/null +++ b/CapsLockIndicatorV3/MColorPicker.cs @@ -0,0 +1,220 @@ +/** + * Loosely based on https://sourceforge.net/projects/alpha-color-dialog/ + * by Opulos Inc. + * Licensed under BSD license + * + * Copyright 2015 Opulos Inc. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Drawing; +using System.Runtime.InteropServices; +using System.Text; + +namespace CapsLockIndicatorV3 +{ + public class MColorPicker : System.Windows.Forms.ColorDialog + { + #region P/Invoke + [DllImport("user32.dll")] + private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); + + [DllImport("user32.dll")] + private static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect); + + [DllImport("user32.dll")] + private static extern IntPtr GetParent(IntPtr hWnd); + + [DllImport("user32.dll")] + private static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); + + [DllImport("user32.dll")] + private static extern int PostMessage(IntPtr hWnd, int Msg, int wParam, int lParam); + + [DllImport("user32.dll")] + private static extern IntPtr GetDlgItem(IntPtr hDlg, int nIDDlgItem); + + [DllImport("user32.dll")] + private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); + + [DllImport("user32.dll")] + private static extern bool SetForegroundWindow(IntPtr hWnd); + + [DllImport("user32.dll", CharSet = CharSet.Auto)] + private static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount); + + [DllImport("gdi32.dll")] + static extern uint SetBkColor(IntPtr hdc, int crColor); + + [DllImport("gdi32.dll")] + static extern int SetBkMode(IntPtr hdc, int iBkMode); + + [DllImport("user32.dll")] + static extern IntPtr BeginPaint(IntPtr hwnd, out PAINTSTRUCT lpPaint); + + [DllImport("user32.dll")] + static extern bool EndPaint(IntPtr hWnd, [In] ref PAINTSTRUCT lpPaint); + + [DllImport("user32.dll")] + static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); + + [DllImport("user32.dll", EntryPoint = "GetWindowLong")] + static extern int GetWindowLong(IntPtr hWnd, int nIndex); + + private const int ACD_COLORCHANGED = 0x0400; + private const int SRC = 0xCC0020; + + private const int SWP_NOSIZE = 0x0001; + private const int SWP_NOMOVE = 0x0002; + private const int SWP_NOZORDER = 0x0004; + + private const int WM_CREATE = 0x0001; + private const int WM_PAINT = 0x000F; + private const int WM_ERASEBKGND = 0x0014; + private const int WM_INITDIALOG = 0x110; + private const int WM_SETFONT = 0x0030; + private const int WM_GETFONT = 0x0031; + private const int WM_SHOWWINDOW = 0x18; + private const int GWL_STYLE = -16; + private const int WM_COMMAND = 0x111; + private const int WM_CHAR = 0x102; + private const int WM_LBUTTONDOWN = 0x201; + + private const int TRANSPARENT = 1; + private const int OPAQUE = 2; + + private const int WS_CLIPCHILDREN = 0x02000000; + private const int WS_VISIBLE = 0x10000000; + private const int WS_CHILD = 0x40000000; + private const int WS_TABSTOP = 0x00010000; + + private struct RECT + { + public int Left; + public int Top; + public int Right; + public int Bottom; + } + + [StructLayout(LayoutKind.Sequential)] + struct PAINTSTRUCT + { + public IntPtr hdc; + public bool fErase; + public RECT rcPaint; + public bool fRestore; + public bool fIncUpdate; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] rgbReserved; + } + #endregion + + public IntPtr PInstance => Instance; + + private IntPtr handle = IntPtr.Zero; + private IntPtr hWndRed = IntPtr.Zero; + private IntPtr hWndGreen = IntPtr.Zero; + private IntPtr hWndBlue = IntPtr.Zero; + private IntPtr hWndOK = IntPtr.Zero; + private IntPtr hWndCancel = IntPtr.Zero; + private IntPtr hWndAdd = IntPtr.Zero; + private IntPtr hWndExpand = IntPtr.Zero; + + protected override IntPtr OwnerWndProc(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam) + { + return base.OwnerWndProc(hWnd, msg, wparam, lparam); + } + + protected override IntPtr HookProc(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam) + { + if (msg == WM_INITDIALOG) + { +#if EXPERIMENTAL__USE_DARK_COMMON_DIALOGS + var prevStyle = GetWindowLong(hWnd, GWL_STYLE); + SetWindowLong(hWnd, GWL_STYLE, prevStyle | WS_CLIPCHILDREN); +#endif + + // To find the controlIDs, use Spy++ (Visual Studio: Tools > Spy++) + hWndOK = GetDlgItem(hWnd, 0x1); + hWndCancel = GetDlgItem(hWnd, 0x2); + hWndRed = GetDlgItem(hWnd, 0x02c2); + hWndGreen = GetDlgItem(hWnd, 0x02c3); + hWndBlue = GetDlgItem(hWnd, 0x02c4); + hWndExpand = GetDlgItem(hWnd, 0x02cf); + hWndAdd = GetDlgItem(hWnd, 0x02c8); + + DarkMode(); + } + else if (msg == WM_SHOWWINDOW) + { + //center the dialog on the parent window: + RECT cr = new RECT(); + RECT r0 = new RECT(); + IntPtr parent = GetParent(hWnd); + GetWindowRect(hWnd, ref r0); + GetWindowRect(parent, ref cr); + handle = hWnd; + + PrepareDarkMode(handle); + + int x = cr.Left + ((cr.Right - cr.Left) - (r0.Right - r0.Left)) / 2; + int y = cr.Top + ((cr.Bottom - cr.Top) - (r0.Bottom - r0.Top)) / 2; + SetWindowPos(hWnd, IntPtr.Zero, x, y, 0, 0, SWP_NOZORDER | SWP_NOSIZE); + } + else if (msg == WM_COMMAND || msg == WM_CHAR || msg == WM_LBUTTONDOWN) + { + PostMessage(hWnd, ACD_COLORCHANGED, 0, 0); + } + else if (msg == WM_ERASEBKGND) + { +#if EXPERIMENTAL__USE_DARK_COMMON_DIALOGS + using (var g = Graphics.FromHwnd(handle)) + g.Clear(Color.FromArgb(255, 32, 32, 32)); +#endif + } + else if (msg == WM_PAINT) + { } + + return base.HookProc(hWnd, msg, wparam, lparam); + } + + private void PrepareDarkMode(IntPtr hWnd) + { + if (!SettingsManager.Get("beta_enableDarkMode")) + return; + + Native.UseImmersiveDarkModeColors(hWnd, true); + } + + private void DarkMode() + { + if (!SettingsManager.Get("beta_enableDarkMode")) + return; + + Native.SetDarkMode(hWndOK, true); + Native.SetDarkMode(hWndCancel, true); + Native.SetDarkMode(hWndExpand, true); + Native.SetDarkMode(hWndAdd, true); + } + } +} diff --git a/CapsLockIndicatorV3/MFontPicker.cs b/CapsLockIndicatorV3/MFontPicker.cs new file mode 100644 index 0000000..3a9b935 --- /dev/null +++ b/CapsLockIndicatorV3/MFontPicker.cs @@ -0,0 +1,238 @@ +/** + * Loosely based on https://sourceforge.net/projects/alpha-color-dialog/ + * by Opulos Inc. + * Licensed under BSD license + * + * Copyright 2015 Opulos Inc. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace CapsLockIndicatorV3 +{ + public class MFontPicker : System.Windows.Forms.FontDialog + { + #region P/Invoke + [DllImport("user32.dll")] + private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); + + [DllImport("user32.dll")] + private static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect); + + [DllImport("user32.dll")] + private static extern IntPtr GetParent(IntPtr hWnd); + + [DllImport("user32.dll")] + private static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); + + [DllImport("user32.dll")] + private static extern int PostMessage(IntPtr hWnd, int Msg, int wParam, int lParam); + + [DllImport("user32.dll")] + private static extern IntPtr GetDlgItem(IntPtr hDlg, int nIDDlgItem); + + [DllImport("user32.dll")] + private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); + + [DllImport("user32.dll")] + private static extern bool SetForegroundWindow(IntPtr hWnd); + + [DllImport("user32.dll", CharSet = CharSet.Auto)] + private static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount); + + [DllImport("gdi32.dll")] + static extern uint SetBkColor(IntPtr hdc, int crColor); + + [DllImport("gdi32.dll")] + static extern int SetBkMode(IntPtr hdc, int iBkMode); + + [DllImport("user32.dll")] + static extern IntPtr BeginPaint(IntPtr hwnd, out PAINTSTRUCT lpPaint); + + [DllImport("user32.dll")] + static extern bool EndPaint(IntPtr hWnd, [In] ref PAINTSTRUCT lpPaint); + + [DllImport("user32.dll")] + static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); + + [DllImport("user32.dll", EntryPoint = "GetWindowLong")] + static extern int GetWindowLong(IntPtr hWnd, int nIndex); + + private const int ACD_COLORCHANGED = 0x0400; + private const int SRC = 0xCC0020; + + private const int SWP_NOSIZE = 0x0001; + private const int SWP_NOMOVE = 0x0002; + private const int SWP_NOZORDER = 0x0004; + + private const int WM_CREATE = 0x0001; + private const int WM_PAINT = 0x000F; + private const int WM_ERASEBKGND = 0x0014; + private const int WM_INITDIALOG = 0x110; + private const int WM_SETFONT = 0x0030; + private const int WM_GETFONT = 0x0031; + private const int WM_SHOWWINDOW = 0x18; + private const int GWL_STYLE = -16; + private const int WM_COMMAND = 0x111; + private const int WM_CHAR = 0x102; + private const int WM_LBUTTONDOWN = 0x201; + + private const int TRANSPARENT = 1; + private const int OPAQUE = 2; + + private const int WS_VISIBLE = 0x10000000; + private const int WS_CHILD = 0x40000000; + private const int WS_CLIPCHILDREN = 0x02000000; + private const int WS_TABSTOP = 0x00010000; + + private struct RECT + { + public int Left; + public int Top; + public int Right; + public int Bottom; + } + + [StructLayout(LayoutKind.Sequential)] + struct PAINTSTRUCT + { + public IntPtr hdc; + public bool fErase; + public RECT rcPaint; + public bool fRestore; + public bool fIncUpdate; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] rgbReserved; + } + #endregion + + private IntPtr handle = IntPtr.Zero; + private IntPtr hWndOkButon = IntPtr.Zero; + private IntPtr hWndCancelButon = IntPtr.Zero; + private IntPtr hWndEffectsGroup = IntPtr.Zero; + private IntPtr hWndEffectsStrike = IntPtr.Zero; + private IntPtr hWndEffectsUnder = IntPtr.Zero; + private IntPtr hWndSampleGroup = IntPtr.Zero; + private IntPtr hWndFontLabel = IntPtr.Zero; + private IntPtr hWndWeightLabel = IntPtr.Zero; + private IntPtr hWndSizeLabel = IntPtr.Zero; + private IntPtr hWndUnknown = IntPtr.Zero; + private IntPtr hWndScriptLabel = IntPtr.Zero; + private IntPtr hWndFontComboBox = IntPtr.Zero; + private IntPtr hWndWeightComboBox = IntPtr.Zero; + private IntPtr hWndSizeComboBox = IntPtr.Zero; + private IntPtr hWndScriptComboBox = IntPtr.Zero; + + protected override IntPtr OwnerWndProc(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam) + { + return base.OwnerWndProc(hWnd, msg, wparam, lparam); + } + + protected override IntPtr HookProc(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam) + { + if (msg == WM_INITDIALOG) + { +#if EXPERIMENTAL__USE_DARK_COMMON_DIALOGS + var prevStyle = GetWindowLong(hWnd, GWL_STYLE); + SetWindowLong(hWnd, GWL_STYLE, prevStyle | WS_CLIPCHILDREN); +#endif + + hWndOkButon = GetDlgItem(hWnd, 0x0001); + hWndCancelButon = GetDlgItem(hWnd, 0x0002); + hWndEffectsGroup = GetDlgItem(hWnd, 0x0430); + hWndEffectsStrike = GetDlgItem(hWnd, 0x0410); + hWndEffectsUnder = GetDlgItem(hWnd, 0x0411); + hWndSampleGroup = GetDlgItem(hWnd, 0x0431); + hWndFontLabel = GetDlgItem(hWnd, 0x0440); + hWndWeightLabel = GetDlgItem(hWnd, 0x0441); + hWndSizeLabel = GetDlgItem(hWnd, 0x0442); + hWndUnknown = GetDlgItem(hWnd, 0x0445); + hWndScriptLabel = GetDlgItem(hWnd, 0x0446); + hWndFontComboBox = GetDlgItem(hWnd, 0x0470); + hWndWeightComboBox = GetDlgItem(hWnd, 0x0471); + hWndSizeComboBox = GetDlgItem(hWnd, 0x0472); + hWndScriptComboBox = GetDlgItem(hWnd, 0x0474); + + DarkMode(); + } + else if (msg == WM_SHOWWINDOW) + { + //center the dialog on the parent window: + RECT cr = new RECT(); + RECT r0 = new RECT(); + IntPtr parent = GetParent(hWnd); + GetWindowRect(hWnd, ref r0); + GetWindowRect(parent, ref cr); + handle = hWnd; + + PrepareDarkMode(handle); + + int x = cr.Left + ((cr.Right - cr.Left) - (r0.Right - r0.Left)) / 2; + int y = cr.Top + ((cr.Bottom - cr.Top) - (r0.Bottom - r0.Top)) / 2; + SetWindowPos(hWnd, IntPtr.Zero, x, y, 0, 0, SWP_NOZORDER | SWP_NOSIZE); + } + else if (msg == WM_ERASEBKGND) + { +#if EXPERIMENTAL__USE_DARK_COMMON_DIALOGS + using (var g = Graphics.FromHwnd(handle)) + g.Clear(Color.FromArgb(255, 32, 32, 32)); +#endif + } + else if (msg == WM_PAINT) + { } + + return base.HookProc(hWnd, msg, wparam, lparam); + } + + private void PrepareDarkMode(IntPtr hWnd) + { + Native.UseImmersiveDarkModeColors(hWnd, true); + } + + private void DarkMode() + { + Native.SetDarkMode(hWndOkButon, true); + Native.SetDarkMode(hWndCancelButon, true); + Native.SetDarkMode(hWndEffectsGroup, true); + Native.SetDarkMode(hWndEffectsStrike, true); + Native.SetDarkMode(hWndEffectsUnder, true); + Native.SetDarkMode(hWndSampleGroup, true); + Native.SetDarkMode(hWndFontLabel, true); + Native.SetDarkMode(hWndWeightLabel, true); + Native.SetDarkMode(hWndSizeLabel, true); + Native.SetDarkMode(hWndUnknown, true); + Native.SetDarkMode(hWndScriptLabel, true); + Native.SetDarkMode(hWndFontComboBox, true); + Native.SetDarkMode(hWndWeightComboBox, true); + Native.SetDarkMode(hWndSizeComboBox, true); + Native.SetDarkMode(hWndScriptComboBox, true); + } + } +} diff --git a/CapsLockIndicatorV3/MainForm.Designer.cs b/CapsLockIndicatorV3/MainForm.Designer.cs index 174022b..eba5658 100644 --- a/CapsLockIndicatorV3/MainForm.Designer.cs +++ b/CapsLockIndicatorV3/MainForm.Designer.cs @@ -77,8 +77,6 @@ private void InitializeComponent() this.showNoIcons = new System.Windows.Forms.CheckBox(); this.showNoNotification = new System.Windows.Forms.CheckBox(); this.aboutPanel = new System.Windows.Forms.Panel(); - this.appNameLabel = new CapsLockIndicatorV3.LnkLabel(); - this.logo = new CapsLockIndicatorV3.LnkLabel(); this.aboutPanelTopBorder = new System.Windows.Forms.PictureBox(); this.aboutText = new System.Windows.Forms.Label(); this.hideWindow = new System.Windows.Forms.Button(); @@ -92,6 +90,12 @@ private void InitializeComponent() this.mainToolTip = new System.Windows.Forms.ToolTip(this.components); this.checkForUpdatedCheckBox = new System.Windows.Forms.CheckBox(); this.localeComboBox = new CapsLockIndicatorV3.LnComboBox(); + this.appNameLabel = new CapsLockIndicatorV3.LnkLabel(); + this.logo = new CapsLockIndicatorV3.LnkLabel(); + this.contextMenu1 = new System.Windows.Forms.ContextMenu(); + this.showMenuItem = new System.Windows.Forms.MenuItem(); + this.menuItem1 = new System.Windows.Forms.MenuItem(); + this.exitMenuItem = new System.Windows.Forms.MenuItem(); this.generalIconContextMenuStrip.SuspendLayout(); this.iconsGroup.SuspendLayout(); this.indicatorGroup.SuspendLayout(); @@ -107,7 +111,6 @@ private void InitializeComponent() // // numLockIcon // - this.numLockIcon.ContextMenuStrip = this.generalIconContextMenuStrip; this.numLockIcon.Text = "Num Lock"; this.numLockIcon.Visible = true; this.numLockIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.GeneralIconMouseDoubleClick); @@ -142,14 +145,12 @@ private void InitializeComponent() // // capsLockIcon // - this.capsLockIcon.ContextMenuStrip = this.generalIconContextMenuStrip; this.capsLockIcon.Text = "Caps Lock"; this.capsLockIcon.Visible = true; this.capsLockIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.GeneralIconMouseDoubleClick); // // scrollLockIcon // - this.scrollLockIcon.ContextMenuStrip = this.generalIconContextMenuStrip; this.scrollLockIcon.Text = "Scroll Lock"; this.scrollLockIcon.Visible = true; this.scrollLockIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.GeneralIconMouseDoubleClick); @@ -298,34 +299,6 @@ private void InitializeComponent() this.aboutPanel.Size = new System.Drawing.Size(306, 66); this.aboutPanel.TabIndex = 4; // - // appNameLabel - // - this.appNameLabel.ActiveLinkColor = System.Drawing.Color.FromArgb(((int)(((byte)(52)))), ((int)(((byte)(77)))), ((int)(((byte)(180))))); - this.appNameLabel.AutoSize = true; - this.appNameLabel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold); - this.appNameLabel.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline; - this.appNameLabel.LinkColor = System.Drawing.Color.FromArgb(((int)(((byte)(52)))), ((int)(((byte)(77)))), ((int)(((byte)(180))))); - this.appNameLabel.Location = new System.Drawing.Point(63, 10); - this.appNameLabel.Name = "appNameLabel"; - this.appNameLabel.Size = new System.Drawing.Size(111, 15); - this.appNameLabel.TabIndex = 5; - this.appNameLabel.TabStop = true; - this.appNameLabel.Text = "CapsLock Indicator"; - this.mainToolTip.SetToolTip(this.appNameLabel, "Visit CapsLock Indicator website"); - this.appNameLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.appNameLabel_LinkClicked); - // - // logo - // - this.logo.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.logo.Image = ((System.Drawing.Image)(resources.GetObject("logo.Image"))); - this.logo.Location = new System.Drawing.Point(9, 10); - this.logo.Name = "logo"; - this.logo.Size = new System.Drawing.Size(48, 48); - this.logo.TabIndex = 4; - this.logo.Click += new System.EventHandler(this.lnkLabel1_Click); - // // aboutPanelTopBorder // this.aboutPanelTopBorder.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(52)))), ((int)(((byte)(77)))), ((int)(((byte)(180))))); @@ -376,7 +349,6 @@ private void InitializeComponent() this.generalIcon.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info; this.generalIcon.BalloonTipText = "You can show CapsLock Indicator again by double clicking on this icon."; this.generalIcon.BalloonTipTitle = "CapsLock Indicator"; - this.generalIcon.ContextMenuStrip = this.generalIconContextMenuStrip; this.generalIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("generalIcon.Icon"))); this.generalIcon.Text = "CapsLock Indicator"; this.generalIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.GeneralIconMouseDoubleClick); @@ -457,6 +429,58 @@ private void InitializeComponent() this.localeComboBox.SelectedIndexChanged += new System.EventHandler(this.localeComboBox_SelectedIndexChanged); this.localeComboBox.Format += new System.Windows.Forms.ListControlConvertEventHandler(this.localeComboBox_Format); // + // appNameLabel + // + this.appNameLabel.ActiveLinkColor = System.Drawing.Color.FromArgb(((int)(((byte)(52)))), ((int)(((byte)(77)))), ((int)(((byte)(180))))); + this.appNameLabel.AutoSize = true; + this.appNameLabel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold); + this.appNameLabel.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline; + this.appNameLabel.LinkColor = System.Drawing.Color.FromArgb(((int)(((byte)(52)))), ((int)(((byte)(77)))), ((int)(((byte)(180))))); + this.appNameLabel.Location = new System.Drawing.Point(63, 10); + this.appNameLabel.Name = "appNameLabel"; + this.appNameLabel.Size = new System.Drawing.Size(111, 15); + this.appNameLabel.TabIndex = 5; + this.appNameLabel.TabStop = true; + this.appNameLabel.Text = "CapsLock Indicator"; + this.mainToolTip.SetToolTip(this.appNameLabel, "Visit CapsLock Indicator website"); + this.appNameLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.appNameLabel_LinkClicked); + // + // logo + // + this.logo.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.logo.Image = ((System.Drawing.Image)(resources.GetObject("logo.Image"))); + this.logo.Location = new System.Drawing.Point(9, 10); + this.logo.Name = "logo"; + this.logo.Size = new System.Drawing.Size(48, 48); + this.logo.TabIndex = 4; + this.logo.Click += new System.EventHandler(this.lnkLabel1_Click); + // + // contextMenu1 + // + this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.showMenuItem, + this.menuItem1, + this.exitMenuItem}); + // + // showMenuItem + // + this.showMenuItem.Index = 0; + this.showMenuItem.Text = "&Show"; + this.showMenuItem.Click += new System.EventHandler(this.showMenuItem_Click); + // + // menuItem1 + // + this.menuItem1.Index = 1; + this.menuItem1.Text = "-"; + // + // exitMenuItem + // + this.exitMenuItem.Index = 2; + this.exitMenuItem.Text = "&Exit"; + this.exitMenuItem.Click += new System.EventHandler(this.exitMenuItem_Click); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); @@ -513,6 +537,10 @@ private void InitializeComponent() private LnkLabel appNameLabel; private System.Windows.Forms.ToolTip mainToolTip; private System.Windows.Forms.CheckBox checkForUpdatedCheckBox; - private CapsLockIndicatorV3.LnComboBox localeComboBox; + private CapsLockIndicatorV3.LnComboBox localeComboBox; + private System.Windows.Forms.ContextMenu contextMenu1; + private System.Windows.Forms.MenuItem showMenuItem; + private System.Windows.Forms.MenuItem menuItem1; + private System.Windows.Forms.MenuItem exitMenuItem; } } diff --git a/CapsLockIndicatorV3/MainForm.cs b/CapsLockIndicatorV3/MainForm.cs index 180158b..c83f239 100644 --- a/CapsLockIndicatorV3/MainForm.cs +++ b/CapsLockIndicatorV3/MainForm.cs @@ -87,6 +87,12 @@ public MainForm() iconsGroup.Enabled = !showNoIcons.Checked; indicatorGroup.Enabled = !showNoNotification.Checked; + generalIcon.ContextMenu = + numLockIcon.ContextMenu = + capsLockIcon.ContextMenu = + scrollLockIcon.ContextMenu = + contextMenu1; + if (SettingsManager.Get("beta_enableDarkMode")) { HandleCreated += MainForm_HandleCreated; @@ -99,10 +105,31 @@ public MainForm() enableNumIcon.ForeColor = enableCapsIcon.ForeColor = enableScrollIcon.ForeColor = + showNoIcons.ForeColor = + showNoNotification.ForeColor = + startonlogonCheckBox.ForeColor = + hideOnStartupCheckBox.ForeColor = Color.White; + enableNumInd.FlatStyle = + enableCapsInd.FlatStyle = + enableScrollInd.FlatStyle = + enableNumIcon.FlatStyle = + enableCapsIcon.FlatStyle = + enableScrollIcon.FlatStyle = + showNoIcons.FlatStyle = + showNoNotification.FlatStyle = + startonlogonCheckBox.FlatStyle = + hideOnStartupCheckBox.FlatStyle = + FlatStyle.Standard; + BackColor = Color.FromArgb(255, 32, 32, 32); ForeColor = Color.White; + aboutPanelTopBorder.BackColor = Color.FromArgb(255, 196, 204, 238); + appNameLabel.LinkColor = + appNameLabel.ActiveLinkColor = + Color.FromArgb(255, 196, 204, 238); + logo.Image = (Bitmap)resources.GetObject("logo_dark"); ControlScheduleSetDarkMode(checkForUpdatesButton); ControlScheduleSetDarkMode(indSettings); @@ -114,6 +141,7 @@ public MainForm() ControlScheduleSetDarkMode(enableNumIcon); ControlScheduleSetDarkMode(enableCapsIcon); ControlScheduleSetDarkMode(enableScrollIcon); + ControlScheduleSetDarkMode(localeComboBox); } // Check if application is in startup @@ -153,14 +181,16 @@ private void ControlScheduleSetDarkMode(Control control) private void ReloadIcons() { - CapsOff = File.Exists("caps0.ico") ? Icon.ExtractAssociatedIcon("caps0.ico") : (Icon)resources.GetObject("CLIv3_Caps_Off"); - CapsOn = File.Exists("caps1.ico") ? Icon.ExtractAssociatedIcon("caps1.ico") : (Icon)resources.GetObject("CLIv3_Caps_On"); + var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + + CapsOff = File.Exists(Path.Combine(dir, "caps0.ico")) ? Icon.ExtractAssociatedIcon(Path.Combine(dir, "caps0.ico")) : (Icon)resources.GetObject("CLIv3_Caps_Off"); + CapsOn = File.Exists(Path.Combine(dir, "caps1.ico")) ? Icon.ExtractAssociatedIcon(Path.Combine(dir, "caps1.ico")) : (Icon)resources.GetObject("CLIv3_Caps_On"); - NumOff = File.Exists("num0.ico") ? Icon.ExtractAssociatedIcon("num0.ico") : (Icon)resources.GetObject("CLIv3_Num_Off"); - NumOn = File.Exists("num1.ico") ? Icon.ExtractAssociatedIcon("num1.ico") : (Icon)resources.GetObject("CLIv3_Num_On"); + NumOff = File.Exists(Path.Combine(dir, "num0.ico")) ? Icon.ExtractAssociatedIcon(Path.Combine(dir, "num0.ico")) : (Icon)resources.GetObject("CLIv3_Num_Off"); + NumOn = File.Exists(Path.Combine(dir, "num1.ico")) ? Icon.ExtractAssociatedIcon(Path.Combine(dir, "num1.ico")) : (Icon)resources.GetObject("CLIv3_Num_On"); - ScrollOff = File.Exists("scroll0.ico") ? Icon.ExtractAssociatedIcon("scroll0.ico") : (Icon)resources.GetObject("CLIv3_Scroll_Off"); - ScrollOn = File.Exists("scroll1.ico") ? Icon.ExtractAssociatedIcon("scroll1.ico") : (Icon)resources.GetObject("CLIv3_Scroll_On"); + ScrollOff = File.Exists(Path.Combine(dir, "scroll0.ico")) ? Icon.ExtractAssociatedIcon(Path.Combine(dir, "scroll0.ico")) : (Icon)resources.GetObject("CLIv3_Scroll_Off"); + ScrollOn = File.Exists(Path.Combine(dir, "scroll1.ico")) ? Icon.ExtractAssociatedIcon(Path.Combine(dir, "scroll1.ico")) : (Icon)resources.GetObject("CLIv3_Scroll_On"); } private void AddCultures() @@ -229,7 +259,9 @@ void ApplyLocales() startonlogonCheckBox.Text = strings.startOnLogon; generalIcon.BalloonTipText = strings.generalIconBalloonText; showToolStripMenuItem.Text = strings.contextMenuShow; + showMenuItem.Text = strings.contextMenuShow; exitToolStripMenuItem.Text = strings.contextMenuExit; + exitMenuItem.Text = strings.contextMenuExit; hideOnStartupCheckBox.Text = strings.hideOnStartup; } @@ -260,14 +292,26 @@ void UpdateTimerTick(object sender, EventArgs e) // Handle the overlay if (numState != KeyHelper.isNumlockActive && enableNumInd.Checked && !showNoNotification.Checked) - ShowOverlay(string.Format(KeyHelper.isNumlockActive ? strings.keyIsOn : strings.keyIsOff, strings.numLock), KeyHelper.isNumlockActive); + ShowOverlay( + KeyHelper.isNumlockActive ? + (SettingsManager.Get("customMessageNumOn").Trim().Length > 0 ? SettingsManager.Get("customMessageNumOn") : string.Format(strings.keyIsOn, strings.numLock)) : + (SettingsManager.Get("customMessageNumOff").Trim().Length > 0 ? SettingsManager.Get("customMessageNumOff") : string.Format(strings.keyIsOff, strings.numLock)), + KeyHelper.isNumlockActive); //ShowOverlay("Numlock is " + (KeyHelper.isNumlockActive ? "on" : "off"), KeyHelper.isNumlockActive); if (capsState != KeyHelper.isCapslockActive && enableCapsInd.Checked && !showNoNotification.Checked) - ShowOverlay(string.Format(KeyHelper.isCapslockActive ? strings.keyIsOn : strings.keyIsOff, strings.capsLock), KeyHelper.isCapslockActive); + ShowOverlay( + KeyHelper.isCapslockActive ? + (SettingsManager.Get("customMessageCapsOn").Trim().Length > 0 ? SettingsManager.Get("customMessageCapsOn") : string.Format(strings.keyIsOn, strings.capsLock)) : + (SettingsManager.Get("customMessageCapsOff").Trim().Length > 0 ? SettingsManager.Get("customMessageCapsOff") : string.Format(strings.keyIsOff, strings.capsLock)), + KeyHelper.isCapslockActive); if (scrollState != KeyHelper.isScrolllockActive && enableScrollInd.Checked && !showNoNotification.Checked) - ShowOverlay(string.Format(KeyHelper.isScrolllockActive ? strings.keyIsOn : strings.keyIsOff, strings.scrollLock), KeyHelper.isScrolllockActive); + ShowOverlay( + KeyHelper.isScrolllockActive ? + (SettingsManager.Get("customMessageScrollOn").Trim().Length > 0 ? SettingsManager.Get("customMessageScrollOn") : string.Format(strings.keyIsOn, strings.scrollLock)) : + (SettingsManager.Get("customMessageScrollOff").Trim().Length > 0 ? SettingsManager.Get("customMessageScrollOff") : string.Format(strings.keyIsOff, strings.scrollLock)), + KeyHelper.isScrolllockActive); // Reset the values numState = KeyHelper.isNumlockActive; @@ -288,6 +332,7 @@ void ShowOverlay(string message, bool isActive) , isActive ? SettingsManager.Get("indBgColourActive") : SettingsManager.Get("indBgColourInactive") , isActive ? SettingsManager.Get("indFgColourActive") : SettingsManager.Get("indFgColourInactive") , isActive ? SettingsManager.Get("indBdColourActive") : SettingsManager.Get("indBdColourInactive") + , SettingsManager.Get("bdSize") , SettingsManager.GetOrDefault("indFont") , SettingsManager.Get("overlayPosition") , SettingsManager.Get("indOpacity") @@ -302,6 +347,7 @@ void ShowOverlay(string message, bool isActive) , isActive ? SettingsManager.Get("indBgColourActive") : SettingsManager.Get("indBgColourInactive") , isActive ? SettingsManager.Get("indFgColourActive") : SettingsManager.Get("indFgColourInactive") , isActive ? SettingsManager.Get("indBdColourActive") : SettingsManager.Get("indBdColourInactive") + , SettingsManager.Get("bdSize") , SettingsManager.GetOrDefault("indFont") , SettingsManager.Get("overlayPosition") , SettingsManager.Get("indOpacity") @@ -361,9 +407,11 @@ void handleVersion(string xmlData) .Value; Version cVersion = new Version(currentVersion); - Version lVersion = new Version(latestVersion); - + Version lVersion = new Version(latestVersion); + +#if !DEBUG if (lVersion > cVersion) +#endif { UpdateDialog ud = new UpdateDialog(); ud.ShowInTaskbar = isHidden; @@ -601,6 +649,21 @@ private void localeComboBox_Format(object sender, ListControlConvertEventArgs e) e.Value = "--LINE--"; else e.Value = string.Format("{0} ({1})", itm.displayText, itm.localeString); - } + } + + private void showMenuItem_Click(object sender, EventArgs e) + { + Show(); + Focus(); + generalIcon.Visible = false; + isHidden = false; + ShowInTaskbar = true; + } + + private void exitMenuItem_Click(object sender, EventArgs e) + { + shouldClose = true; + Close(); + } } } diff --git a/CapsLockIndicatorV3/MainForm.resx b/CapsLockIndicatorV3/MainForm.resx index d34a5f6..35c7307 100644 --- a/CapsLockIndicatorV3/MainForm.resx +++ b/CapsLockIndicatorV3/MainForm.resx @@ -184,6 +184,9 @@ 593, 17 + + 17, 56 + AAABAAUAAAAAAAEAIADHJAAAVgAAADAwAAABACAAqCUAAB0lAAAgIAAAAQAgAKgQAADFSgAAGBgAAAEA diff --git a/CapsLockIndicatorV3/Native.cs b/CapsLockIndicatorV3/Native.cs index 789d4ed..dcc7d3b 100644 --- a/CapsLockIndicatorV3/Native.cs +++ b/CapsLockIndicatorV3/Native.cs @@ -33,6 +33,7 @@ internal static class Native const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20; const int PREFFERED_APP_MODE__ALLOW_DARK = 1; const int PREFFERED_APP_MODE__DEFAULT = 0; + const int PREFFERED_APP_MODE__FORCE_DARK = 2; public enum DeviceCap { @@ -50,6 +51,11 @@ struct WindowCompositionAttributeData public int SizeOfData; } + public static void SetDarkMode(IntPtr handle, bool v) + { + SetWindowTheme(handle, v ? "DarkMode_Explorer" : "Explorer", null); + } + public static void ControlSetDarkMode(Control control, bool v) { SetWindowTheme(control.Handle, v ? "DarkMode_Explorer" : "Explorer", null); @@ -83,7 +89,7 @@ internal static bool UseImmersiveDarkModeColors(IntPtr handle, bool dark) public static void SetPrefferDarkMode(bool dark) { - SetPreferredAppMode(dark ? PREFFERED_APP_MODE__ALLOW_DARK : PREFFERED_APP_MODE__DEFAULT); + SetPreferredAppMode(dark ? PREFFERED_APP_MODE__FORCE_DARK : PREFFERED_APP_MODE__DEFAULT); } public static bool UseImmersiveDarkMode(IntPtr handle, bool enabled) diff --git a/CapsLockIndicatorV3/Program.cs b/CapsLockIndicatorV3/Program.cs index 312392c..212b7eb 100644 --- a/CapsLockIndicatorV3/Program.cs +++ b/CapsLockIndicatorV3/Program.cs @@ -7,6 +7,7 @@ using Mono.Options; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; @@ -14,9 +15,9 @@ using System.Windows.Forms; namespace CapsLockIndicatorV3 -{ - internal sealed class Program - { +{ + internal sealed class Program + { [Flags] enum KeyType { @@ -37,14 +38,14 @@ static void SetDisplay(DisplayType type, int keys) switch (type) { case DisplayType.Icon: - SettingsManager.Set("numIco" , (keys & (int)KeyType.NumLock) != 0); - SettingsManager.Set("capsIco" , (keys & (int)KeyType.CapsLock) != 0); - SettingsManager.Set("scrollIco" , (keys & (int)KeyType.ScrollLock) != 0); + SettingsManager.Set("numIco", (keys & (int)KeyType.NumLock) != 0); + SettingsManager.Set("capsIco", (keys & (int)KeyType.CapsLock) != 0); + SettingsManager.Set("scrollIco", (keys & (int)KeyType.ScrollLock) != 0); break; case DisplayType.Notification: - SettingsManager.Set("numInd" , (keys & (int)KeyType.NumLock) != 0); - SettingsManager.Set("capsInd" , (keys & (int)KeyType.CapsLock) != 0); - SettingsManager.Set("scrollInd" , (keys & (int)KeyType.ScrollLock) != 0); + SettingsManager.Set("numInd", (keys & (int)KeyType.NumLock) != 0); + SettingsManager.Set("capsInd", (keys & (int)KeyType.CapsLock) != 0); + SettingsManager.Set("scrollInd", (keys & (int)KeyType.ScrollLock) != 0); break; default: break; @@ -69,15 +70,15 @@ static void SetVerCheck(bool v) } static void DisplayHelp(OptionSet p) { - StringWriter sw = new StringWriter(); - + StringWriter sw = new StringWriter(); + sw.WriteLine("CapsLock Indicator"); sw.WriteLine(); sw.WriteLine("Options:"); p.WriteOptionDescriptions(sw); sw.WriteLine(); - sw.WriteLine("For more information, visit: http://cli.jonaskohl.de/!/commandline"); - + sw.WriteLine("For more information, visit: http://cli.jonaskohl.de/!/commandline"); + string result = sw.ToString(); sw.Close(); @@ -100,9 +101,9 @@ static void SetDisplayLocation(string v) // Create a mutex to check if an instance is already running static Mutex mutex = new Mutex(true, "{6f54c357-0542-4d7d-9225-338bc3cd7834}"); - [STAThread] - private static void Main(string[] args) - { + [STAThread] + private static void Main(string[] args) + { //__FIXME__.SettingsKey = Environment.ExpandEnvironmentVariables(@"%appdata%\Jonas Kohl\CapsLock Indicator\settings\any\user.config"); SettingsManager.Load(); @@ -143,15 +144,32 @@ private static void Main(string[] args) return; } - SettingsManager.Save(); + SettingsManager.Save(); + if (SettingsManager.Get("beta_enableDarkMode")) + Native.SetPrefferDarkMode(true); + + var runApp = true; + #endregion + +#if DEBUG + if (SettingsManager.Get("firstRun")) +#else + if (SettingsManager.Get("firstRun") && new Version(SettingsManager.Get("versionNo")) >= Assembly.GetExecutingAssembly().GetName().Version) +#endif + { + using (var d = new FirstRunDialog()) + { + if (d.ShowDialog() == DialogResult.OK) + SettingsManager.Set("firstRun", false); + else + runApp = false; + } + } - if (Environment.CurrentDirectory.ToLower() == Environment.ExpandEnvironmentVariables(@"%systemroot%\system32").ToLower() || - Environment.CurrentDirectory.ToLower() == Environment.ExpandEnvironmentVariables(@"%systemroot%\system32\").ToLower()) - Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - - Application.Run(new MainForm()); + if (runApp) + Application.Run(new MainForm()); // Release the mutex mutex.ReleaseMutex(); @@ -162,8 +180,8 @@ private static void Main(string[] args) { Application.EnableVisualStyles(); MessageBox.Show("An instance is already open!"); - } - } + } + } public static void ReleaseMutex() { diff --git a/CapsLockIndicatorV3/Properties/AssemblyInfo.cs b/CapsLockIndicatorV3/Properties/AssemblyInfo.cs index a828397..06dd573 100644 --- a/CapsLockIndicatorV3/Properties/AssemblyInfo.cs +++ b/CapsLockIndicatorV3/Properties/AssemblyInfo.cs @@ -12,7 +12,7 @@ [assembly: AssemblyConfiguration ("")] [assembly: AssemblyCompany ("Jonas Kohl")] [assembly: AssemblyProduct ("CapsLock Indicator")] -[assembly: AssemblyCopyright("© 2017-2020 Jonas Kohl / All rights reserved")] +[assembly: AssemblyCopyright("© 2017-2021 Jonas Kohl / All rights reserved")] [assembly: AssemblyTrademark ("")] [assembly: AssemblyCulture ("")] // This sets the default COM visibility of types in the assembly to invisible. @@ -24,6 +24,6 @@ // // You can specify all the values or you can use the default the Revision and // Build Numbers by using the '*' as shown below: -[assembly: AssemblyVersion("3.9.1.0")] -[assembly: AssemblyFileVersion("3.9.1.0")] +[assembly: AssemblyVersion("3.10.0.0")] +[assembly: AssemblyFileVersion("3.10.0.0")] [assembly: Guid ("6f54c357-0542-4d7d-9225-338bc3cd7834")] diff --git a/CapsLockIndicatorV3/Resources/defaultSettings.txt b/CapsLockIndicatorV3/Resources/defaultSettings.txt index 41cc460..802a905 100644 --- a/CapsLockIndicatorV3/Resources/defaultSettings.txt +++ b/CapsLockIndicatorV3/Resources/defaultSettings.txt @@ -11,6 +11,8 @@ b:hideOnStartup=False b:checkForUpdates=True b:upgradeRequired=True b:alwaysShowWhenActive=False +b:firstRun=True +b:advSettingsWarnShown=False c:indBgColourActive=255;66;66;66 c:indFgColourActive=255;255;255;255 c:indBdColourActive=255;77;180;52 @@ -21,5 +23,12 @@ f:indFont=Segoe UI; 12pt i:indDisplayTime=500 i:selectedUICulture=1 i:indOpacity=100 -s:versionNo=3.9.0.0 +i:bdSize=4 +s:versionNo=3.10.0.0 s:overlayPosition=BottomRight +s:customMessageCapsOn= +s:customMessageCapsOff= +s:customMessageNumOn= +s:customMessageNumOff= +s:customMessageScrollOn= +s:customMessageScrollOff= diff --git a/CapsLockIndicatorV3/Resources/logo_dark.Image.png b/CapsLockIndicatorV3/Resources/logo_dark.Image.png new file mode 100644 index 0000000000000000000000000000000000000000..5f3fe378e3d424cb2ee2ba6ef43291f3c476e2d0 GIT binary patch literal 999 zcmV663@d#Gh6g@LIShK#UQ;^4|s<4-of0Ab#Vv z0);fNm3Wi*h1f2IhYD=sHW6N(+?P@VLE>9tw_@Sh@DuNFUwc&<2ouMM^`dyF=RQx^ zHPA|YMcgck4?p+aV$}e|_X=m>A@&iQ%^C>1K)j5;T;Zf=0F!4xxCqB=q4;L&55CBJw^;bV+ZlNJOY)R+xVP_i_!OQME}Fvsm}vLQ$}vV zDC|OptIdJaPKh6Rml5CG)@AfIA8THl#8IcjKkiA3Z)xum2M;%yxjm{GKryo4iLjBy zhYmHFZ33xyRT)=Ojy`z{;x&XY0tZS|JkaRnHMLa2CL6mELOV+E$!n;_2vn4)c%Z_| z^=K)D&AR=-^r-}Lo6e4i;p>x0{m-i4ZoU|PlBY_c7hy)D$F7zCL34{-T zv;lKM5mLF(chk372nEExW8C|C&PGNEWBW?^8W7$YE?P&g;XVPK?KBamxO z*f22$132RTSnPyO9tn#k5IGClJ}~G+Js>Z!7Uo1;E@)nw+7FUyO~|X0(e+=X-zlsW z^?14PRHTo%^J4kOoc?a?$tv9C0$%U4$MVB?BGPYs)}2b+BVNjPsCDMtRq;F?OPNp& zv~2*Z#QS>ZLI7T1bPIO_8t=-vkc>yfPc9Y@ZN1saoQxIXc^)RWVU@M5Y-9kKLDsBx zt+9r*mt`Td9*!w4K2%q5mtA^WLG+mk~{<#fKjD!5WT*|8wBJ*>b&um)B&u#t-FaQ$5 V8+;J_#2o+t002ovPDHLkV1iB?%-jF~ literal 0 HcmV?d00001 diff --git a/CapsLockIndicatorV3/SettingsManager.cs b/CapsLockIndicatorV3/SettingsManager.cs index 0ded781..d8445d9 100644 --- a/CapsLockIndicatorV3/SettingsManager.cs +++ b/CapsLockIndicatorV3/SettingsManager.cs @@ -3,6 +3,7 @@ using System.Drawing; using System.IO; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; @@ -11,6 +12,7 @@ namespace CapsLockIndicatorV3 public static class SettingsManager { public static string SettingsFilePath => Environment.ExpandEnvironmentVariables(@"%appdata%\Jonas Kohl\CapsLock Indicator\settings\any\usercfg"); + public static string SettingsFileLocal => Environment.ExpandEnvironmentVariables(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "usercfg")); private static Dictionary Settings; @@ -39,10 +41,15 @@ private static void LoadDefaults() private static void LoadUser() { + var path = SettingsFileLocal; + + if (!File.Exists(path)) + path = SettingsFilePath; + if (!File.Exists(SettingsFilePath)) return; - var lines = File.ReadAllLines(SettingsFilePath); + var lines = File.ReadAllLines(path); if (Settings == null) Settings = new Dictionary(); @@ -97,9 +104,14 @@ public static void Save() foreach (var s in Settings) sb.AppendFormat("{0}:{1}={2}\n", GetSettingsTypeIndicator(s.Value.Item1), s.Key, ConvertToString(s.Value.Item2)); - if (!Directory.Exists(Path.GetDirectoryName(SettingsFilePath))) - Directory.CreateDirectory(Path.GetDirectoryName(SettingsFilePath)); - File.WriteAllText(SettingsFilePath, sb.ToString()); + var path = SettingsFileLocal; + + if (!File.Exists(path)) + path = SettingsFilePath; + + if (!Directory.Exists(Path.GetDirectoryName(path))) + Directory.CreateDirectory(Path.GetDirectoryName(path)); + File.WriteAllText(path, sb.ToString()); } private static object Cast(string value, Type type) @@ -171,5 +183,15 @@ public static void Set(string key, object value) { Settings[key] = (value.GetType(), value); } + + public static string GetActualPath() + { + var path = SettingsFileLocal; + + if (!File.Exists(path)) + path = SettingsFilePath; + + return path; + } } } diff --git a/CapsLockIndicatorV3/UpdateDialog.cs b/CapsLockIndicatorV3/UpdateDialog.cs index fa9718f..707a8e0 100644 --- a/CapsLockIndicatorV3/UpdateDialog.cs +++ b/CapsLockIndicatorV3/UpdateDialog.cs @@ -23,8 +23,39 @@ public UpdateDialog() updateNowButton.Text = strings.updateNow; dismissButton.Text = strings.dismissButton; downloadManuallyButton.Text = strings.downloadManuallyButton; - } + if (SettingsManager.Get("beta_enableDarkMode")) + { + HandleCreated += UpdateDialog_HandleCreated; + + lnkLabel1.ForeColor = + lnkLabel1.LinkColor = + Color.White; + + BackColor = Color.FromArgb(255, 32, 32, 32); + ForeColor = Color.White; + infoLabel.ForeColor = Color.FromArgb(255, 196, 204, 238); + changelogRtf.BackColor = Color.FromArgb(255, 56, 56, 56); + + ControlScheduleSetDarkMode(dismissButton); + ControlScheduleSetDarkMode(updateNowButton); + ControlScheduleSetDarkMode(downloadManuallyButton); + } + } + + private void UpdateDialog_HandleCreated(object sender, EventArgs e) + { + Native.UseImmersiveDarkModeColors(Handle, true); + } + + private void ControlScheduleSetDarkMode(Control control) + { + control.HandleCreated += (sender, e) => + { + Native.ControlSetDarkMode(control, true); + }; + } + public void SetNewVersion(Version v) { newVersion = v; diff --git a/CapsLockIndicatorV3/VersionCheck.cs b/CapsLockIndicatorV3/VersionCheck.cs index fccca7e..b136482 100644 --- a/CapsLockIndicatorV3/VersionCheck.cs +++ b/CapsLockIndicatorV3/VersionCheck.cs @@ -27,7 +27,7 @@ public static async void IsLatestVersion(Action callback, bool isManualC ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; try { - string data = await client.DownloadStringTaskAsync(CheckURL); + string data = await client.DownloadStringTaskAsync(CheckURL + (SettingsManager.Get("beta_enableDarkMode") ? "&dark=true" : "")); callback(data); } catch (Exception e) diff --git a/CapsLockIndicatorV3/resources.Designer.cs b/CapsLockIndicatorV3/resources.Designer.cs index ab62dea..cc7086f 100644 --- a/CapsLockIndicatorV3/resources.Designer.cs +++ b/CapsLockIndicatorV3/resources.Designer.cs @@ -130,35 +130,43 @@ internal static System.Drawing.Icon CLIv3_Scroll_On { } /// - /// Looks up a localized string similar to b:numIco=true - ///b:capsIco=true - ///b:scrollIco=true - ///b:numInd=true - ///b:capsInd=true - ///b:scrollInd=true - ///b:noIco=false - ///b:noInd=false - ///b:beta_enableDarkMode=false - ///b:hideOnStartup=false - ///b:checkForUpdates=true - ///b:upgradeRequired=true - ///c:indBgColourActive=66,66,66 - ///c:indFgColourActive=255,255,255 - ///c:indBgColourActive=77,180,52 - ///c:indBgColourInactive=66,66,66 - ///c:indFgColourInactive=255,255,255 - ///c:indBgColourInactive=180,52,77 - ///i:indDisplayTime=500 - ///i:selectedUICulture=-1 - ///i:indOpacity=100 - ///s:versionNo=3.9.0.0 - ///s:indFont=Segoe UI; 12pt - ///s: [rest of string was truncated]";. + /// Looks up a localized string similar to b:numIco=True + ///b:capsIco=True + ///b:scrollIco=True + ///b:numInd=True + ///b:capsInd=True + ///b:scrollInd=True + ///b:noIco=False + ///b:noInd=False + ///b:beta_enableDarkMode=False + ///b:hideOnStartup=False + ///b:checkForUpdates=True + ///b:upgradeRequired=True + ///b:alwaysShowWhenActive=False + ///b:firstRun=True + ///c:indBgColourActive=255;66;66;66 + ///c:indFgColourActive=255;255;255;255 + ///c:indBdColourActive=255;77;180;52 + ///c:indBgColourInactive=255;66;66;66 + ///c:indFgColourInactive=255;255;255;255 + ///c:indBdColourInactive=255;180;52;77 + ///f:indFont=Segoe UI; 12pt + ///i:indDisplayTi [rest of string was truncated]";. /// internal static string defaultSettings { get { return ResourceManager.GetString("defaultSettings", resourceCulture); } } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap logo_dark { + get { + object obj = ResourceManager.GetObject("logo_dark", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } } } diff --git a/CapsLockIndicatorV3/resources.resx b/CapsLockIndicatorV3/resources.resx index 422a029..c95a6b5 100644 --- a/CapsLockIndicatorV3/resources.resx +++ b/CapsLockIndicatorV3/resources.resx @@ -142,4 +142,7 @@ Resources\defaultSettings.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + Resources\logo_dark.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/CapsLockIndicatorV3/strings.Designer.cs b/CapsLockIndicatorV3/strings.Designer.cs index b817c7b..0d12261 100644 --- a/CapsLockIndicatorV3/strings.Designer.cs +++ b/CapsLockIndicatorV3/strings.Designer.cs @@ -60,6 +60,15 @@ internal strings() { } } + /// + /// Looks up a localized string similar to Advanced Settings. + /// + internal static string advancedSettings { + get { + return ResourceManager.GetString("advancedSettings", resourceCulture); + } + } + /// /// Looks up a localized string similar to Background colour activated. /// @@ -96,6 +105,15 @@ internal static string borderColourDeactivatedButton { } } + /// + /// Looks up a localized string similar to Border thickness. + /// + internal static string borderThicknessGroup { + get { + return ResourceManager.GetString("borderThicknessGroup", resourceCulture); + } + } + /// /// Looks up a localized string similar to Caps lock. /// @@ -204,6 +222,69 @@ internal static string exitMessage { } } + /// + /// Looks up a localized string similar to Allow CapsLock Indicator to periodically check for updates online (can be changed later). + /// + internal static string firstRunAllowUpdateCheck { + get { + return ResourceManager.GetString("firstRunAllowUpdateCheck", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Contribute. + /// + internal static string firstRunContribute { + get { + return ResourceManager.GetString("firstRunContribute", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to &Exit. + /// + internal static string firstRunExit { + get { + return ResourceManager.GetString("firstRunExit", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Welcome to CapsLock Indicator. + /// + internal static string firstRunHeading { + get { + return ResourceManager.GetString("firstRunHeading", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Thank you for choosing CapsLock Indicator! This program is open-source and free, always has been, always will be! Are you interested in contributing to CapsLock Indicator yourself? Visit the link below for more information! Also, please take a moment to review the settings below!. + /// + internal static string firstRunMessage { + get { + return ResourceManager.GetString("firstRunMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to What information will be sent?. + /// + internal static string firstRunPrivacyInfoLinkLabel { + get { + return ResourceManager.GetString("firstRunPrivacyInfoLinkLabel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to &Let's go!. + /// + internal static string firstRunStart { + get { + return ResourceManager.GetString("firstRunStart", resourceCulture); + } + } + /// /// Looks up a localized string similar to Font. /// diff --git a/CapsLockIndicatorV3/strings.de.resx b/CapsLockIndicatorV3/strings.de.resx index 9886bef..aa726c0 100644 --- a/CapsLockIndicatorV3/strings.de.resx +++ b/CapsLockIndicatorV3/strings.de.resx @@ -117,6 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Erw. Einstellungen + Hintergrund aktiv @@ -129,6 +132,9 @@ Rand inaktiv + + Randstärke + Feststelltaste @@ -165,6 +171,27 @@ Die Anwendung zu verlassen heißt, dass die Icons und Benachrichtigungen nicht länger angezeigt weden. Trotzdem verlassen? + + Zulassen, dass CapsLock Indicator online nach Aktualisierungen sucht + + + Mitarbeiten + + + Verlass&en + + + Willkommen bei CapsLock Indicator! + + + Vielen Dank, dass Sie sich für CapsLock Indicator entschieden haben. Diese Anwendung is quelloffen und kostenlos! Für immer! Sind Sie daran interessiert, selbst an CapsLock Indicator zu arbeiten? Klicken Sie den untenstehenden Link für mehr Information. Außerdem bitten wir Sie, sich einen Moment zu nehmen, um die untenstehenden Einstellungen zu überprüfen. + + + Welche Informationen werden übermittelt? + + + &Loslegen + Schrift @@ -229,7 +256,7 @@ Zeige Benachr., wenn... - Benachrichtigung immer anz., wenn aktiv + Benachr. immer anz., wenn aktiv Autostart diff --git a/CapsLockIndicatorV3/strings.resx b/CapsLockIndicatorV3/strings.resx index d7f4281..89a02ce 100644 --- a/CapsLockIndicatorV3/strings.resx +++ b/CapsLockIndicatorV3/strings.resx @@ -117,6 +117,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Advanced Settings + Label of the hyperlink that opens the settings file + Background colour activated The caption for the "Background colour activated" button. @@ -133,6 +137,10 @@ Border colour deactivated The caption for the "Border colour deactivated" button. + + Border thickness + Label of the border thickness groupbox + Caps lock The name of the caps lock key @@ -181,6 +189,34 @@ Exiting the application means the icons and notifications are no longer displayed. Exit anyway? The message to display on application exit + + Allow CapsLock Indicator to periodically check for updates online (can be changed later) + Label of the checkbox that determines whether or not CLI should search for updates + + + Contribute + Label of the hyperlink that takes you to CLI's GitHub page + + + &Exit + Button that exists the application. The character after the "&" is the hotkey that is used with the ALT key. + + + Welcome to CapsLock Indicator + The heading of the first-run dialog + + + Thank you for choosing CapsLock Indicator! This program is open-source and free, always has been, always will be! Are you interested in contributing to CapsLock Indicator yourself? Visit the link below for more information! Also, please take a moment to review the settings below! + The message of the first-run dialog + + + What information will be sent? + The label of the hyperlink that shows which information will be sent on each update check + + + &Let's go! + Button that starts the application. The character after the "&" is the hotkey that is used with the ALT key. + Font The title for the "Font" group box