Skip to content

Commit

Permalink
Improve password change window
Browse files Browse the repository at this point in the history
Restore entry-specific sequence, if already defined and option "entry-specific" is selected
Small improvements in interaction with PEDCalc to recalculate the new password expiry date

Fixes #28
  • Loading branch information
Rookiestyle committed Jul 17, 2024
1 parent a5cce66 commit a6a73c5
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/PCADialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,9 @@ private void CheckPEDCalc()
}
object pedNewExpireDate;
DateTime dtNewExpireDate = pedcalc.GetNewExpiryDateUtc(pe, out pedNewExpireDate);
bool bOldExpires = EntryExpiry.Checked;
EntryExpiry.Value = dtNewExpireDate.ToLocalTime();
EntryExpiry.Checked = bOldExpires;
lMsg.Add("PEDCalc result: " + pedNewExpireDate.ToString());
lMsg.Add("New expiry date:" + dtNewExpireDate.ToLocalTime().ToString());
}
Expand Down Expand Up @@ -633,12 +635,15 @@ private void bSequenceEdit_Click(object sender, EventArgs e)
rtbSequence.Text = atc.DefaultSequence;
}

bool m_bEditingText = false;
private void rtbSequence_TextChanged(object sender, EventArgs e)
{
string sequence = rtbSequence.Text;
int i = m_Sequences.IndexOf(sequence);
if (i == -1) i = m_Sequences.Count - 1;
m_bEditingText = true;
cbSequences.SelectedIndex = Math.Min(i, cbSequences.Items.Count - 1);
m_bEditingText = false;
SprContext ctx = new SprContext();
ctx.EncodeAsAutoTypeSequence = true;

Expand All @@ -653,7 +658,15 @@ private void cbSequences_SelectedIndexChanged(object sender, EventArgs e)
if (Config.DefaultPCASequences.TryGetValue(cbSequences.Items[cbSequences.SelectedIndex] as string, out s)
&& !string.IsNullOrEmpty(s)
&& (s != rtbSequence.Text))
{
rtbSequence.Text = s;
return;
}
s = cbSequences.Items[cbSequences.SelectedIndex] as string;
if (!m_bEditingText && s == PluginTranslate.EntrySpecificSequence)
{
rtbSequence.Text = m_pcadata.PCASequence;
}
}

private void HideControl(string ControlName, Form f)
Expand Down
4 changes: 2 additions & 2 deletions src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
//
// 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("2.17")]
[assembly: AssemblyFileVersion("2.17")]
[assembly: AssemblyVersion("2.17.1")]
[assembly: AssemblyFileVersion("2.17.1")]
[assembly: Guid("5d5cc62b-d6f6-4e0b-a7ff-3d5ef21dd656")]
57 changes: 57 additions & 0 deletions src/Utilities/EventHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,37 @@ public static object DoInvoke(object sender, bool bUnwrapMonoWorkaround, List<De
return true;
}

public static List<Delegate> GetEventHandlersOfStaticClass(this Type t, string EventName)
{
List<Delegate> result = new List<Delegate>();

object obj = null;
List<FieldInfo> event_fields = GetTypeEventFields(t);
EventHandlerList static_event_handlers = null;

foreach (FieldInfo fi in event_fields)
{
if (!CheckEvent(fi, EventName)) continue;

EventInfo ei = t.GetEvent(fi.Name, AllBindings);
if (ei == null)
ei = t.GetEvent(EventName, AllBindings);
if (ei == null)
ei = fi.DeclaringType.GetEvent(fi.Name, AllBindings);
if (ei == null)
ei = fi.DeclaringType.GetEvent(EventName, AllBindings);
if (ei != null)
{
object val = fi.GetValue(obj);
Delegate mdel = (val as Delegate);
if (mdel != null)
result.AddRange(mdel.GetInvocationList());
}
}
return result;

}

public static List<Delegate> GetEventHandlers(this object obj, string EventName)
{
List<Delegate> result = new List<Delegate>();
Expand Down Expand Up @@ -80,6 +111,32 @@ public static List<Delegate> GetEventHandlers(this object obj, string EventName)
return result;
}

public static void RemoveEventHandlersOfStaticClass(this Type t, string EventName, List<Delegate> handlers)
{
if (handlers == null) return;

object obj = null;
List<FieldInfo> event_fields = GetTypeEventFields(t);

foreach (FieldInfo fi in event_fields)
{
if (!CheckEvent(fi, EventName)) continue;

EventInfo ei = t.GetEvent(fi.Name, AllBindings);
if (ei == null)
ei = t.GetEvent(EventName, AllBindings);
if (ei == null)
ei = fi.DeclaringType.GetEvent(fi.Name, AllBindings);
if (ei == null)
ei = fi.DeclaringType.GetEvent(EventName, AllBindings);
if (ei != null)
{
foreach (Delegate del in handlers)
ei.RemoveEventHandler(obj, del);
}
}
}

public static void RemoveEventHandlers(this object obj, string EventName, List<Delegate> handlers)
{
if (obj == null) return;
Expand Down
2 changes: 1 addition & 1 deletion version.info
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
:
PasswordChangeAssistant:2.17
PasswordChangeAssistant:2.17.1
PasswordChangeAssistant!de:11
PasswordChangeAssistant!it:3
PasswordChangeAssistant!pt:9
Expand Down

0 comments on commit a6a73c5

Please sign in to comment.