Skip to content

Commit

Permalink
Internal optimizations
Browse files Browse the repository at this point in the history
Show text with new password expiry date only when neccessary
  • Loading branch information
Rookiestyle committed May 11, 2024
1 parent 8c1c58c commit 152937e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 16 deletions.
45 changes: 33 additions & 12 deletions src/PEDCalcExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)
Expand Down Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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")]

2 changes: 1 addition & 1 deletion version.info
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 152937e

Please sign in to comment.