From dcd5b74472f857b3738171decdfacc11cd7a82c0 Mon Sep 17 00:00:00 2001 From: Aziz Rafsanjani Date: Sun, 25 Jun 2017 18:07:48 +0000 Subject: [PATCH 1/2] If 'Close Minimizes' is unchecked then prompt user for confirmation when Main Form is closed --- DS4Windows/DS4Forms/DS4Form.cs | 27 + DS4Windows/DS4Forms/KBM360.en.resx | 1241 +++++++++++++++++++ DS4Windows/Properties/Resources.Designer.cs | 18 + DS4Windows/Properties/Resources.resx | 6 + 4 files changed, 1292 insertions(+) create mode 100644 DS4Windows/DS4Forms/KBM360.en.resx diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 1a50114..a0c42ec 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -2166,6 +2166,33 @@ namespace DS4Windows return; } + //in case user accidentally clicks on the close button whilst "Close Minimizes" checkbox is unchecked + if (!cBCloseMini.Checked && !contextclose) + { + DS4Device[] devices = Program.rootHub.DS4Controllers; + int controllerLen = devices.Length; + bool nocontrollers = true; + + for (Int32 i = 0, PadsLen = Pads.Length; nocontrollers && i < PadsLen; i++) + { + DS4Device d = devices[i]; + if (d != null) + { + nocontrollers = false; + } + } + + if (!nocontrollers) + { + if (MessageBox.Show(Properties.Resources.CloseConfirm, Properties.Resources.Confirm, + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + return; + } + } + } + if (cBCloseMini.Checked && !contextclose) { this.WindowState = FormWindowState.Minimized; diff --git a/DS4Windows/DS4Forms/KBM360.en.resx b/DS4Windows/DS4Forms/KBM360.en.resx new file mode 100644 index 0000000..af168f1 --- /dev/null +++ b/DS4Windows/DS4Forms/KBM360.en.resx @@ -0,0 +1,1241 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + 582, 165 + + + 24, 24 + + + 760, 44 + + + 97, 140 + + + 218, 25 + + + 27, 24 + + + 188, 25 + + + 27, 24 + + + 248, 25 + + + 27, 24 + + + 158, 25 + + + 27, 24 + + + 278, 25 + + + 27, 24 + + + 128, 25 + + + 27, 24 + + + 308, 25 + + + 27, 24 + + + 98, 25 + + + 27, 24 + + + 467, 55 + + + 33, 24 + + + 68, 25 + + + 27, 24 + + + 500, 55 + + + 33, 24 + + + 38, 55 + + + 24, 24 + + + 533, 55 + + + 33, 24 + + + 398, 55 + + + 51, 24 + + + 533, 85 + + + 33, 24 + + + 368, 55 + + + 24, 24 + + + 500, 85 + + + 33, 24 + + + 338, 55 + + + 24, 24 + + + 467, 85 + + + 33, 24 + + + 308, 55 + + + 24, 24 + + + 500, 25 + + + 33, 24 + + + 278, 55 + + + 24, 24 + + + 467, 25 + + + 33, 24 + + + 248, 55 + + + 24, 24 + + + 613, 26 + + + 24, 24 + + + 218, 55 + + + 24, 24 + + + 643, 26 + + + 24, 24 + + + 188, 55 + + + 24, 24 + + + 673, 26 + + + 24, 24 + + + 158, 55 + + + 24, 24 + + + 583, 26 + + + 24, 24 + + + 128, 55 + + + 24, 24 + + + 703, 26 + + + 40, 24 + + + 98, 55 + + + 24, 24 + + + 703, 55 + + + 40, 24 + + + 68, 55 + + + 24, 24 + + + 703, 85 + + + 40, 24 + + + 161, 175 + + + 138, 24 + + + 533, 25 + + + 33, 24 + + + 11, 145 + + + 66, 24 + + + 413, 25 + + + 33, 24 + + + 383, 145 + + + 66, 24 + + + 338, 25 + + + 33, 24 + + + 353, 145 + + + 24, 24 + + + 374, 25 + + + 33, 24 + + + 323, 145 + + + 24, 24 + + + 11, 55 + + + 24, 24 + + + 293, 145 + + + 24, 24 + + + 263, 145 + + + 24, 24 + + + 583, 55 + + + 24, 24 + + + 233, 145 + + + 24, 24 + + + 583, 85 + + + 24, 24 + + + 203, 145 + + + 24, 24 + + + 613, 55 + + + 24, 24 + + + 173, 145 + + + 24, 24 + + + 613, 85 + + + 24, 24 + + + 143, 145 + + + 24, 24 + + + 643, 55 + + + 24, 24 + + + 113, 145 + + + 24, 24 + + + 643, 85 + + + 24, 24 + + + 83, 145 + + + 24, 24 + + + 673, 55 + + + 24, 24 + + + 353, 175 + + + 39, 24 + + + 673, 85 + + + 24, 54 + + + 305, 175 + + + 42, 24 + + + 673, 145 + + + 24, 54 + + + 113, 175 + + + 42, 24 + + + 583, 115 + + + 24, 24 + + + 68, 175 + + + 39, 24 + + + 613, 115 + + + 24, 24 + + + 398, 175 + + + 50, 24 + + + 583, 145 + + + 24, 24 + + + 11, 175 + + + 51, 24 + + + 643, 115 + + + 24, 24 + + + 11, 115 + + + 51, 24 + + + 583, 175 + + + 54, 24 + + + 398, 115 + + + 51, 24 + + + 613, 145 + + + 24, 24 + + + 368, 115 + + + 24, 24 + + + 643, 145 + + + 24, 24 + + + 16, 212 + + + 61, 28 + + + 17, 23 + + + 43, 13 + + + 17, 47 + + + 38, 13 + + + 17, 74 + + + 30, 13 + + + 85, 45 + + + 49, 20 + + + 85, 72 + + + 49, 20 + + + 218, 115 + + + 24, 24 + + + 83, 210 + + + 42, 20 + + + 34, 179 + + + 100, 20 + + + 308, 115 + + + 24, 24 + + + 278, 115 + + + 24, 24 + + + 248, 115 + + + 24, 24 + + + 533, 176 + + + 33, 24 + + + 33, 153 + + + 100, 20 + + + 33, 127 + + + 100, 20 + + + 17, 182 + + + 14, 13 + + + 17, 156 + + + 15, 13 + + + 338, 115 + + + 24, 24 + + + 500, 146 + + + 33, 24 + + + 85, 18 + + + 68, 23 + + + 17, 130 + + + 15, 13 + + + 467, 176 + + + 33, 24 + + + 114, 288 + + + 49, 20 + + + 500, 176 + + + 33, 24 + + + 144, 209 + + + 13, 13 + + + 643, 175 + + + 24, 24 + + + 188, 115 + + + 24, 24 + + + 663, 8 + + + 79, 17 + + + 158, 115 + + + 24, 24 + + + 0, 326 + + + 167, 60 + + + 128, 115 + + + 24, 24 + + + 452, 106 + + + 38, 33 + + + 98, 115 + + + 24, 24 + + + 309, 81 + + + 50, 30 + + + 68, 115 + + + 24, 24 + + + 370, 80 + + + 30, 30 + + + 11, 85 + + + 36, 24 + + + 266, 80 + + + 30, 30 + + + 413, 85 + + + 36, 24 + + + 497, 78 + + + 30, 30 + + + 383, 85 + + + 24, 24 + + + 420, 78 + + + 32, 34 + + + 353, 85 + + + 24, 24 + + + 455, 46 + + + 38, 35 + + + 323, 85 + + + 24, 24 + + + 14, 50 + + + 79, 29 + + + 293, 85 + + + 24, 24 + + + 278, 155 + + + 30, 30 + + + 263, 85 + + + 24, 24 + + + 251, 138 + + + 27, 21 + + + 233, 85 + + + 24, 24 + + + 254, 178 + + + 26, 21 + + + 203, 85 + + + 24, 24 + + + 224, 153 + + + 26, 30 + + + 173, 85 + + + 24, 24 + + + 60, 10 + + + 30, 42 + + + 143, 85 + + + 24, 24 + + + 294, 1 + + + 73, 13 + + + 826, 85 + + + 24, 24 + + + 461, 9 + + + 108, 13 + + + 113, 85 + + + 24, 24 + + + 10, 9 + + + 322, 13 + + + 796, 110 + + + 24, 21 + + + 749, 4 + + + 118, 23 + + + 796, 62 + + + 24, 22 + + + 371, 166 + + + 15, 30 + + + 796, 85 + + + 24, 24 + + + 384, 189 + + + 29, 14 + + + 83, 85 + + + 24, 24 + + + 414, 166 + + + 14, 30 + + + 831, 150 + + + 19, 24 + + + 563, 55 + + + 90, 30 + + + 766, 150 + + + 19, 24 + + + 163, 94 + + + 13, 30 + + + 843, 120 + + + 24, 24 + + + 384, 155 + + + 30, 13 + + + 745, 121 + + + 24, 24 + + + 178, 124 + + + 30, 11 + + + 796, 170 + + + 24, 24 + + + 574, 12 + + + 40, 44 + + + 796, 28 + + + 24, 24 + + + 212, 95 + + + 10, 30 + + + 766, 85 + + + 24, 24 + + + 385, 170 + + + 26, 19 + + + 53, 85 + + + 24, 24 + + + 178, 83 + + + 30, 11 + + + 182, 99 + + + 22, 22 + + + 598, 8 + + + 59, 17 + + + 22, 330 + + + 160, 23 + + + 22, 365 + + + 160, 23 + + + 11, 25 + + + 51, 24 + + + 6, 245 + + + 158, 37 + + + 2, 107 + + + 89, 17 + + + 138, 182 + + + 25, 13 + + + 138, 154 + + + 25, 13 + + + 138, 129 + + + 25, 13 + + + 871, 0 + + + 167, 446 + + + 22, 209 + + + + 2, 2, 2, 2 + + + 62, 17 + + + 94, 209 + + + 2, 2, 2, 2 + + + 86, 17 + + + 22, 236 + + + 161, 21 + + + 467, 24 + + + 14, 13 + + + 203, 202 + + + 2, 2, 2, 2 + + + 668, 247 + + + 96, 96 + + + 1038, 446 + + \ No newline at end of file diff --git a/DS4Windows/Properties/Resources.Designer.cs b/DS4Windows/Properties/Resources.Designer.cs index a277b7e..ab0c994 100644 --- a/DS4Windows/Properties/Resources.Designer.cs +++ b/DS4Windows/Properties/Resources.Designer.cs @@ -274,6 +274,15 @@ namespace DS4Windows.Properties { } } + /// + /// Looks up a localized string similar to This will disconnect all your connected controllers. Proceed?. + /// + internal static string CloseConfirm { + get { + return ResourceManager.GetString("CloseConfirm", resourceCulture); + } + } + /// /// Looks up a localized string similar to Close DS4Windows?. /// @@ -310,6 +319,15 @@ namespace DS4Windows.Properties { } } + /// + /// Looks up a localized string similar to Confirm.... + /// + internal static string Confirm { + get { + return ResourceManager.GetString("Confirm", resourceCulture); + } + } + /// /// Looks up a localized string similar to Connecting.... /// diff --git a/DS4Windows/Properties/Resources.resx b/DS4Windows/Properties/Resources.resx index 9df65d2..a3cb93f 100644 --- a/DS4Windows/Properties/Resources.resx +++ b/DS4Windows/Properties/Resources.resx @@ -787,4 +787,10 @@ Check to have gyro active while trigger is active. Uncheck to disable gyro while trigger is active. + + This will disconnect all your connected controllers. Proceed? + + + Confirm... + \ No newline at end of file From dbc33d1986ecc1e74b0a807212094b61b332e157 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Fri, 30 Jun 2017 06:46:54 -0700 Subject: [PATCH 2/2] Tweak routine for runtime --- DS4Windows/DS4Forms/DS4Form.cs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index e018768..5354b01 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -2157,6 +2157,7 @@ namespace DS4Windows linkSetup.LinkColor = Color.Blue; } + bool tempBool = false; protected void ScpForm_Closing(object sender, FormClosingEventArgs e) { if (opt.Visible) @@ -2166,22 +2167,19 @@ namespace DS4Windows return; } + bool closeMini = tempBool = cBCloseMini.Checked; + DS4Device d = null; + tempBool = true; //in case user accidentally clicks on the close button whilst "Close Minimizes" checkbox is unchecked - if (!cBCloseMini.Checked && !contextclose) + if (!closeMini && !contextclose) { - DS4Device[] devices = Program.rootHub.DS4Controllers; - int controllerLen = devices.Length; - bool nocontrollers = true; - - for (Int32 i = 0, PadsLen = Pads.Length; nocontrollers && i < PadsLen; i++) + for (int i = 0, PadsLen = Pads.Length; tempBool && i < PadsLen; i++) { - DS4Device d = devices[i]; - if (d != null) - { - nocontrollers = false; - } + d = Program.rootHub.DS4Controllers[i]; + tempBool = (d != null) ? false : tempBool; } + bool nocontrollers = tempBool; if (!nocontrollers) { if (MessageBox.Show(Properties.Resources.CloseConfirm, Properties.Resources.Confirm, @@ -2192,8 +2190,7 @@ namespace DS4Windows } } } - - if (cBCloseMini.Checked && !contextclose) + else if (closeMini && !contextclose) { this.WindowState = FormWindowState.Minimized; e.Cancel = true;