Simplify discards on gui event methods

This commit is contained in:
Kurt 2024-06-08 01:34:32 -05:00
parent 06b8ec03ae
commit 84d42807e0
31 changed files with 138 additions and 149 deletions

View file

@ -62,8 +62,8 @@ public partial class BoxEditor : UserControl, ISlotViewer<PictureBox>
BoxSlotCount = SlotPictureBoxes.Count;
foreach (var pb in SlotPictureBoxes)
{
pb.MouseEnter += (o, args) => BoxSlot_MouseEnter(pb, args);
pb.MouseLeave += (o, args) => BoxSlot_MouseLeave(pb, args);
pb.MouseEnter += (_, args) => BoxSlot_MouseEnter(pb, args);
pb.MouseLeave += (_, args) => BoxSlot_MouseLeave(pb, args);
pb.MouseClick += BoxSlot_MouseClick;
pb.MouseMove += BoxSlot_MouseMove;
pb.MouseDown += BoxSlot_MouseDown;
@ -72,7 +72,7 @@ public partial class BoxEditor : UserControl, ISlotViewer<PictureBox>
pb.DragEnter += BoxSlot_DragEnter;
pb.DragDrop += BoxSlot_DragDrop;
pb.QueryContinueDrag += BoxSlot_QueryContinueDrag;
pb.GiveFeedback += (sender, e) => e.UseDefaultCursors = false;
pb.GiveFeedback += (_, e) => e.UseDefaultCursors = false;
pb.AllowDrop = true;
}
}

View file

@ -35,7 +35,7 @@ public sealed class BoxMenuStrip : ContextMenuStrip
var name = item.Type.ToString();
ManipTypeImage.TryGetValue(item.Type, out var img);
var tsi = new ToolStripMenuItem { Name = $"mnu_{name}", Text = name, Image = img };
tsi.Click += (s, e) => Manipulator.Execute(item, sav.CurrentBox, All, Reverse);
tsi.Click += (_, _) => Manipulator.Execute(item, sav.CurrentBox, All, Reverse);
parent.DropDownItems.Add(tsi);
CustomItems.Add(new ItemVisibility(tsi, item));
}

View file

@ -38,8 +38,8 @@ public partial class PartyEditor : UserControl, ISlotViewer<PictureBox>
BoxSlotCount = SlotPictureBoxes.Count;
foreach (var pb in SlotPictureBoxes)
{
pb.MouseEnter += (o, args) => BoxSlot_MouseEnter(pb, args);
pb.MouseLeave += (o, args) => BoxSlot_MouseLeave(pb, args);
pb.MouseEnter += (_, args) => BoxSlot_MouseEnter(pb, args);
pb.MouseLeave += (_, args) => BoxSlot_MouseLeave(pb, args);
pb.MouseClick += BoxSlot_MouseClick;
pb.MouseMove += BoxSlot_MouseMove;
pb.MouseDown += BoxSlot_MouseDown;
@ -48,7 +48,7 @@ public partial class PartyEditor : UserControl, ISlotViewer<PictureBox>
pb.DragEnter += BoxSlot_DragEnter;
pb.DragDrop += BoxSlot_DragDrop;
pb.QueryContinueDrag += BoxSlot_QueryContinueDrag;
pb.GiveFeedback += (sender, e) => e.UseDefaultCursors = false;
pb.GiveFeedback += (_, e) => e.UseDefaultCursors = false;
pb.AllowDrop = true;
}
}

View file

