From 152937e0cfe425b9253093fa1e72a6a5f0bb980a Mon Sep 17 00:00:00 2001 From: rookiestyle Date: Sat, 11 May 2024 10:48:23 +0200 Subject: [PATCH] Internal optimizations Show text with new password expiry date only when neccessary --- src/PEDCalcExt.cs | 45 +++++++++++++++++++++++++--------- src/Properties/AssemblyInfo.cs | 6 ++--- version.info | 2 +- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/src/PEDCalcExt.cs b/src/PEDCalcExt.cs index 9c85230..9d5c1a5 100644 --- a/src/PEDCalcExt.cs +++ b/src/PEDCalcExt.cs @@ -424,8 +424,6 @@ private void OnFormShown(object sender, EventArgs e) dtExpireDate.ValueChanged += (o, e1) => CheckShowNewExpireDate(); SecureTextBoxEx password = (SecureTextBoxEx)Tools.GetControl("m_tbPassword", m_pweForm); password.TextChanged += (o, e1) => CheckShowNewExpireDate(); - Label lNewExpireDate = new Label(); - lNewExpireDate.Name = "PEDCalc_NewExpireDate"; string sDate = string.Empty; m_iSelectedEntries = (int)m_host.MainWindow.GetSelectedEntriesCount(); if ((Tools.KeePassVersion >= Configuration.KeePassMultipleEntries) && (m_iSelectedEntries > 1)) @@ -442,15 +440,7 @@ private void OnFormShown(object sender, EventArgs e) sDate = expiry.ToLongTimeString(); else sDate = expiry.ToString(dtExpireDate.CustomFormat); - lNewExpireDate.Text = PluginTranslate.PluginName + ": " + sDate; - lNewExpireDate.Left = dtExpireDate.Left; - lNewExpireDate.Top = dtExpireDate.Top + dtExpireDate.Height + 2; - lNewExpireDate.Width = dtExpireDate.Width; - lNewExpireDate.AutoSize = true; - ToolTip tt = new ToolTip(); - tt.ToolTipTitle = PluginTranslate.PluginName; - tt.ToolTipIcon = ToolTipIcon.Info; - tt.SetToolTip(lNewExpireDate, PluginTranslate.NewExpiryDateTooltip); + Label lNewExpireDate = GetNewExpireDateLabel(sDate, dtExpireDate); dtExpireDate.Parent.Controls.Add(lNewExpireDate); int h = dtExpireDate.Parent.ClientSize.Height; if (h < lNewExpireDate.Top + lNewExpireDate.Height + 2) @@ -484,11 +474,42 @@ private void OnFormShown(object sender, EventArgs e) } } + private Label GetNewExpireDateLabel() + { + return GetNewExpireDateLabel(false, null, null); + } + + private Label GetNewExpireDateLabel(string sText, Control cRefControl) + { + return GetNewExpireDateLabel(true, sText, cRefControl); + } + + private Label GetNewExpireDateLabel(bool bCreateIfNotExists, string sText, Control cRefControl) + { + Label lNewExpireDate = (Label)Tools.GetControl("PEDCalc_NewExpireDate", m_pweForm); + if (lNewExpireDate == null && !bCreateIfNotExists) return null; + if (lNewExpireDate != null) return lNewExpireDate; + lNewExpireDate = new Label(); + lNewExpireDate.Name = "PEDCalc_NewExpireDate"; + lNewExpireDate.Text = PluginTranslate.PluginName + ": " + sText; + lNewExpireDate.Left = cRefControl.Left; + lNewExpireDate.Top = cRefControl.Top + cRefControl.Height + 2; + lNewExpireDate.Width = cRefControl.Width; + lNewExpireDate.AutoSize = true; + + ToolTip tt = new ToolTip(); + tt.ToolTipTitle = PluginTranslate.PluginName; + tt.ToolTipIcon = ToolTipIcon.Info; + tt.SetToolTip(lNewExpireDate, PluginTranslate.NewExpiryDateTooltip); + + return lNewExpireDate; + } + private void CheckShowNewExpireDate() { if (m_pweForm == null) return; - Label lNewExpireDate = (Label)Tools.GetControl("PEDCalc_NewExpireDate", m_pweForm); + Label lNewExpireDate = GetNewExpireDateLabel(); if (lNewExpireDate == null) return; lNewExpireDate.Visible = false; diff --git a/src/Properties/AssemblyInfo.cs b/src/Properties/AssemblyInfo.cs index 7281863..cdf5961 100644 --- a/src/Properties/AssemblyInfo.cs +++ b/src/Properties/AssemblyInfo.cs @@ -12,7 +12,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("rookiestyle")] [assembly: AssemblyProduct("KeePass Plugin")] -[assembly: AssemblyCopyright("Copyright 2021-2023")] +[assembly: AssemblyCopyright("Copyright 2021-2024")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // This sets the default COM visibility of types in the assembly to invisible. @@ -24,7 +24,7 @@ // // 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("1.14.1")] -[assembly: AssemblyFileVersion("1.14.1")] +[assembly: AssemblyVersion("1.14.2")] +[assembly: AssemblyFileVersion("1.14.2")] [assembly: Guid("3abc1af7-d517-4129-bbfe-d647983d48db")] diff --git a/version.info b/version.info index 9ef8373..f96a8ce 100644 --- a/version.info +++ b/version.info @@ -1,5 +1,5 @@ : -PEDCalc - Password Expiry Calculator:1.14.1 +PEDCalc - Password Expiry Calculator:1.14.2 PEDCalc - Password Expiry Calculator!de:6 PEDCalc - Password Expiry Calculator!fr:3 PEDCalc - Password Expiry Calculator!pt:1