From 75ab8597372cbc1ae8f4ddd481b1a4d9eb3c6eda Mon Sep 17 00:00:00 2001 From: dannoe Date: Mon, 6 Apr 2020 23:44:34 +0200 Subject: [PATCH] (Un)register windows at the global windows manager of keepass --- KeeTrayTOTP/FormAbout.Designer.cs | 1 + KeeTrayTOTP/FormAbout.cs | 8 ++++++++ KeeTrayTOTP/FormSettings.Designer.cs | 1 + KeeTrayTOTP/FormSettings.cs | 8 ++++++++ KeeTrayTOTP/FormTimeCorrection.Designer.cs | 1 + KeeTrayTOTP/FormTimeCorrection.cs | 8 ++++++++ KeeTrayTOTP/SetupTOTP.Designer.cs | 1 + KeeTrayTOTP/SetupTOTP.cs | 8 ++++++++ KeeTrayTOTP/ShowQR.Designer.cs | 1 + KeeTrayTOTP/ShowQR.cs | 8 ++++++++ 10 files changed, 45 insertions(+) diff --git a/KeeTrayTOTP/FormAbout.Designer.cs b/KeeTrayTOTP/FormAbout.Designer.cs index c5a06b4..4b77c74 100644 --- a/KeeTrayTOTP/FormAbout.Designer.cs +++ b/KeeTrayTOTP/FormAbout.Designer.cs @@ -147,6 +147,7 @@ private void InitializeComponent() this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "_about form_"; + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FormAbout_FormClosed); this.Load += new System.EventHandler(this.FormAbout_Load); ((System.ComponentModel.ISupportInitialize)(this.PictureBoxAbout)).EndInit(); this.ResumeLayout(false); diff --git a/KeeTrayTOTP/FormAbout.cs b/KeeTrayTOTP/FormAbout.cs index ca0c32b..98bd371 100644 --- a/KeeTrayTOTP/FormAbout.cs +++ b/KeeTrayTOTP/FormAbout.cs @@ -1,6 +1,7 @@ using System; using System.Reflection; using System.Windows.Forms; +using KeePass.UI; namespace KeeTrayTOTP { @@ -32,6 +33,8 @@ internal FormAbout(KeeTrayTOTPExt plugin) /// private void FormAbout_Load(object sender, EventArgs e) { + GlobalWindowManager.AddWindow(this); + Text = Localization.Strings.About + @" - " + Localization.Strings.TrayTOTPPlugin; ListViewAbout.Items[0].SubItems.Add(AssemblyTitle); ListViewAbout.Items[1].SubItems.Add(AssemblyCompany); @@ -151,5 +154,10 @@ internal string AssemblyCompany return ((AssemblyCompanyAttribute)attributes[0]).Company; } } + + private void FormAbout_FormClosed(object sender, FormClosedEventArgs e) + { + GlobalWindowManager.RemoveWindow(this); + } } } \ No newline at end of file diff --git a/KeeTrayTOTP/FormSettings.Designer.cs b/KeeTrayTOTP/FormSettings.Designer.cs index b7806b7..3fd821f 100644 --- a/KeeTrayTOTP/FormSettings.Designer.cs +++ b/KeeTrayTOTP/FormSettings.Designer.cs @@ -787,6 +787,7 @@ private void InitializeComponent() this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "_seetings form_"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormSettings_FormClosing); + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FormSettings_FormClosed); this.Load += new System.EventHandler(this.FormSettings_Load); this.TabControlSettings.ResumeLayout(false); this.TabPageContextMenus.ResumeLayout(false); diff --git a/KeeTrayTOTP/FormSettings.cs b/KeeTrayTOTP/FormSettings.cs index cc6b6bf..c8d15b8 100644 --- a/KeeTrayTOTP/FormSettings.cs +++ b/KeeTrayTOTP/FormSettings.cs @@ -1,6 +1,7 @@ using System; using System.ComponentModel; using System.Windows.Forms; +using KeePass.UI; namespace KeeTrayTOTP { @@ -43,6 +44,8 @@ internal FormSettings(KeeTrayTOTPExt plugin) /// private void FormSettings_Load(object sender, EventArgs e) { + GlobalWindowManager.AddWindow(this); + Text = Localization.Strings.Settings + @" - " + Localization.Strings.TrayTOTPPlugin; // Set form's name using constants. Working(true, true); // Set controls depending on the state of action. WorkerLoad.RunWorkerAsync(); // Load Settings in form controls. @@ -479,5 +482,10 @@ private void WorkerReset_RunWorkerCompleted(object sender, RunWorkerCompletedEve { WorkerLoad.RunWorkerAsync("Reset"); } + + private void FormSettings_FormClosed(object sender, FormClosedEventArgs e) + { + GlobalWindowManager.RemoveWindow(this); + } } } diff --git a/KeeTrayTOTP/FormTimeCorrection.Designer.cs b/KeeTrayTOTP/FormTimeCorrection.Designer.cs index e3181f3..ec622c8 100644 --- a/KeeTrayTOTP/FormTimeCorrection.Designer.cs +++ b/KeeTrayTOTP/FormTimeCorrection.Designer.cs @@ -229,6 +229,7 @@ private void InitializeComponent() this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "_time correction_"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormTimeCorrection_FormClosing); + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FormTimeCorrection_FormClosed); this.Load += new System.EventHandler(this.FormTimeCorrection_Load); ((System.ComponentModel.ISupportInitialize)(this.PictureBoxTimeCorrection)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.PictureBoxAbout)).EndInit(); diff --git a/KeeTrayTOTP/FormTimeCorrection.cs b/KeeTrayTOTP/FormTimeCorrection.cs index 350b6d9..a2bc0d4 100644 --- a/KeeTrayTOTP/FormTimeCorrection.cs +++ b/KeeTrayTOTP/FormTimeCorrection.cs @@ -1,6 +1,7 @@ using System; using System.ComponentModel; using System.Windows.Forms; +using KeePass.UI; using KeeTrayTOTP.Libraries; namespace KeeTrayTOTP @@ -48,6 +49,8 @@ internal FormTimeCorrection(KeeTrayTOTPExt plugin, string url) /// private void FormTimeCorrection_Load(object sender, EventArgs e) { + GlobalWindowManager.AddWindow(this); + Text = Localization.Strings.TimeCorrection + @" - " + Localization.Strings.TrayTOTPPlugin; //Sets the form's display text. if (_plugin.PluginHost.MainWindow.ActiveDatabase.IsOpen) { @@ -200,5 +203,10 @@ private void ButtonCancel_Click(object sender, EventArgs e) { //Dialog Result = Cancel } + + private void FormTimeCorrection_FormClosed(object sender, FormClosedEventArgs e) + { + GlobalWindowManager.RemoveWindow(this); + } } } diff --git a/KeeTrayTOTP/SetupTOTP.Designer.cs b/KeeTrayTOTP/SetupTOTP.Designer.cs index 5cd8644..7bef2a1 100644 --- a/KeeTrayTOTP/SetupTOTP.Designer.cs +++ b/KeeTrayTOTP/SetupTOTP.Designer.cs @@ -418,6 +418,7 @@ private void InitializeComponent() this.Name = "SetupTOTP"; this.ShowInTaskbar = false; this.Text = "SetupTOTP"; + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.SetupTOTP_FormClosed); this.Load += new System.EventHandler(this.SetupTOTP_Load); ((System.ComponentModel.ISupportInitialize)(this.PictureBoxAbout)).EndInit(); this.InfoPanel.ResumeLayout(false); diff --git a/KeeTrayTOTP/SetupTOTP.cs b/KeeTrayTOTP/SetupTOTP.cs index b351872..6985a54 100644 --- a/KeeTrayTOTP/SetupTOTP.cs +++ b/KeeTrayTOTP/SetupTOTP.cs @@ -1,5 +1,6 @@ using System; using System.Windows.Forms; +using KeePass.UI; using KeePassLib; using KeePassLib.Security; @@ -31,6 +32,8 @@ internal SetupTOTP(KeeTrayTOTPExt plugin, PwEntry entry) private void SetupTOTP_Load(object sender, EventArgs e) { + GlobalWindowManager.AddWindow(this); + Text = Localization.Strings.Setup + @" - " + Localization.Strings.TrayTOTPPlugin; //Set form's name using constants. if (_plugin.SettingsCheck(_entry) || _plugin.SeedCheck(_entry)) //Checks the the totp settings exists. @@ -229,5 +232,10 @@ private void ButtonDelete_Click(object sender, EventArgs e) Close(); } } + + private void SetupTOTP_FormClosed(object sender, FormClosedEventArgs e) + { + GlobalWindowManager.RemoveWindow(this); + } } } diff --git a/KeeTrayTOTP/ShowQR.Designer.cs b/KeeTrayTOTP/ShowQR.Designer.cs index 0df8b26..a22afd3 100644 --- a/KeeTrayTOTP/ShowQR.Designer.cs +++ b/KeeTrayTOTP/ShowQR.Designer.cs @@ -129,6 +129,7 @@ private void InitializeComponent() this.Name = "ShowQR"; this.ShowInTaskbar = false; this.Text = "ShowQR"; + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.ShowQR_FormClosed); this.Load += new System.EventHandler(this.ShowQR_Load); ((System.ComponentModel.ISupportInitialize)(this.QROutputPicture)).EndInit(); this.ResumeLayout(false); diff --git a/KeeTrayTOTP/ShowQR.cs b/KeeTrayTOTP/ShowQR.cs index a750438..7918ae9 100644 --- a/KeeTrayTOTP/ShowQR.cs +++ b/KeeTrayTOTP/ShowQR.cs @@ -1,5 +1,6 @@ using System; using System.Windows.Forms; +using KeePass.UI; using QRCoder; namespace KeeTrayTOTP @@ -15,6 +16,8 @@ public ShowQR() private void ShowQR_Load(object sender, EventArgs e) { + GlobalWindowManager.AddWindow(this); + GenerateQRCode(); } @@ -48,5 +51,10 @@ protected override bool ProcessDialogKey(Keys keyData) return base.ProcessDialogKey(keyData); } + + private void ShowQR_FormClosed(object sender, FormClosedEventArgs e) + { + GlobalWindowManager.RemoveWindow(this); + } } }