@ -92,17 +92,17 @@ public partial class SAVEditor : UserControl, ISlotViewer<PictureBox>, ISaveFile
pb.ContextMenuStrip = menu.mnuVSD;
}
GiveFeedback += (sender, e) => e.UseDefaultCursors = false;
Tab_Box.MouseWheel += (s, e) =>
GiveFeedback += (_, e) => e.UseDefaultCursors = false;
Tab_Box.MouseWheel += (_, e) =>
{
if (menu.mnuVSD.Visible)
return;
Box.CurrentBox = e.Delta > 1 ? Box.Editor.MoveLeft() : Box.Editor.MoveRight();
};
GB_Daycare.Click += (o, args) => SwitchDaycare(GB_Daycare, args);
GB_Daycare.Click += (_, _) => SwitchDaycare();
FLP_SAVtools.Scroll += WinFormsUtil.PanelScroll;
SortMenu.Opening += (s, x) => x.Cancel = !tabBoxMulti.GetTabRect(tabBoxMulti.SelectedIndex).Contains(PointToClient(MousePosition));
SortMenu.Opening += (_, x) => x.Cancel = !tabBoxMulti.GetTabRect(tabBoxMulti.SelectedIndex).Contains(PointToClient(MousePosition));
}
private void InitializeDragDrop(Control pb)
@ -117,7 +117,7 @@ public partial class SAVEditor : UserControl, ISlotViewer<PictureBox>, ISaveFile
pb.DragEnter += M.DragEnter;
pb.DragDrop += M.DragDrop;
pb.QueryContinueDrag += M.QueryContinueDrag;
pb.GiveFeedback += (sender, e) => e.UseDefaultCursors = false;
pb.GiveFeedback += (_, e) => e.UseDefaultCursors = false;
pb.AllowDrop = true;
pb.ContextMenuStrip = menu.mnuVSD;
}
@ -572,7 +572,7 @@ public partial class SAVEditor : UserControl, ISlotViewer<PictureBox>, ISaveFile
private int DaycareIndex;
private void SwitchDaycare(object sender, EventArgs e)
private void SwitchDaycare()
{
if (SAV is not IDaycareMulti m)
return;

View file

@ -146,8 +146,8 @@ public partial class Main : Form
{
C_SAV.Menu_Redo = Menu_Redo;
C_SAV.Menu_Undo = Menu_Undo;
dragout.GiveFeedback += (sender, e) => e.UseDefaultCursors = false;
GiveFeedback += (sender, e) => e.UseDefaultCursors = false;
dragout.GiveFeedback += (_, e) => e.UseDefaultCursors = false;
GiveFeedback += (_, e) => e.UseDefaultCursors = false;
PKME_Tabs.EnableDragDrop(Main_DragEnter, Main_DragDrop);
C_SAV.EnableDragDrop(Main_DragEnter, Main_DragDrop);
@ -159,9 +159,9 @@ public partial class Main : Form
// Add ContextMenus
var mnu = new ContextMenuPKM();
mnu.RequestEditorLegality += (o, args) => ClickLegality(mnu, args);
mnu.RequestEditorQR += (o, args) => ClickQR(mnu, args);
mnu.RequestEditorSaveAs += (o, args) => MainMenuSave(mnu, args);
mnu.RequestEditorLegality += (_, args) => ClickLegality(mnu, args);
mnu.RequestEditorQR += (_, args) => ClickQR(mnu, args);
mnu.RequestEditorSaveAs += (_, args) => MainMenuSave(mnu, args);
dragout.ContextMenuStrip = mnu.mnuL;
C_SAV.menu.RequestEditorLegality = DisplayLegalityReport;
}

View file

@ -145,7 +145,7 @@ public partial class BatchEditor : Form
{
editor = new Core.BatchEditor();
bool finished = false, displayed = false; // hack cuz DoWork event isn't cleared after completion
b.DoWork += (sender, e) =>
b.DoWork += (_, _) =>
{
if (finished)
return;
@ -157,8 +157,8 @@ public partial class BatchEditor : Form
RunBatchEditFolder(sets, source, destination);
finished = true;
};
b.ProgressChanged += (sender, e) => SetProgressBar(e.ProgressPercentage);
b.RunWorkerCompleted += (sender, e) =>
b.ProgressChanged += (_, e) => SetProgressBar(e.ProgressPercentage);
b.RunWorkerCompleted += (_, _) =>
{
string result = editor.GetEditorResults(sets);
if (!displayed) WinFormsUtil.Alert(result);

View file

@ -157,7 +157,7 @@ public partial class RibbonEditor : Form
pb.BackgroundImage = img;
var display = RibbonStrings.GetName(name);
pb.MouseEnter += (s, e) => tipName.SetToolTip(pb, display);
pb.MouseEnter += (_, _) => tipName.SetToolTip(pb, display);
if (Entity is IRibbonSetAffixed)
pb.Click += (_, _) => CB_Affixed.Text = RibbonStrings.GetName(name);
FLP_Ribbons.Controls.Add(pb);
@ -201,7 +201,7 @@ public partial class RibbonEditor : Form
Maximum = rib.MaxCount,
};
nud.ValueChanged += (sender, e) =>
nud.ValueChanged += (_, _) =>
{
var controlName = PrefixPB + rib.Name;
var pb = FLP_Ribbons.Controls[controlName] ?? throw new ArgumentException($"{controlName} not found in {FLP_Ribbons.Name}.");
@ -215,7 +215,7 @@ public partial class RibbonEditor : Form
nud.Value = Math.Min(rib.MaxCount, rib.RibbonCount);
TLP_Ribbons.Controls.Add(nud, 0, row);
label.Click += (s, e) => nud.Value = (nud.Value == 0) ? nud.Maximum : 0;
label.Click += (_, _) => nud.Value = (nud.Value == 0) ? nud.Maximum : 0;
}
private void AddRibbonCheckBox(RibbonInfo rib, int row, Control label)
@ -228,7 +228,7 @@ public partial class RibbonEditor : Form
Padding = Padding.Empty,
Margin = Padding.Empty,
};
chk.CheckedChanged += (sender, e) =>
chk.CheckedChanged += (_, _) =>
{
rib.HasRibbon = chk.Checked;
var controlName = PrefixPB + rib.Name;
@ -243,7 +243,7 @@ public partial class RibbonEditor : Form
chk.Checked = rib.HasRibbon;
TLP_Ribbons.Controls.Add(chk, 0, row);
label.Click += (s, e) => chk.Checked ^= true;
label.Click += (_, _) => chk.Checked ^= true;
}
private void ToggleNewRibbon(RibbonInfo rib, Control pb)

View file

@ -107,7 +107,7 @@ public partial class TrashEditor : Form
var l = GetLabel($"${i:X2}");
l.Font = NUD_Generation.Font;
var n = GetNUD(min: 0, max: 255, hex: true);
n.Click += (s, e) =>
n.Click += (_, _) =>
{
switch (ModifierKeys)
{
@ -116,7 +116,7 @@ public partial class TrashEditor : Form
}
};
n.Value = Raw[i];
n.ValueChanged += (o, args) => UpdateNUD(n, args);
n.ValueChanged += (_, _) => UpdateNUD(n);
FLP_Hex.Controls.Add(l);
FLP_Hex.Controls.Add(n);
@ -124,7 +124,7 @@ public partial class TrashEditor : Form
if (i % 4 == 3)
FLP_Hex.SetFlowBreak(n, true);
}
TB_Text.TextChanged += (o, args) => UpdateString(TB_Text, args);
TB_Text.TextChanged += (_, _) => UpdateString(TB_Text);
CB_Species.InitializeBinding();
CB_Species.DataSource = new BindingSource(GameInfo.SpeciesDataSource, null);
@ -133,14 +133,13 @@ public partial class TrashEditor : Form
CB_Language.DataSource = GameInfo.LanguageDataSource(generation);
}
private void UpdateNUD(object sender, EventArgs e)
private void UpdateNUD(NumericUpDown nud)
{
if (editing)
return;
editing = true;
// build bytes
if (sender is not NumericUpDown nud)
throw new Exception();
editing = true;
int index = Bytes.IndexOf(nud);
Raw[index] = (byte)nud.Value;
@ -148,13 +147,13 @@ public partial class TrashEditor : Form
editing = false;
}
private void UpdateString(object sender, EventArgs e)
private void UpdateString(TextBox tb)
{
if (editing)
return;
editing = true;
// build bytes
ReadOnlySpan<byte> data = SetString(TB_Text.Text);
ReadOnlySpan<byte> data = SetString(tb.Text);
if (data.Length > Raw.Length)
data = data[..Raw.Length];
data.CopyTo(Raw);

View file

@ -25,7 +25,7 @@ public partial class ReportGrid : Form
private void GetContextMenu()
{
var mnuHide = new ToolStripMenuItem { Name = "mnuHide", Text = MsgReportColumnHide };
mnuHide.Click += (sender, e) =>
mnuHide.Click += (_, _) =>
{
int c = dgData.SelectedCells.Count;
if (c == 0)
@ -35,7 +35,7 @@ public partial class ReportGrid : Form
dgData.Columns[dgData.SelectedCells[i].ColumnIndex].Visible = false;
};
var mnuRestore = new ToolStripMenuItem { Name = "mnuRestore", Text = MsgReportColumnRestore };
mnuRestore.Click += (sender, e) =>
mnuRestore.Click += (_, _) =>
{
int c = dgData.ColumnCount;
for (int i = 0; i < c; i++)

View file

@ -24,6 +24,9 @@ public partial class SAV_Database : Form
private readonly PKMEditor PKME_Tabs;
private readonly EntityInstructionBuilder UC_Builder;
private const int GridWidth = 6;
private const int GridHeight = 11;
public SAV_Database(PKMEditor f1, SAVEditor saveditor)
{
InitializeComponent();
@ -48,7 +51,7 @@ public partial class SAV_Database : Form
var grid = DatabasePokeGrid;
var smallWidth = grid.Width;
var smallHeight = grid.Height;
grid.InitializeGrid(6, 11, SpriteUtil.Spriter);
grid.InitializeGrid(GridWidth, GridHeight, SpriteUtil.Spriter);
grid.SetBackground(Resources.box_wp_clean);
var newWidth = grid.Width;
var newHeight = grid.Height;
@ -64,30 +67,26 @@ public partial class SAV_Database : Form
foreach (var slot in PKXBOXES)
{
// Enable Click
slot.MouseClick += (sender, e) =>
slot.MouseClick += (_, e) =>
{
if (sender == null)
return;
switch (ModifierKeys)
{
case Keys.Control: ClickView(sender, e); break;
case Keys.Alt: ClickDelete(sender, e); break;
case Keys.Shift: ClickSet(sender, e); break;
case Keys.Control: ClickView(slot, e); break;
case Keys.Alt: ClickDelete(slot, e); break;
case Keys.Shift: ClickSet(slot, e); break;
}
};
slot.ContextMenuStrip = mnu;
if (Main.Settings.Hover.HoverSlotShowText)
{
slot.MouseMove += (o, args) => ShowSet.UpdatePreviewPosition(args.Location);
slot.MouseEnter += (o, args) => ShowHoverTextForSlot(slot, args);
slot.MouseLeave += (o, args) => ShowSet.Clear();
slot.MouseMove += (_, args) => ShowSet.UpdatePreviewPosition(args.Location);
slot.MouseEnter += (_, _) => ShowHoverTextForSlot(slot);
slot.MouseLeave += (_, _) => ShowSet.Clear();
}
slot.Enter += (sender, e) =>
slot.Enter += (_, _) =>
{
if (sender is not PictureBox pb)
return;
var index = Array.IndexOf(PKXBOXES, pb);
var index = Array.IndexOf(PKXBOXES, slot);
if (index < 0)
return;
index += (SCR_Box.Value * RES_MIN);
@ -95,7 +94,7 @@ public partial class SAV_Database : Form
return;
var pk = Results[index];
pb.AccessibleDescription = ShowdownParsing.GetLocalizedPreviewText(pk.Entity, Main.CurrentLanguage);
slot.AccessibleDescription = ShowdownParsing.GetLocalizedPreviewText(pk.Entity, Main.CurrentLanguage);
};
}
@ -119,14 +118,14 @@ public partial class SAV_Database : Form
});
task.Start();
Menu_SearchSettings.DropDown.Closing += (sender, e) =>
Menu_SearchSettings.DropDown.Closing += (_, e) =>
{
if (e.CloseReason == ToolStripDropDownCloseReason.ItemClicked)
e.Cancel = true;
};
CB_Format.Items[0] = MsgAny;
CenterToParent();
Closing += (sender, e) => ShowSet.Clear();
Closing += (_, _) => ShowSet.Clear();
}
private readonly PictureBox[] PKXBOXES;
@ -135,8 +134,8 @@ public partial class SAV_Database : Form
private List<SlotCache> RawDB = [];
private int slotSelected = -1; // = null;
private Image? slotColor;
private const int RES_MAX = 66;
private const int RES_MIN = 6;
private const int RES_MIN = GridWidth * 1;
private const int RES_MAX = GridWidth * GridHeight;
private readonly string Counter;
private readonly string Viewed;
private const int MAXFORMAT = PKX.Generation;
@ -237,9 +236,9 @@ public partial class SAV_Database : Form
L_Count.Text = string.Format(Counter, Results.Count);
slotSelected = Results.Count - 1;
slotColor = SpriteUtil.Spriter.Set;
if ((SCR_Box.Maximum + 1) * 6 < Results.Count)
if ((SCR_Box.Maximum + 1) * GridWidth < Results.Count)
SCR_Box.Maximum++;
SCR_Box.Value = Math.Max(0, SCR_Box.Maximum - (PKXBOXES.Length / 6) + 1);
SCR_Box.Value = Math.Max(0, SCR_Box.Maximum - (PKXBOXES.Length / GridWidth) + 1);
FillPKXBoxes(SCR_Box.Value);
WinFormsUtil.Alert(MsgDBAddFromTabsSuccess);
}
@ -768,9 +767,8 @@ public partial class SAV_Database : Form
private void L_Viewed_MouseEnter(object sender, EventArgs e) => hover.SetToolTip(L_Viewed, L_Viewed.Text);
private void ShowHoverTextForSlot(object sender, EventArgs e)
private void ShowHoverTextForSlot(PictureBox pb)
{
var pb = (PictureBox)sender;
int index = Array.IndexOf(PKXBOXES, pb);
if (!GetShiftedIndex(ref index))
return;

View file

@ -24,6 +24,9 @@ public partial class SAV_Encounters : Form
private readonly CancellationTokenSource TokenSource = new();
private readonly EntityInstructionBuilder UC_Builder;
private const int GridWidth = 6;
private const int GridHeight = 11;
public SAV_Encounters(PKMEditor f1, TrainerDatabase db)
{
InitializeComponent();
@ -44,7 +47,7 @@ public partial class SAV_Encounters : Form
var grid = EncounterPokeGrid;
var smallWidth = grid.Width;
var smallHeight = grid.Height;
grid.InitializeGrid(6, 11, SpriteUtil.Spriter);
grid.InitializeGrid(GridWidth, GridHeight, SpriteUtil.Spriter);
grid.SetBackground(Resources.box_wp_clean);
var newWidth = grid.Width;
var newHeight = grid.Height;
@ -61,18 +64,14 @@ public partial class SAV_Encounters : Form
foreach (var slot in PKXBOXES)
{
// Enable Click
slot.MouseClick += (sender, e) =>
slot.MouseClick += (_, e) =>
{
if (sender == null)
return;
if (ModifierKeys == Keys.Control)
ClickView(sender, e);
ClickView(slot, e);
};
slot.Enter += (sender, e) =>
slot.Enter += (_, _) =>
{
if (sender is not PictureBox pb)
return;
var index = Array.IndexOf(PKXBOXES, pb);
var index = Array.IndexOf(PKXBOXES, slot);
if (index < 0)
return;
index += (SCR_Box.Value * RES_MIN);
@ -80,16 +79,16 @@ public partial class SAV_Encounters : Form
return;
var enc = Results[index];
pb.AccessibleDescription = string.Join(Environment.NewLine, enc.GetTextLines());
slot.AccessibleDescription = string.Join(Environment.NewLine, enc.GetTextLines());
};
slot.ContextMenuStrip = mnu;
if (Main.Settings.Hover.HoverSlotShowText)
slot.MouseEnter += (o, args) => ShowHoverTextForSlot(slot, args);
slot.MouseEnter += (_, _) => ShowHoverTextForSlot(slot);
}
Counter = L_Count.Text;
L_Viewed.Text = string.Empty; // invisible for now
L_Viewed.MouseEnter += (sender, e) => hover.SetToolTip(L_Viewed, L_Viewed.Text);
L_Viewed.MouseEnter += (_, _) => hover.SetToolTip(L_Viewed, L_Viewed.Text);
PopulateComboBoxes();
WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
@ -130,8 +129,8 @@ public partial class SAV_Encounters : Form
private List<IEncounterInfo> Results = [];
private int slotSelected = -1; // = null;
private Image? slotColor;
private const int RES_MAX = 66;
private const int RES_MIN = 6;
private const int RES_MIN = GridWidth * 1;
private const int RES_MAX = GridWidth * GridHeight;
private readonly string Counter;
private bool GetShiftedIndex(ref int index)
@ -482,9 +481,8 @@ public partial class SAV_Encounters : Form
FillPKXBoxes(SCR_Box.Value = newval);
}
private void ShowHoverTextForSlot(object sender, EventArgs e)
private void ShowHoverTextForSlot(PictureBox pb)
{
var pb = (PictureBox)sender;
int index = Array.IndexOf(PKXBOXES, pb);
if (!GetShiftedIndex(ref index))
return;

View file

@ -22,6 +22,9 @@ public partial class SAV_MysteryGiftDB : Form
private readonly SummaryPreviewer ShowSet = new();
private readonly EntityInstructionBuilder UC_Builder;
private const int GridWidth = 6;
private const int GridHeight = 11;
public SAV_MysteryGiftDB(PKMEditor tabs, SAVEditor sav)
{
InitializeComponent();
@ -46,7 +49,7 @@ public partial class SAV_MysteryGiftDB : Form
var grid = MysteryPokeGrid;
var smallWidth = grid.Width;
var smallHeight = grid.Height;
grid.InitializeGrid(6, 11, SpriteUtil.Spriter);
grid.InitializeGrid(GridWidth, GridHeight, SpriteUtil.Spriter);
grid.SetBackground(Resources.box_wp_clean);
var newWidth = grid.Width;
var newHeight = grid.Height;
@ -63,19 +66,17 @@ public partial class SAV_MysteryGiftDB : Form
foreach (var slot in PKXBOXES)
{
// Enable Click
slot.MouseClick += (sender, e) =>
slot.MouseClick += (_, e) =>
{
if (ModifierKeys == Keys.Control)
ClickView(sender!, e);
ClickView(slot, e);
};
slot.ContextMenuStrip = mnu;
slot.MouseEnter += (o, args) => ShowHoverTextForSlot(slot, args);
slot.Enter += (sender, e) =>
slot.MouseEnter += (_, _) => ShowHoverTextForSlot(slot);
slot.Enter += (_, _) =>
{
if (sender is not PictureBox pb)
return;
var index = Array.IndexOf(PKXBOXES, pb);
var index = Array.IndexOf(PKXBOXES, slot);
if (index < 0)
return;
index += (SCR_Box.Value * RES_MIN);
@ -83,14 +84,14 @@ public partial class SAV_MysteryGiftDB : Form
return;
var enc = Results[index];
pb.AccessibleDescription = string.Join(Environment.NewLine, enc.GetTextLines());
slot.AccessibleDescription = string.Join(Environment.NewLine, enc.GetTextLines());
};
}
Counter = L_Count.Text;
Viewed = L_Viewed.Text;
L_Viewed.Text = string.Empty; // invis for now
L_Viewed.MouseEnter += (sender, e) => hover.SetToolTip(L_Viewed, L_Viewed.Text);
L_Viewed.MouseEnter += (_, _) => hover.SetToolTip(L_Viewed, L_Viewed.Text);
// Load Data
B_Search.Enabled = false;
@ -107,8 +108,8 @@ public partial class SAV_MysteryGiftDB : Form
private List<MysteryGift> RawDB = [];
private int slotSelected = -1; // = null;
private Image? slotColor;
private const int RES_MAX = 66;
private const int RES_MIN = 6;
private const int RES_MIN = GridWidth * 1;
private const int RES_MAX = GridWidth * GridHeight;
private readonly string Counter;
private readonly string Viewed;
private const int MAXFORMAT = PKX.Generation;
@ -452,10 +453,8 @@ public partial class SAV_MysteryGiftDB : Form
}
}
private void ShowHoverTextForSlot(object sender, EventArgs e)
private void ShowHoverTextForSlot(PictureBox pb)
{
if (sender is not PictureBox pb)
return;
int index = Array.IndexOf(PKXBOXES, pb);
if (!GetShiftedIndex(ref index))
return;

View file

@ -38,7 +38,7 @@ public partial class SAV_EventReset1 : Form
Text = pkmname, Enabled = pair.IsHidden,
Size = new Size((Width / 2) - 25, 22),
};
b.Click += (s, e) =>
b.Click += (_, _) =>
{
pair.Reset();
b.Enabled = false;

View file

@ -447,7 +447,7 @@ public partial class SAV_Misc3 : Form
NUD_RecordValue.Minimum = int.MinValue;
NUD_RecordValue.Maximum = int.MaxValue;
CB_Record.SelectedIndexChanged += (s, e) =>
CB_Record.SelectedIndexChanged += (_, _) =>
{
if (CB_Record.SelectedValue == null)
return;
@ -456,10 +456,10 @@ public partial class SAV_Misc3 : Form
LoadRecordID(index);
NUD_FameH.Visible = NUD_FameS.Visible = NUD_FameM.Visible = index == 1;
};
CB_Record.MouseWheel += (s, e) => ((HandledMouseEventArgs)e).Handled = true; // disallowed
CB_Record.MouseWheel += (_, e) => ((HandledMouseEventArgs)e).Handled = true; // disallowed
CB_Record.SelectedIndex = 0;
LoadRecordID(0);
NUD_RecordValue.ValueChanged += (s, e) =>
NUD_RecordValue.ValueChanged += (_, _) =>
{
if (CB_Record.SelectedValue == null)
return;
@ -475,7 +475,7 @@ public partial class SAV_Misc3 : Form
{
NUD_BP.Value = Math.Min(NUD_BP.Maximum, em.BP);
NUD_BPEarned.Value = em.BPEarned;
NUD_BPEarned.ValueChanged += (s, e) => em.BPEarned = (uint)NUD_BPEarned.Value;
NUD_BPEarned.ValueChanged += (_, _) => em.BPEarned = (uint)NUD_BPEarned.Value;
}
else
{
@ -483,9 +483,9 @@ public partial class SAV_Misc3 : Form
NUD_BPEarned.Visible = L_BPEarned.Visible = false;
}
NUD_FameH.ValueChanged += (s, e) => ChangeFame(records);
NUD_FameM.ValueChanged += (s, e) => ChangeFame(records);
NUD_FameS.ValueChanged += (s, e) => ChangeFame(records);
NUD_FameH.ValueChanged += (_, _) => ChangeFame(records);
NUD_FameM.ValueChanged += (_, _) => ChangeFame(records);
NUD_FameS.ValueChanged += (_, _) => ChangeFame(records);
void ChangeFame(Record3 r3) => r3.SetRecord(1, (uint)(NUD_RecordValue.Value = GetFameTime()));
void LoadRecordID(int index) => NUD_RecordValue.Value = records.GetRecord(index);

View file

@ -23,7 +23,7 @@ public partial class SAV_Trainer : Form
TB_TRNick.Font = TB_OTName.Font;
}
B_MaxCash.Click += (sender, e) => MT_Money.Text = "9,999,999";
B_MaxCash.Click += (_, _) => MT_Money.Text = "9,999,999";
CB_Gender.Items.Clear();
CB_Gender.Items.AddRange(Main.GenderSymbols.Take(2).ToArray()); // m/f depending on unicode selection

View file

@ -26,7 +26,7 @@ public partial class SAV_Trainer7 : Form
TB_OTName.Font = FontUtil.GetPKXFont();
}
B_MaxCash.Click += (sender, e) => MT_Money.Text = "9,999,999";
B_MaxCash.Click += (_, _) => MT_Money.Text = "9,999,999";
CB_Gender.Items.Clear();
CB_Gender.Items.AddRange(Main.GenderSymbols.Take(2).ToArray()); // m/f depending on unicode selection

View file

@ -26,7 +26,7 @@ public partial class SAV_Trainer7GG : Form
TB_OTName.Font = TB_RivalName.Font = FontUtil.GetPKXFont();
}
B_MaxCash.Click += (sender, e) => MT_Money.Text = "9,999,999";
B_MaxCash.Click += (_, _) => MT_Money.Text = "9,999,999";
GetComboBoxes();
LoadTrainerInfo();

