From 3400718cb49259c51174b90191d272b6253d5a64 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rub=C3=A9n=20Corz=C3=B3n=20Villar?=
<37846227+czoon@users.noreply.github.com>
Date: Fri, 3 Jul 2020 18:42:26 +0200
Subject: [PATCH 01/11] Beginning "Start minimized" checkbox implementation.
---
QuietOnTheSetUI/Form1.Designer.cs | 30 ++++++++++++++++++++++--------
QuietOnTheSetUI/Form1.cs | 16 +++++++++++++---
2 files changed, 35 insertions(+), 11 deletions(-)
diff --git a/QuietOnTheSetUI/Form1.Designer.cs b/QuietOnTheSetUI/Form1.Designer.cs
index 289059f..2239f06 100644
--- a/QuietOnTheSetUI/Form1.Designer.cs
+++ b/QuietOnTheSetUI/Form1.Designer.cs
@@ -47,6 +47,7 @@ private void InitializeComponent()
this.exitButton = new System.Windows.Forms.Button();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.footerLabel = new System.Windows.Forms.Label();
+ this.checkBox2 = new System.Windows.Forms.CheckBox();
((System.ComponentModel.ISupportInitialize)(this.volumeTrackBar)).BeginInit();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
@@ -75,20 +76,20 @@ private void InitializeComponent()
//
// passwordTextBox
//
- this.passwordTextBox.Font = new System.Drawing.Font("Century Schoolbook", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.passwordTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.passwordTextBox.Location = new System.Drawing.Point(17, 251);
this.passwordTextBox.Name = "passwordTextBox";
- this.passwordTextBox.Size = new System.Drawing.Size(224, 33);
+ this.passwordTextBox.Size = new System.Drawing.Size(224, 31);
this.passwordTextBox.TabIndex = 3;
this.passwordTextBox.UseSystemPasswordChar = true;
this.passwordTextBox.TextChanged += new System.EventHandler(this.passwordTextBox_TextChanged);
//
// confirmPasswordTextBox
//
- this.confirmPasswordTextBox.Font = new System.Drawing.Font("Century Schoolbook", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.confirmPasswordTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.confirmPasswordTextBox.Location = new System.Drawing.Point(17, 322);
this.confirmPasswordTextBox.Name = "confirmPasswordTextBox";
- this.confirmPasswordTextBox.Size = new System.Drawing.Size(224, 33);
+ this.confirmPasswordTextBox.Size = new System.Drawing.Size(224, 31);
this.confirmPasswordTextBox.TabIndex = 4;
this.confirmPasswordTextBox.UseSystemPasswordChar = true;
this.confirmPasswordTextBox.TextChanged += new System.EventHandler(this.confirmPasswordTextBox_TextChanged);
@@ -144,7 +145,7 @@ private void InitializeComponent()
//
this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
- this.label3.Font = new System.Drawing.Font("Century Schoolbook", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3.Location = new System.Drawing.Point(2, 7);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(765, 38);
@@ -154,7 +155,7 @@ private void InitializeComponent()
//
// label4
//
- this.label4.Font = new System.Drawing.Font("Century Schoolbook", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.Location = new System.Drawing.Point(-1, 59);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(187, 25);
@@ -187,7 +188,7 @@ private void InitializeComponent()
this.label5.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.label5.Font = new System.Drawing.Font("Century Schoolbook", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label5.Location = new System.Drawing.Point(-1, 59);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(187, 25);
@@ -220,7 +221,7 @@ private void InitializeComponent()
//
this.checkBox1.AutoSize = true;
this.checkBox1.Font = new System.Drawing.Font("Calibri", 15.75F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.checkBox1.Location = new System.Drawing.Point(365, 363);
+ this.checkBox1.Location = new System.Drawing.Point(365, 338);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(272, 30);
this.checkBox1.TabIndex = 14;
@@ -240,11 +241,23 @@ private void InitializeComponent()
this.footerLabel.Text = "v1.0.10 Built on December 29, 2016";
this.footerLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
+ // checkBox2
+ //
+ this.checkBox2.AutoSize = true;
+ this.checkBox2.Font = new System.Drawing.Font("Calibri", 15.75F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.checkBox2.Location = new System.Drawing.Point(365, 363);
+ this.checkBox2.Name = "checkBox2";
+ this.checkBox2.Size = new System.Drawing.Size(167, 30);
+ this.checkBox2.TabIndex = 16;
+ this.checkBox2.Text = "Start minimized";
+ this.checkBox2.UseVisualStyleBackColor = true;
+ //
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(763, 418);
+ this.Controls.Add(this.checkBox2);
this.Controls.Add(this.footerLabel);
this.Controls.Add(this.checkBox1);
this.Controls.Add(this.exitButton);
@@ -290,6 +303,7 @@ private void InitializeComponent()
private System.Windows.Forms.Button exitButton;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.Label footerLabel;
+ private System.Windows.Forms.CheckBox checkBox2;
}
}
diff --git a/QuietOnTheSetUI/Form1.cs b/QuietOnTheSetUI/Form1.cs
index a0123d5..258677e 100644
--- a/QuietOnTheSetUI/Form1.cs
+++ b/QuietOnTheSetUI/Form1.cs
@@ -22,6 +22,8 @@ public partial class Form1 : Form
private string _password;
private int _maxVolume;
private bool _exitAllowed = false;
+ private RegistryKey rk = Registry.CurrentUser.OpenSubKey
+ ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
public Form1()
{
@@ -236,9 +238,6 @@ private void exitButton_Click(object sender, EventArgs e)
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
- RegistryKey rk = Registry.CurrentUser.OpenSubKey
- ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
-
if (checkBox1.Checked)
{
rk.SetValue("QuietOnTheSet", Application.ExecutablePath.ToString());
@@ -248,5 +247,16 @@ private void checkBox1_CheckedChanged(object sender, EventArgs e)
rk.DeleteValue("QuietOnTheSet", false);
}
}
+ private void checkBox2_CheckedChanged(object sender, EventArgs e)
+ {
+ if (checkBox2.Checked)
+ {
+ // rk.SetValue("QuietOnTheSet_StartMinimized", true);
+ }
+ else
+ {
+ // rk.DeleteValue("QuietOnTheSet_StartMinimized", false);
+ }
+ }
}
}
From cf053d197dceadc23d4554fd4323c9ea3cbd5fef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rub=C3=A9n=20Corz=C3=B3n=20Villar?=
<37846227+czoon@users.noreply.github.com>
Date: Fri, 3 Jul 2020 19:05:05 +0200
Subject: [PATCH 02/11] Added new user registry keys for starting
configuration.
---
QuietOnTheSetUI/Form1.cs | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/QuietOnTheSetUI/Form1.cs b/QuietOnTheSetUI/Form1.cs
index 258677e..d9de7ce 100644
--- a/QuietOnTheSetUI/Form1.cs
+++ b/QuietOnTheSetUI/Form1.cs
@@ -22,8 +22,8 @@ public partial class Form1 : Form
private string _password;
private int _maxVolume;
private bool _exitAllowed = false;
- private RegistryKey rk = Registry.CurrentUser.OpenSubKey
- ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
+ private RegistryKey _qotsRegistryKey = Registry.CurrentUser.CreateSubKey
+ ("SOFTWARE\\QuietOnTheSet");
public Form1()
{
@@ -238,6 +238,9 @@ private void exitButton_Click(object sender, EventArgs e)
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
+ RegistryKey rk = Registry.CurrentUser.OpenSubKey
+ ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
+
if (checkBox1.Checked)
{
rk.SetValue("QuietOnTheSet", Application.ExecutablePath.ToString());
@@ -246,17 +249,13 @@ private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
rk.DeleteValue("QuietOnTheSet", false);
}
+
+ _qotsRegistryKey.SetValue("startAutomatically", checkBox1.Checked);
}
+
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
- if (checkBox2.Checked)
- {
- // rk.SetValue("QuietOnTheSet_StartMinimized", true);
- }
- else
- {
- // rk.DeleteValue("QuietOnTheSet_StartMinimized", false);
- }
+ _qotsRegistryKey.SetValue("startMinimized", checkBox2.Checked);
}
}
}
From 35c8dbf1d09860161cb892db3c4ef6da7cb0c35d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rub=C3=A9n=20Corz=C3=B3n=20Villar?=
<37846227+czoon@users.noreply.github.com>
Date: Fri, 3 Jul 2020 19:21:30 +0200
Subject: [PATCH 03/11] Access to current user registry keys.
---
QuietOnTheSetUI/Form1.Designer.cs | 1 +
QuietOnTheSetUI/Form1.cs | 4 ++++
2 files changed, 5 insertions(+)
diff --git a/QuietOnTheSetUI/Form1.Designer.cs b/QuietOnTheSetUI/Form1.Designer.cs
index 2239f06..b290530 100644
--- a/QuietOnTheSetUI/Form1.Designer.cs
+++ b/QuietOnTheSetUI/Form1.Designer.cs
@@ -251,6 +251,7 @@ private void InitializeComponent()
this.checkBox2.TabIndex = 16;
this.checkBox2.Text = "Start minimized";
this.checkBox2.UseVisualStyleBackColor = true;
+ this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
//
// Form1
//
diff --git a/QuietOnTheSetUI/Form1.cs b/QuietOnTheSetUI/Form1.cs
index d9de7ce..20d9549 100644
--- a/QuietOnTheSetUI/Form1.cs
+++ b/QuietOnTheSetUI/Form1.cs
@@ -29,6 +29,10 @@ public Form1()
{
InitializeComponent();
// Bitmap applicationIcon = QuietOnTheSetUI.Properties.Resources.appicon;
+
+ checkBox1.Checked = Convert.ToBoolean(_qotsRegistryKey.GetValue("startAutomatically"));
+ checkBox2.Checked = Convert.ToBoolean(_qotsRegistryKey.GetValue("startMinimized"));
+
this.Icon = QuietOnTheSetUI.Properties.Resources.appicon;
mmDevice = MMDE.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
notifyIcon1.Icon = QuietOnTheSetUI.Properties.Resources.appicon;
From 43c2cda7781e644e326ee7607d775345827e26fc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rub=C3=A9n=20Corz=C3=B3n=20Villar?=
<37846227+czoon@users.noreply.github.com>
Date: Fri, 3 Jul 2020 20:06:27 +0200
Subject: [PATCH 04/11] Try/catch when accessing registry values.
---
QuietOnTheSetUI/Form1.cs | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/QuietOnTheSetUI/Form1.cs b/QuietOnTheSetUI/Form1.cs
index 20d9549..c801121 100644
--- a/QuietOnTheSetUI/Form1.cs
+++ b/QuietOnTheSetUI/Form1.cs
@@ -30,8 +30,21 @@ public Form1()
InitializeComponent();
// Bitmap applicationIcon = QuietOnTheSetUI.Properties.Resources.appicon;
- checkBox1.Checked = Convert.ToBoolean(_qotsRegistryKey.GetValue("startAutomatically"));
- checkBox2.Checked = Convert.ToBoolean(_qotsRegistryKey.GetValue("startMinimized"));
+ // The registry keys are ignored if they can't be converted or retrieved.
+ try
+ {
+ checkBox1.Checked = Convert.ToBoolean(_qotsRegistryKey.GetValue("startAutomatically"));
+ checkBox2.Checked = Convert.ToBoolean(_qotsRegistryKey.GetValue("startMinimized"));
+ if(checkBox2.Checked)
+ {
+ this.WindowState = FormWindowState.Minimized;
+ }
+ }
+ catch (Exception)
+ {
+ checkBox1.Checked = false;
+ checkBox2.Checked = false;
+ }
this.Icon = QuietOnTheSetUI.Properties.Resources.appicon;
mmDevice = MMDE.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
From 9513bf42bc9b0aa6f9c545b5709825d8e580f830 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rub=C3=A9n=20Corz=C3=B3n=20Villar?=
<37846227+czoon@users.noreply.github.com>
Date: Sat, 4 Jul 2020 01:17:59 +0200
Subject: [PATCH 05/11] Application not shown in taskbar when starts minimized.
---
QuietOnTheSetUI/Form1.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/QuietOnTheSetUI/Form1.cs b/QuietOnTheSetUI/Form1.cs
index c801121..ddc5273 100644
--- a/QuietOnTheSetUI/Form1.cs
+++ b/QuietOnTheSetUI/Form1.cs
@@ -38,6 +38,7 @@ public Form1()
if(checkBox2.Checked)
{
this.WindowState = FormWindowState.Minimized;
+ this.ShowInTaskbar = false;
}
}
catch (Exception)
From a48bd81ddc0088f29f4b99bddad2e3b1e25695cc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rub=C3=A9n=20Corz=C3=B3n=20Villar?=
<37846227+czoon@users.noreply.github.com>
Date: Sat, 4 Jul 2020 13:41:21 +0200
Subject: [PATCH 06/11] Registry values configuration replaced with
Properties.Settings.
---
QuietOnTheSetUI/Form1.cs | 21 ++++++------
.../Properties/Settings.Designer.cs | 34 ++++++++++++++++---
QuietOnTheSetUI/Properties/Settings.settings | 6 ++++
3 files changed, 45 insertions(+), 16 deletions(-)
diff --git a/QuietOnTheSetUI/Form1.cs b/QuietOnTheSetUI/Form1.cs
index ddc5273..24a054c 100644
--- a/QuietOnTheSetUI/Form1.cs
+++ b/QuietOnTheSetUI/Form1.cs
@@ -22,20 +22,17 @@ public partial class Form1 : Form
private string _password;
private int _maxVolume;
private bool _exitAllowed = false;
- private RegistryKey _qotsRegistryKey = Registry.CurrentUser.CreateSubKey
- ("SOFTWARE\\QuietOnTheSet");
public Form1()
{
InitializeComponent();
// Bitmap applicationIcon = QuietOnTheSetUI.Properties.Resources.appicon;
- // The registry keys are ignored if they can't be converted or retrieved.
try
{
- checkBox1.Checked = Convert.ToBoolean(_qotsRegistryKey.GetValue("startAutomatically"));
- checkBox2.Checked = Convert.ToBoolean(_qotsRegistryKey.GetValue("startMinimized"));
- if(checkBox2.Checked)
+ checkBox1.Checked = Convert.ToBoolean(Properties.Settings.Default["StartAutomatically"]);
+ checkBox2.Checked = Convert.ToBoolean(Properties.Settings.Default["StartMinimized"]);
+ if (checkBox2.Checked)
{
this.WindowState = FormWindowState.Minimized;
this.ShowInTaskbar = false;
@@ -104,7 +101,7 @@ private void Form1_FormClosing(object sender, FormClosingEventArgs e)
}
}
- internal void LockVolume (bool initializing=false)
+ internal void LockVolume(bool initializing = false)
{
_isLocked = true;
lockButton.Text = "Unlock";
@@ -168,13 +165,13 @@ private void SetMaxVolume()
private void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
{
var newVolume = Convert.ToInt16(data.MasterVolume * 100);
- if (_isLocked && newVolume > _maxVolume)
+ if (_isLocked && newVolume > _maxVolume)
{
SetMaxVolume();
}
if (currentVolumeLabel.InvokeRequired)
{
- currentVolumeLabel.Invoke(new MethodInvoker(delegate { currentVolumeLabel.Text = newVolume.ToString() ; }));
+ currentVolumeLabel.Invoke(new MethodInvoker(delegate { currentVolumeLabel.Text = newVolume.ToString(); }));
}
}
@@ -268,12 +265,14 @@ private void checkBox1_CheckedChanged(object sender, EventArgs e)
rk.DeleteValue("QuietOnTheSet", false);
}
- _qotsRegistryKey.SetValue("startAutomatically", checkBox1.Checked);
+ Properties.Settings.Default["StartAutomatically"] = checkBox1.Checked;
+ Properties.Settings.Default.Save();
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
- _qotsRegistryKey.SetValue("startMinimized", checkBox2.Checked);
+ Properties.Settings.Default["StartMinimized"] = checkBox2.Checked;
+ Properties.Settings.Default.Save();
}
}
}
diff --git a/QuietOnTheSetUI/Properties/Settings.Designer.cs b/QuietOnTheSetUI/Properties/Settings.Designer.cs
index ccc7fc2..9a908a9 100644
--- a/QuietOnTheSetUI/Properties/Settings.Designer.cs
+++ b/QuietOnTheSetUI/Properties/Settings.Designer.cs
@@ -1,10 +1,10 @@
//------------------------------------------------------------------------------
//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
+// Este código fue generado por una herramienta.
+// Versión de runtime:4.0.30319.42000
//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
+// Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si
+// se vuelve a generar el código.
//
//------------------------------------------------------------------------------
@@ -12,7 +12,7 @@ namespace QuietOnTheSetUI.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.5.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -58,5 +58,29 @@ public bool IsLocked {
this["IsLocked"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("False")]
+ public bool StartAutomatically {
+ get {
+ return ((bool)(this["StartAutomatically"]));
+ }
+ set {
+ this["StartAutomatically"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("False")]
+ public bool StartMinimized {
+ get {
+ return ((bool)(this["StartMinimized"]));
+ }
+ set {
+ this["StartMinimized"] = value;
+ }
+ }
}
}
diff --git a/QuietOnTheSetUI/Properties/Settings.settings b/QuietOnTheSetUI/Properties/Settings.settings
index e4515bb..75aa8bf 100644
--- a/QuietOnTheSetUI/Properties/Settings.settings
+++ b/QuietOnTheSetUI/Properties/Settings.settings
@@ -11,5 +11,11 @@
False
+
+ False
+
+
+ False
+
\ No newline at end of file
From 09e72efd293133d411e84561d898f3cff97ef599 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rub=C3=A9n=20Corz=C3=B3n=20Villar?=
<37846227+czoon@users.noreply.github.com>
Date: Sat, 4 Jul 2020 15:15:20 +0200
Subject: [PATCH 07/11] Volume locked by default with the last maximum value if
the application starts minimized.
---
QuietOnTheSetUI/Form1.cs | 3 +++
1 file changed, 3 insertions(+)
diff --git a/QuietOnTheSetUI/Form1.cs b/QuietOnTheSetUI/Form1.cs
index 24a054c..7f69b8c 100644
--- a/QuietOnTheSetUI/Form1.cs
+++ b/QuietOnTheSetUI/Form1.cs
@@ -36,6 +36,9 @@ public Form1()
{
this.WindowState = FormWindowState.Minimized;
this.ShowInTaskbar = false;
+ // The volume is automatically locked if the app is minimized
+ Properties.Settings.Default["IsLocked"] = true;
+ Properties.Settings.Default.Save();
}
}
catch (Exception)
From 9157e4144c99f4b0f0c8908e0ac8d9e26fcadb31 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rub=C3=A9n=20Corz=C3=B3n=20Villar?=
<37846227+czoon@users.noreply.github.com>
Date: Sat, 4 Jul 2020 23:55:13 +0200
Subject: [PATCH 08/11] Program hidden from alt+tab menu when minimized.
---
QuietOnTheSetUI/Form1.Designer.cs | 1 +
QuietOnTheSetUI/Form1.cs | 2 ++
2 files changed, 3 insertions(+)
diff --git a/QuietOnTheSetUI/Form1.Designer.cs b/QuietOnTheSetUI/Form1.Designer.cs
index b290530..3e7b1e5 100644
--- a/QuietOnTheSetUI/Form1.Designer.cs
+++ b/QuietOnTheSetUI/Form1.Designer.cs
@@ -272,6 +272,7 @@ private void InitializeComponent()
this.Controls.Add(this.lockButton);
this.Controls.Add(this.panel1);
this.Controls.Add(this.volumeTrackBar);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.Name = "Form1";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
diff --git a/QuietOnTheSetUI/Form1.cs b/QuietOnTheSetUI/Form1.cs
index 7f69b8c..5fb1ea7 100644
--- a/QuietOnTheSetUI/Form1.cs
+++ b/QuietOnTheSetUI/Form1.cs
@@ -85,12 +85,14 @@ private void Form1_Resize(object sender, EventArgs e)
{
if (FormWindowState.Minimized == this.WindowState)
{
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; // Hide QOTS from alt+tab
notifyIcon1.Visible = true;
notifyIcon1.ShowBalloonTip(500);
this.Hide();
}
else if (FormWindowState.Normal == this.WindowState)
{
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
notifyIcon1.Visible = false;
}
}
From bceb2ca7bc344334d28fac28e7679cedde8eaf5b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rub=C3=A9n=20Corz=C3=B3n=20Villar?=
<37846227+czoon@users.noreply.github.com>
Date: Sun, 5 Jul 2020 18:32:53 +0200
Subject: [PATCH 09/11] App is completely hidden if it starts minimized.
---
QuietOnTheSetUI/Form1.cs | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/QuietOnTheSetUI/Form1.cs b/QuietOnTheSetUI/Form1.cs
index 5fb1ea7..b15a8a9 100644
--- a/QuietOnTheSetUI/Form1.cs
+++ b/QuietOnTheSetUI/Form1.cs
@@ -34,8 +34,9 @@ public Form1()
checkBox2.Checked = Convert.ToBoolean(Properties.Settings.Default["StartMinimized"]);
if (checkBox2.Checked)
{
- this.WindowState = FormWindowState.Minimized;
- this.ShowInTaskbar = false;
+ // Hides the app completely
+ Form1_FormClosing(null, new FormClosingEventArgs(new CloseReason(), true));
+
// The volume is automatically locked if the app is minimized
Properties.Settings.Default["IsLocked"] = true;
Properties.Settings.Default.Save();
From f10a65da4caca0febbd06d4aae16ba11f897a9c8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rub=C3=A9n=20Corz=C3=B3n=20Villar?=
<37846227+czoon@users.noreply.github.com>
Date: Sun, 5 Jul 2020 22:55:10 +0200
Subject: [PATCH 10/11] Fixed bug when Alt+Tab still shows app when minimized.
---
QuietOnTheSetUI/Form1.cs | 45 ++++++++++++++++++++++++++++++----------
1 file changed, 34 insertions(+), 11 deletions(-)
diff --git a/QuietOnTheSetUI/Form1.cs b/QuietOnTheSetUI/Form1.cs
index b15a8a9..2142a60 100644
--- a/QuietOnTheSetUI/Form1.cs
+++ b/QuietOnTheSetUI/Form1.cs
@@ -23,6 +23,29 @@ public partial class Form1 : Form
private int _maxVolume;
private bool _exitAllowed = false;
+ // Removes the app from Alt+Tab window if minimized
+ protected override CreateParams CreateParams
+ {
+ get
+ {
+ var Params = base.CreateParams;
+ if (FormWindowState.Minimized == this.WindowState)
+ {
+ Params.ExStyle |= 0x80;
+ }
+ return Params;
+ }
+ }
+
+ protected override void OnShown(EventArgs e)
+ {
+ if (FormWindowState.Minimized == this.WindowState)
+ {
+ base.OnShown(e);
+ Hide();
+ }
+ }
+
public Form1()
{
InitializeComponent();
@@ -32,15 +55,6 @@ public Form1()
{
checkBox1.Checked = Convert.ToBoolean(Properties.Settings.Default["StartAutomatically"]);
checkBox2.Checked = Convert.ToBoolean(Properties.Settings.Default["StartMinimized"]);
- if (checkBox2.Checked)
- {
- // Hides the app completely
- Form1_FormClosing(null, new FormClosingEventArgs(new CloseReason(), true));
-
- // The volume is automatically locked if the app is minimized
- Properties.Settings.Default["IsLocked"] = true;
- Properties.Settings.Default.Save();
- }
}
catch (Exception)
{
@@ -48,6 +62,16 @@ public Form1()
checkBox2.Checked = false;
}
+ if (checkBox2.Checked)
+ {
+ // Hides the app completely
+ Form1_FormClosing(null, new FormClosingEventArgs(new CloseReason(), true));
+
+ // The volume is automatically locked if the app is minimized
+ Properties.Settings.Default["IsLocked"] = true;
+ Properties.Settings.Default.Save();
+ }
+
this.Icon = QuietOnTheSetUI.Properties.Resources.appicon;
mmDevice = MMDE.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
notifyIcon1.Icon = QuietOnTheSetUI.Properties.Resources.appicon;
@@ -86,14 +110,13 @@ private void Form1_Resize(object sender, EventArgs e)
{
if (FormWindowState.Minimized == this.WindowState)
{
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; // Hide QOTS from alt+tab
notifyIcon1.Visible = true;
notifyIcon1.ShowBalloonTip(500);
this.Hide();
}
else if (FormWindowState.Normal == this.WindowState)
{
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ //this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
notifyIcon1.Visible = false;
}
}
From 244dae8626b8f5aec52ec6e44c4c45ba91069424 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rub=C3=A9n=20Corz=C3=B3n=20Villar?=
<37846227+czoon@users.noreply.github.com>
Date: Sun, 5 Jul 2020 23:38:54 +0200
Subject: [PATCH 11/11] Minor dialog type fix.
---
QuietOnTheSetUI/Form1.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/QuietOnTheSetUI/Form1.cs b/QuietOnTheSetUI/Form1.cs
index 2142a60..b6d50e9 100644
--- a/QuietOnTheSetUI/Form1.cs
+++ b/QuietOnTheSetUI/Form1.cs
@@ -116,7 +116,7 @@ private void Form1_Resize(object sender, EventArgs e)
}
else if (FormWindowState.Normal == this.WindowState)
{
- //this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
notifyIcon1.Visible = false;
}
}