Skip to content

Commit

Permalink
Normalize event handler args to sender, e
Browse files Browse the repository at this point in the history
  • Loading branch information
dlech committed Jun 3, 2018
1 parent ba93c9d commit 9a47555
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 55 deletions.
2 changes: 1 addition & 1 deletion KeeAgent/KeeAgentColumnProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ internal void Agent_KeyAddedOrRemoved(object sender, SshKeyEventArgs e)
UpdateUI();
}

private void Agent_Locked(object aSender, Agent.LockEventArgs aEventArgs)
private void Agent_Locked(object sender, Agent.LockEventArgs e)
{
UpdateUI();
}
Expand Down
54 changes: 22 additions & 32 deletions KeeAgent/KeeAgentExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ private void RemoveMenuItems()
}
}

private void manageKeeAgentMenuItem_Click(object aSource, EventArgs aEvent)
private void manageKeeAgentMenuItem_Click(object sender, EventArgs e)
{
ShowManageDialog();
}
Expand Down Expand Up @@ -653,21 +653,19 @@ private void LoadOptions()
/// Kudos to the luckyrat for figuring out how to to this in KeePassRPC
/// (KeeFox) and open-sourcing the code so I could copy/learn from it.
///</remarks>
private void WindowAddedHandler(object aSender,
GwmWindowEventArgs aEventArgs)
private void WindowAddedHandler(object sender, GwmWindowEventArgs e)
{
/* Add KeeAgent tab to PwEntryForm dialog */
var pwEntryForm = aEventArgs.Form as PwEntryForm;
var pwEntryForm = e.Form as PwEntryForm;
if (pwEntryForm != null) {
var optionsPanel = new EntryPanel(this);
pwEntryForm.Shown +=
delegate(object sender, EventArgs args)
pwEntryForm.Shown += (s, e2) =>
{
pwEntryForm.AddTab(optionsPanel);
};
var foundControls = pwEntryForm.Controls.Find("m_btnOK", true);
var okButton = foundControls[0] as Button;
okButton.GotFocus += (sender, args) =>
okButton.GotFocus += (s, e2) =>
{
if (optionsPanel.CurrentSettings != optionsPanel.IntialSettings) {
pwEntryForm.EntryBinaries.SetKeeAgentSettings(optionsPanel.CurrentSettings);
Expand All @@ -678,10 +676,9 @@ private void WindowAddedHandler(object aSender,
}

/* Add KeeAgent tab to Database Settings dialog */
var databaseSettingForm = aEventArgs.Form as DatabaseSettingsForm;
var databaseSettingForm = e.Form as DatabaseSettingsForm;
if (databaseSettingForm != null) {
databaseSettingForm.Shown +=
delegate(object sender, EventArgs args)
databaseSettingForm.Shown += (s, e2) =>
{
var dbSettingsPanel =
new DatabaseSettingsPanel(pluginHost.MainWindow.ActiveDatabase);
Expand All @@ -690,10 +687,9 @@ private void WindowAddedHandler(object aSender,
}

/* Add KeeAgent tab to Options dialog */
var optionsForm = aEventArgs.Form as OptionsForm;
var optionsForm = e.Form as OptionsForm;
if (optionsForm != null) {
optionsForm.Shown +=
delegate(object sender, EventArgs args)
optionsForm.Shown += (s, e2) =>
{
var optionsPanel = new OptionsPanel(this);
optionsForm.AddTab(optionsPanel);
Expand All @@ -702,12 +698,11 @@ private void WindowAddedHandler(object aSender,
}
}

private void PwEntryForm_EntrySaving(object aSender,
CancellableOperationEventArgs aEventArgs)
private void PwEntryForm_EntrySaving(object sender, CancellableOperationEventArgs e)
{
/* Get reference to new settings */

var entryForm = aSender as PwEntryForm;
var entryForm = sender as PwEntryForm;
if (entryForm != null && (entryForm.DialogResult == DialogResult.OK ||
saveBeforeCloseQuestionMessageShown)) {
var foundControls = entryForm.Controls.Find("EntryPanel", true);
Expand Down Expand Up @@ -764,23 +759,21 @@ private void PwEntryForm_EntrySaving(object aSender,
}
}
MessageService.ShowWarning(errorMessage);
aEventArgs.Cancel = true;
e.Cancel = true;
}
}
}
saveBeforeCloseQuestionMessageShown = false;
}

private void PwEntryForm_FormClosing(object aSender,
FormClosingEventArgs aEventArgs)
private void PwEntryForm_FormClosing(object sender, FormClosingEventArgs e)
{
saveBeforeCloseQuestionMessageShown = false;
}

private void OptionsForm_FormClosed(object aSender,
FormClosedEventArgs aEventArgs)
private void OptionsForm_FormClosed(object sender, FormClosedEventArgs e)
{
var optionsForm = aSender as OptionsForm;
var optionsForm = sender as OptionsForm;
if (optionsForm != null && optionsForm.DialogResult == DialogResult.OK) {
SaveGlobalOptions();
}
Expand All @@ -796,11 +789,11 @@ internal void Log(string aMessage)
}
}

private void PageantAgent_Locked(object aSender, Agent.LockEventArgs aEventArgs)
private void PageantAgent_Locked(object sender, Agent.LockEventArgs e)
{
if (Options.ShowBalloon) {
string notifyText;
if (aEventArgs.IsLocked) {
if (e.IsLocked) {
notifyText = Translatable.NotifyLocked;
} else {
notifyText = Translatable.NotifyUnlocked;
Expand All @@ -825,8 +818,7 @@ private void PageantAgent_KeyRemoved(object sender, SshKeyEventArgs e)
RemoveKey(e.Key);
}

private void PageantAgent_MessageReceived(object aSender,
Agent.MessageReceivedEventArgs aEventArgs)
private void PageantAgent_MessageReceived(object sender, Agent.MessageReceivedEventArgs e)
{
var mainWindow = pluginHost.MainWindow;

Expand Down Expand Up @@ -953,8 +945,7 @@ private void MainForm_FileClosing(object sender, FileClosingEventArgs e)
}
}

private void MainForm_FileClosed(object aSender,
FileClosedEventArgs aEventArgs)
private void MainForm_FileClosed(object sender, FileClosedEventArgs e)
{
try {
foreach (var key in removeKeyList) {
Expand All @@ -967,11 +958,10 @@ private void MainForm_FileClosed(object aSender,
}
}

private void MessageService_MessageShowing(object aSender,
MessageServiceEventArgs aEventArgs)
private void MessageService_MessageShowing(object sender, MessageServiceEventArgs e)
{
if (aEventArgs.Title == PwDefs.ShortProductName &&
aEventArgs.Text == KPRes.SaveBeforeCloseQuestion) {
if (e.Title == PwDefs.ShortProductName &&
e.Text == KPRes.SaveBeforeCloseQuestion) {
saveBeforeCloseQuestionMessageShown = true;
}
}
Expand Down
3 changes: 1 addition & 2 deletions KeeAgent/UI/DatabaseSettingsPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (ParentForm != null) {
ParentForm.FormClosing +=
delegate(object aSender, FormClosingEventArgs aEventArgs)
ParentForm.FormClosing += (s, e2) =>
{
if (ParentForm.DialogResult == DialogResult.OK) {
var settings = mDatabaseSettingsBindingSource.DataSource as DatabaseSettings;
Expand Down
3 changes: 1 addition & 2 deletions KeeAgent/UI/GroupBoxEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ protected override void OnControlAdded(ControlEventArgs e)
base.OnControlAdded(e);
var radioButton = e.Control as RadioButton;
if (radioButton != null) {
radioButton.CheckedChanged +=
delegate(object aSender, EventArgs aEventArgs)
radioButton.CheckedChanged += (s, e2) =>
{
if (radioButton.Checked) {
SelectedRadioButton = radioButton.Name;
Expand Down
30 changes: 13 additions & 17 deletions KeeAgent/UI/KeyLocationPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,27 @@ public KeyLocationPanel()
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
BackColor = Color.Transparent;

locationGroupBox.DataBindings["SelectedRadioButton"].Format +=
delegate (object aSender, ConvertEventArgs aEventArgs) {
if (aEventArgs.DesiredType == typeof(string)) {
var type = aEventArgs.Value as EntrySettings.LocationType?;
locationGroupBox.DataBindings["SelectedRadioButton"].Format += (s, e) =>
{
if (e.DesiredType == typeof(string)) {
var type = e.Value as EntrySettings.LocationType?;
switch (type) {
case EntrySettings.LocationType.Attachment:
aEventArgs.Value = attachmentRadioButton.Name;
e.Value = attachmentRadioButton.Name;
break;
case EntrySettings.LocationType.File:
aEventArgs.Value = fileRadioButton.Name;
e.Value = fileRadioButton.Name;
break;
default:
aEventArgs.Value = string.Empty;
e.Value = string.Empty;
break;
}
} else {
Debug.Fail("unexpected");
}
};
locationGroupBox.DataBindings["SelectedRadioButton"].Parse +=
delegate (object sender, ConvertEventArgs e) {
locationGroupBox.DataBindings["SelectedRadioButton"].Parse += (s, e) =>
{
if (e.DesiredType == typeof(EntrySettings.LocationType?) &&
e.Value is string) {
var valueString = e.Value as string;
Expand All @@ -109,14 +109,10 @@ public KeyLocationPanel()
};
// workaround for BindingSource.BindingComplete event not working in Mono
if (Type.GetType("Mono.Runtime") != null) {
locationGroupBox.SelectedRadioButtonChanged +=
(sender, e) => FireKeyLocationChanged();
attachmentComboBox.SelectionChangeCommitted +=
(sender, e) => FireKeyLocationChanged();
saveKeyToTempFileCheckBox.CheckedChanged +=
(sender, e) => FireKeyLocationChanged();
fileNameTextBox.TextChanged +=
(sender, e) => FireKeyLocationChanged();
locationGroupBox.SelectedRadioButtonChanged += (s, e) => FireKeyLocationChanged();
attachmentComboBox.SelectionChangeCommitted += (s, e) => FireKeyLocationChanged();
saveKeyToTempFileCheckBox.CheckedChanged += (s, e) => FireKeyLocationChanged();
fileNameTextBox.TextChanged += (s, e) => FireKeyLocationChanged();
}
}

Expand Down

0 comments on commit 9a47555

Please sign in to comment.