View file

@ -189,7 +189,7 @@ public sealed partial class SAV_FlagWork8b : Form
mtb.Text = ((int)mtb.Value).ToString();
updating = false;
}
cb.SelectedValueChanged += (o, args) =>
cb.SelectedValueChanged += (_, _) =>
{
if (editing || updating)
return;

View file

@ -21,8 +21,8 @@ public partial class SAV_Trainer8 : Form
TB_OTName.Font = TB_TrainerCardName.Font = FontUtil.GetPKXFont();
}
B_MaxCash.Click += (sender, e) => MT_Money.Text = SAV.MaxMoney.ToString();
B_MaxWatt.Click += (sender, e) => MT_Watt.Text = MyStatus8.MaxWatt.ToString();
B_MaxCash.Click += (_, _) => MT_Money.Text = SAV.MaxMoney.ToString();
B_MaxWatt.Click += (_, _) => MT_Watt.Text = MyStatus8.MaxWatt.ToString();
CB_Gender.Items.Clear();
CB_Gender.Items.AddRange(Main.GenderSymbols.Take(2).ToArray()); // m/f depending on unicode selection

View file

@ -27,9 +27,9 @@ public partial class SAV_Trainer9 : Form
TB_OTName.Font = FontUtil.GetPKXFont();
}
B_MaxCash.Click += (sender, e) => MT_Money.Text = SAV.MaxMoney.ToString();
B_MaxLP.Click += (sender, e) => MT_LP.Text = SAV.MaxMoney.ToString();
B_MaxBP.Click += (sender, e) => MT_BP.Text = SAV.MaxMoney.ToString();
B_MaxCash.Click += (_, _) => MT_Money.Text = SAV.MaxMoney.ToString();
B_MaxLP.Click += (_, _) => MT_LP.Text = SAV.MaxMoney.ToString();
B_MaxBP.Click += (_, _) => MT_BP.Text = SAV.MaxMoney.ToString();
var games = GameInfo.Strings.gamelist;
CB_Game.Items.Clear();

View file

@ -29,7 +29,7 @@ public sealed partial class SAV_BoxList : Form
Owner = p.ParentForm;
foreach (var b in Boxes)
m.Env.Slots.Publisher.Subscribers.Add(b);
FormClosing += (sender, e) =>
FormClosing += (_, _) =>
{
foreach (var b in Boxes)
{
@ -41,9 +41,9 @@ public sealed partial class SAV_BoxList : Form
private void AddEvents()
{
GiveFeedback += (sender, e) => e.UseDefaultCursors = false;
GiveFeedback += (_, e) => e.UseDefaultCursors = false;
DragEnter += Main_DragEnter;
DragDrop += (sender, e) =>
DragDrop += (_, _) =>
{
Cursor = DefaultCursor;
System.Media.SystemSounds.Asterisk.Play();
@ -75,19 +75,15 @@ public sealed partial class SAV_BoxList : Form
foreach (var box in Boxes)
{
box.ClearEvents();
box.B_BoxLeft.Click += (s, e) =>
box.B_BoxLeft.Click += (_, _) =>
{
if (s == null)
return;
int index = Array.IndexOf(Boxes, ((Button)s).Parent);
int index = Array.IndexOf(Boxes, box);
int other = (index + Boxes.Length - 1) % Boxes.Length;
m.SwapBoxes(index, other, p.SAV);
};
box.B_BoxRight.Click += (s, e) =>
box.B_BoxRight.Click += (_, _) =>
{
if (s == null)
return;
int index = Array.IndexOf(Boxes, ((Button)s).Parent);
int index = Array.IndexOf(Boxes, box);
int other = (index + 1) % Boxes.Length;
m.SwapBoxes(index, other, p.SAV);
};

View file

@ -29,16 +29,16 @@ public sealed partial class SAV_BoxViewer : Form
CenterToParent();
AllowDrop = true;
GiveFeedback += (sender, e) => e.UseDefaultCursors = false;
GiveFeedback += (_, e) => e.UseDefaultCursors = false;
DragEnter += Main_DragEnter;
DragDrop += (sender, e) =>
DragDrop += (_, _) =>
{
Cursor = DefaultCursor;
System.Media.SystemSounds.Asterisk.Play();
};
Owner = p.ParentForm;
MouseWheel += (s, e) =>
MouseWheel += (_, e) =>
{
if (parent.menu.mnuVSD.Visible)
return;

View file

@ -114,7 +114,7 @@ public sealed partial class SAV_EventFlags : Form
cells[0].Value = values[index];
cells[1].Value = name;
}
dgv.CellValueChanged += (s, e) =>
dgv.CellValueChanged += (_, e) =>
{
if (e.ColumnIndex != 0 || e.RowIndex == -1)
return;
@ -125,7 +125,7 @@ public sealed partial class SAV_EventFlags : Form
if (NUD_Flag.Value == index)
c_CustomFlag.Checked = chk;
};
dgv.CellMouseUp += (s, e) =>
dgv.CellMouseUp += (_, e) =>
{
if (e.RowIndex == -1)
return;
@ -186,7 +186,7 @@ public sealed partial class SAV_EventFlags : Form
cb.InitializeBinding();
cb.DataSource = map;
lbl.Click += (sender, e) => mtb.Value = 0;
lbl.Click += (_, _) => mtb.Value = 0;
bool updating = false;
mtb.ValueChanged += ChangeConstValue;
void ChangeConstValue(object? sender, EventArgs e)
@ -205,7 +205,7 @@ public sealed partial class SAV_EventFlags : Form
MT_Stat.Text = ((int)mtb.Value).ToString();
updating = false;
}
cb.SelectedValueChanged += (o, args) =>
cb.SelectedValueChanged += (_, _) =>
{
if (editing || updating)
return;

View file

@ -114,7 +114,7 @@ public sealed partial class SAV_EventFlags2 : Form
cells[0].Value = values[index];
cells[1].Value = name;
}
dgv.CellValueChanged += (s, e) =>
dgv.CellValueChanged += (_, e) =>
{
if (e.ColumnIndex != 0 || e.RowIndex == -1)
return;
@ -125,7 +125,7 @@ public sealed partial class SAV_EventFlags2 : Form
if (NUD_Flag.Value == index)
c_CustomFlag.Checked = chk;
};
dgv.CellMouseUp += (s, e) =>
dgv.CellMouseUp += (_, e) =>
{
if (e.RowIndex == -1)
return;
@ -185,7 +185,7 @@ public sealed partial class SAV_EventFlags2 : Form
cb.InitializeBinding();
cb.DataSource = map;
lbl.Click += (sender, e) => mtb.Value = 0;
lbl.Click += (_, _) => mtb.Value = 0;
bool updating = false;
mtb.ValueChanged += ChangeConstValue;
void ChangeConstValue(object? sender, EventArgs e)
@ -204,7 +204,7 @@ public sealed partial class SAV_EventFlags2 : Form
MT_Stat.Text = ((int)mtb.Value).ToString();
updating = false;
}
cb.SelectedValueChanged += (o, args) =>
cb.SelectedValueChanged += (_, _) =>
{
if (editing || updating)
return;

View file

@ -82,8 +82,8 @@ public sealed partial class SAV_EventWork : Form
Checked = f.Flag,
AutoSize = true,
};
lbl.Click += (sender, e) => chk.Checked ^= true;
chk.CheckedChanged += (s, e) => f.Flag = chk.Checked;
lbl.Click += (_, _) => chk.Checked ^= true;
chk.CheckedChanged += (_, _) => f.Flag = chk.Checked;
tlp.Controls.Add(chk, 0, i);
tlp.Controls.Add(lbl, 1, i);
i++;
@ -139,7 +139,7 @@ public sealed partial class SAV_EventWork : Form
if (cb.SelectedIndex < 0)
cb.SelectedIndex = 0;
cb.SelectedValueChanged += (s, e) =>
cb.SelectedValueChanged += (_, _) =>
{
if (editing)
return;
@ -154,7 +154,7 @@ public sealed partial class SAV_EventWork : Form
}
editing = false;
};
nud.ValueChanged += (s, e) =>
nud.ValueChanged += (_, _) =>
{
if (editing)
return;

View file

@ -28,7 +28,7 @@ public sealed partial class SAV_GroupViewer : Form
Regenerate(count);
CenterToParent();
MouseWheel += (s, e) => CurrentGroup = e.Delta > 1 ? MoveLeft() : MoveRight();
MouseWheel += (_, e) => CurrentGroup = e.Delta > 1 ? MoveLeft() : MoveRight();
var names = groups.Select(z => $"{z.GroupName}").ToArray();
CB_BoxSelect.Items.AddRange(names);
@ -36,19 +36,18 @@ public sealed partial class SAV_GroupViewer : Form
foreach (PictureBox pb in Box.Entries)
{
pb.Click += (o, args) => OmniClick(pb, args);
pb.Click += (_, args) => OmniClick(pb, args);
pb.ContextMenuStrip = mnu;
pb.MouseMove += (o, args) => Preview.UpdatePreviewPosition(args.Location);
pb.MouseEnter += (o, args) => HoverSlot(pb, args);
pb.MouseLeave += (o, args) => Preview.Clear();
pb.MouseMove += (_, args) => Preview.UpdatePreviewPosition(args.Location);
pb.MouseEnter += (_, _) => HoverSlot(pb);
pb.MouseLeave += (_, _) => Preview.Clear();
}
Closing += (s, e) => Preview.Clear();
Closing += (_, _) => Preview.Clear();
}
private void HoverSlot(object sender, EventArgs e)
private void HoverSlot(PictureBox pb)
{
var group = Groups[CurrentGroup];
var pb = (PictureBox)sender;
var index = Box.Entries.IndexOf(pb);
var slot = group.Slots[index];
Preview.Show(pb, slot);

View file

@ -19,8 +19,8 @@ public partial class SAV_SimpleTrainer : Form
cba = [CHK_1, CHK_2, CHK_3, CHK_4, CHK_5, CHK_6, CHK_7, CHK_8];
TB_OTName.MaxLength = SAV.MaxStringLengthTrainer;
B_MaxCash.Click += (sender, e) => MT_Money.Text = SAV.MaxMoney.ToString();
B_MaxCoins.Click += (sender, e) => MT_Coins.Text = SAV.MaxCoins.ToString();
B_MaxCash.Click += (_, _) => MT_Money.Text = SAV.MaxMoney.ToString();
B_MaxCoins.Click += (_, _) => MT_Coins.Text = SAV.MaxCoins.ToString();
MT_Money.Mask = "".PadRight((int)Math.Floor(Math.Log10(SAV.MaxMoney) + 1), '0');
MT_Coins.Mask = "".PadRight((int)Math.Floor(Math.Log10(SAV.MaxCoins) + 1), '0');

View file

@ -42,7 +42,7 @@ public partial class SAV_Wondercard : Form
pb.MouseDown += BoxSlot_MouseDown;
pb.ContextMenuStrip = mnuVSD;
pb.MouseHover += (_, _) => Summary.Show(pb, Album[pba.IndexOf(pb)]);
pb.Enter += (sender, e) =>
pb.Enter += (_, _) =>
{
var index = pba.IndexOf(pb);
if (index < 0)

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
@ -11,7 +11,7 @@ public partial class TrainerStat : UserControl
public TrainerStat()
{
InitializeComponent();
CB_Stats.MouseWheel += (s, e) => ((HandledMouseEventArgs)e).Handled = true; // disallowed
CB_Stats.MouseWheel += (_, e) => ((HandledMouseEventArgs)e).Handled = true; // disallowed
}
private bool Editing;

View file

@ -28,7 +28,7 @@ public partial class SettingsEditor : Form
CB_Blank.SelectedValue = (int)s.Startup.DefaultSaveVersion;
CB_Blank.SelectedValueChanged += (_, _) => s.Startup.DefaultSaveVersion = (GameVersion)WinFormsUtil.GetIndex(CB_Blank);
CB_Blank.SelectedIndexChanged += (_, _) => BlankChanged = true;
B_Reset.Click += (x, e) => DeleteSettings();
B_Reset.Click += (_, _) => DeleteSettings();
}
else
{

View file

@ -42,7 +42,7 @@ namespace PKHeX.WinForms
ShortcutKeys = Keys.Control | Keys.Alt | Keys.D,
Visible = false,
};
ti.Click += (s, e) => UpdateAll();
ti.Click += (_, _) => UpdateAll();
return ti;
}