mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 06:34:19 +00:00
Upgrade netcore build to NET 5.0
keep with the times, kids handle some compiler messages
This commit is contained in:
parent
5e22c119be
commit
81110b4231
28 changed files with 128 additions and 92 deletions
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp3.1;net46</TargetFrameworks>
|
||||
<TargetFrameworks>net5.0;net46</TargetFrameworks>
|
||||
<LangVersion>8</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
@ -29,7 +29,7 @@
|
|||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith('net5'))">
|
||||
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
|
||||
<PackageReference Include="System.Resources.Extensions" Version="4.7.0" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -118,7 +118,8 @@ namespace PKHeX.WinForms.Controls
|
|||
if (!(sender is MaskedTextBox mt))
|
||||
return;
|
||||
|
||||
int.TryParse(mt.Text, out var val);
|
||||
if (int.TryParse(mt.Text, out var val))
|
||||
val = 0;
|
||||
if (mt == TB_TID7)
|
||||
{
|
||||
if (val > 999_999)
|
||||
|
@ -126,7 +127,8 @@ namespace PKHeX.WinForms.Controls
|
|||
mt.Text = "999999";
|
||||
return;
|
||||
}
|
||||
int.TryParse(TB_SID7.Text, out var sid);
|
||||
if (!int.TryParse(TB_SID7.Text, out var sid))
|
||||
sid = 0;
|
||||
SanityCheckSID7(val, sid);
|
||||
}
|
||||
else if (mt == TB_SID7)
|
||||
|
@ -136,7 +138,8 @@ namespace PKHeX.WinForms.Controls
|
|||
mt.Text = "4294";
|
||||
return;
|
||||
}
|
||||
int.TryParse(TB_TID7.Text, out var tid);
|
||||
if (!int.TryParse(TB_TID7.Text, out var tid))
|
||||
tid = 0;
|
||||
SanityCheckSID7(tid, val);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace PKHeX.WinForms.Controls
|
|||
private Image GetFrame(int frameIndex)
|
||||
{
|
||||
if (GlowCache == null)
|
||||
throw new ArgumentNullException(nameof(GlowCache));
|
||||
throw new NullReferenceException(nameof(GlowCache));
|
||||
var frame = GlowCache[frameIndex];
|
||||
if (frame != null)
|
||||
return frame;
|
||||
|
@ -101,7 +101,7 @@ namespace PKHeX.WinForms.Controls
|
|||
var frameColor = GetFrameColor(elapsedFraction);
|
||||
|
||||
if (GlowData == null)
|
||||
throw new ArgumentNullException(nameof(GlowData));
|
||||
throw new NullReferenceException(nameof(GlowData));
|
||||
var frameData = (byte[])GlowData.Clone();
|
||||
ImageUtil.ChangeAllColorTo(frameData, frameColor);
|
||||
|
||||
|
|
|
@ -209,11 +209,9 @@ namespace PKHeX.WinForms.Controls
|
|||
|
||||
public void ClearEvents()
|
||||
{
|
||||
#pragma warning disable CS8622 // Nullability of reference types in type of parameter doesn't match the target delegate.
|
||||
B_BoxRight.Click -= ClickBoxRight;
|
||||
B_BoxLeft.Click -= ClickBoxLeft;
|
||||
CB_BoxSelect.SelectedIndexChanged -= GetBox;
|
||||
#pragma warning restore CS8622 // Nullability of reference types in type of parameter doesn't match the target delegate.
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
|
@ -222,7 +220,7 @@ namespace PKHeX.WinForms.Controls
|
|||
ResetSlots();
|
||||
}
|
||||
|
||||
private void GetBox(object sender, EventArgs e)
|
||||
private void GetBox(object? sender, EventArgs e)
|
||||
{
|
||||
CurrentBox = CB_BoxSelect.SelectedIndex;
|
||||
if (SAV.CurrentBox != CurrentBox && CanSetCurrentBox)
|
||||
|
@ -231,19 +229,19 @@ namespace PKHeX.WinForms.Controls
|
|||
M?.Hover.Stop();
|
||||
}
|
||||
|
||||
private void ClickBoxLeft(object sender, EventArgs e) => CurrentBox = Editor.MoveLeft(ModifierKeys == Keys.Control);
|
||||
private void ClickBoxRight(object sender, EventArgs e) => CurrentBox = Editor.MoveRight(ModifierKeys == Keys.Control);
|
||||
private void ClickBoxLeft(object? sender, EventArgs e) => CurrentBox = Editor.MoveLeft(ModifierKeys == Keys.Control);
|
||||
private void ClickBoxRight(object? sender, EventArgs e) => CurrentBox = Editor.MoveRight(ModifierKeys == Keys.Control);
|
||||
|
||||
// Drag & Drop Handling
|
||||
private void BoxSlot_MouseEnter(object sender, EventArgs e) => M?.MouseEnter(sender, e);
|
||||
private void BoxSlot_MouseLeave(object sender, EventArgs e) => M?.MouseLeave(sender, e);
|
||||
private void BoxSlot_MouseClick(object sender, MouseEventArgs e) => M?.MouseClick(sender, e);
|
||||
private void BoxSlot_MouseUp(object sender, MouseEventArgs e) => M?.MouseUp(sender, e);
|
||||
private void BoxSlot_MouseDown(object sender, MouseEventArgs e) => M?.MouseDown(sender, e);
|
||||
private void BoxSlot_MouseMove(object sender, MouseEventArgs e) => M?.MouseMove(sender, e);
|
||||
private void BoxSlot_DragEnter(object sender, DragEventArgs e) => M?.DragEnter(sender, e);
|
||||
private void BoxSlot_QueryContinueDrag(object sender, QueryContinueDragEventArgs e) => M?.QueryContinueDrag(sender, e);
|
||||
private void BoxSlot_DragDrop(object sender, DragEventArgs e) => M?.DragDrop(sender, e);
|
||||
private void BoxSlot_MouseEnter(object? sender, EventArgs e) => M?.MouseEnter(sender, e);
|
||||
private void BoxSlot_MouseLeave(object? sender, EventArgs e) => M?.MouseLeave(sender, e);
|
||||
private void BoxSlot_MouseClick(object? sender, MouseEventArgs e) => M?.MouseClick(sender, e);
|
||||
private void BoxSlot_MouseUp(object? sender, MouseEventArgs e) => M?.MouseUp(sender, e);
|
||||
private void BoxSlot_MouseDown(object? sender, MouseEventArgs e) => M?.MouseDown(sender, e);
|
||||
private void BoxSlot_MouseMove(object? sender, MouseEventArgs e) => M?.MouseMove(sender, e);
|
||||
private void BoxSlot_DragEnter(object? sender, DragEventArgs e) => M?.DragEnter(sender, e);
|
||||
private void BoxSlot_QueryContinueDrag(object? sender, QueryContinueDragEventArgs e) => M?.QueryContinueDrag(sender, e);
|
||||
private void BoxSlot_DragDrop(object? sender, DragEventArgs e) => M?.DragDrop(sender, e);
|
||||
|
||||
public bool InitializeFromSAV(SaveFile sav)
|
||||
{
|
||||
|
|
|
@ -98,7 +98,7 @@ namespace PKHeX.WinForms.Controls
|
|||
WinFormsUtil.Alert(MsgSaveSlotLocked);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
throw new IndexOutOfRangeException(nameof(msg));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -133,10 +133,10 @@ namespace PKHeX.WinForms.Controls
|
|||
{
|
||||
var pb = WinFormsUtil.GetUnderlyingControl<PictureBox>(sender);
|
||||
if (pb == null)
|
||||
throw new ArgumentNullException(nameof(pb));
|
||||
throw new InvalidCastException("Unable to find PictureBox");
|
||||
var view = WinFormsUtil.FindFirstControlOfType<ISlotViewer<PictureBox>>(pb);
|
||||
if (view == null)
|
||||
throw new ArgumentNullException(nameof(view));
|
||||
throw new InvalidCastException("Unable to find View Parent");
|
||||
var loc = view.GetSlotData(pb);
|
||||
sender = pb;
|
||||
return new SlotViewInfo<PictureBox>(loc, view);
|
||||
|
|
|
@ -117,15 +117,15 @@ namespace PKHeX.WinForms.Controls
|
|||
}
|
||||
|
||||
// Drag & Drop Handling
|
||||
private void BoxSlot_MouseEnter(object sender, EventArgs e) => M?.MouseEnter(sender, e);
|
||||
private void BoxSlot_MouseLeave(object sender, EventArgs e) => M?.MouseLeave(sender, e);
|
||||
private void BoxSlot_MouseClick(object sender, MouseEventArgs e) => M?.MouseClick(sender, e);
|
||||
private void BoxSlot_MouseUp(object sender, MouseEventArgs e) => M?.MouseUp(sender, e);
|
||||
private void BoxSlot_MouseDown(object sender, MouseEventArgs e) => M?.MouseDown(sender, e);
|
||||
private void BoxSlot_MouseMove(object sender, MouseEventArgs e) => M?.MouseMove(sender, e);
|
||||
private void BoxSlot_DragEnter(object sender, DragEventArgs e) => M?.DragEnter(sender, e);
|
||||
private void BoxSlot_QueryContinueDrag(object sender, QueryContinueDragEventArgs e) => M?.QueryContinueDrag(sender, e);
|
||||
private void BoxSlot_DragDrop(object sender, DragEventArgs e) => M?.DragDrop(sender, e);
|
||||
private void BoxSlot_MouseEnter(object? sender, EventArgs e) => M?.MouseEnter(sender, e);
|
||||
private void BoxSlot_MouseLeave(object? sender, EventArgs e) => M?.MouseLeave(sender, e);
|
||||
private void BoxSlot_MouseClick(object? sender, MouseEventArgs e) => M?.MouseClick(sender, e);
|
||||
private void BoxSlot_MouseUp(object? sender, MouseEventArgs e) => M?.MouseUp(sender, e);
|
||||
private void BoxSlot_MouseDown(object? sender, MouseEventArgs e) => M?.MouseDown(sender, e);
|
||||
private void BoxSlot_MouseMove(object? sender, MouseEventArgs e) => M?.MouseMove(sender, e);
|
||||
private void BoxSlot_DragEnter(object? sender, DragEventArgs e) => M?.DragEnter(sender, e);
|
||||
private void BoxSlot_QueryContinueDrag(object? sender, QueryContinueDragEventArgs e) => M?.QueryContinueDrag(sender, e);
|
||||
private void BoxSlot_DragDrop(object? sender, DragEventArgs e) => M?.DragDrop(sender, e);
|
||||
|
||||
public bool InitializeFromSAV(SaveFile sav)
|
||||
{
|
||||
|
|
|
@ -105,10 +105,8 @@ namespace PKHeX.WinForms.Controls
|
|||
|
||||
private void InitializeDragDrop(Control pb)
|
||||
{
|
||||
#pragma warning disable CS8622 // Nullability of reference types in type of parameter doesn't match the target delegate.
|
||||
pb.MouseEnter += M.MouseEnter;
|
||||
pb.MouseLeave += M.MouseLeave;
|
||||
#pragma warning restore CS8622 // Nullability of reference types in type of parameter doesn't match the target delegate.
|
||||
pb.MouseClick += M.MouseClick;
|
||||
pb.MouseMove += M.MouseMove;
|
||||
pb.MouseDown += M.MouseDown;
|
||||
|
|
|
@ -33,34 +33,42 @@ namespace PKHeX.WinForms.Controls
|
|||
LastSlot.Reset();
|
||||
}
|
||||
|
||||
public void MouseEnter(object sender, EventArgs e)
|
||||
public void MouseEnter(object? sender, EventArgs e)
|
||||
{
|
||||
if (sender == null)
|
||||
return;
|
||||
var pb = (PictureBox)sender;
|
||||
if (pb.Image == null)
|
||||
return;
|
||||
Hover.Start(pb, LastSlot);
|
||||
}
|
||||
|
||||
public void MouseLeave(object sender, EventArgs e)
|
||||
public void MouseLeave(object? sender, EventArgs e)
|
||||
{
|
||||
Hover.Stop();
|
||||
}
|
||||
|
||||
public void MouseClick(object sender, MouseEventArgs e)
|
||||
public void MouseClick(object? sender, MouseEventArgs e)
|
||||
{
|
||||
if (sender == null)
|
||||
return;
|
||||
if (!Drag.Info.DragDropInProgress)
|
||||
SE.ClickSlot(sender, e);
|
||||
}
|
||||
|
||||
public void MouseUp(object sender, MouseEventArgs e)
|
||||
public void MouseUp(object? sender, MouseEventArgs e)
|
||||
{
|
||||
if (sender == null)
|
||||
return;
|
||||
if (e.Button == MouseButtons.Left)
|
||||
Drag.Info.LeftMouseIsDown = false;
|
||||
Drag.Info.Source = null;
|
||||
}
|
||||
|
||||
public void MouseDown(object sender, MouseEventArgs e)
|
||||
public void MouseDown(object? sender, MouseEventArgs e)
|
||||
{
|
||||
if (sender == null)
|
||||
return;
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
Drag.Info.LeftMouseIsDown = true;
|
||||
|
@ -68,16 +76,20 @@ namespace PKHeX.WinForms.Controls
|
|||
}
|
||||
}
|
||||
|
||||
public void QueryContinueDrag(object sender, QueryContinueDragEventArgs e)
|
||||
public void QueryContinueDrag(object? sender, QueryContinueDragEventArgs e)
|
||||
{
|
||||
if (sender == null)
|
||||
return;
|
||||
if (e.Action != DragAction.Cancel && e.Action != DragAction.Drop)
|
||||
return;
|
||||
Drag.Info.LeftMouseIsDown = false;
|
||||
Drag.Info.DragDropInProgress = false;
|
||||
}
|
||||
|
||||
public void DragEnter(object sender, DragEventArgs e)
|
||||
public void DragEnter(object? sender, DragEventArgs e)
|
||||
{
|
||||
if (sender == null)
|
||||
return;
|
||||
if ((e.AllowedEffect & DragDropEffects.Copy) != 0) // external file
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
else if (e.Data != null) // within
|
||||
|
@ -91,13 +103,15 @@ namespace PKHeX.WinForms.Controls
|
|||
{
|
||||
var view = WinFormsUtil.FindFirstControlOfType<ISlotViewer<T>>(pb);
|
||||
if (view == null)
|
||||
throw new ArgumentNullException(nameof(view));
|
||||
throw new InvalidCastException("Unable to find View Parent");
|
||||
var src = view.GetSlotData(pb);
|
||||
return new SlotViewInfo<T>(src, view);
|
||||
}
|
||||
|
||||
public void MouseMove(object sender, MouseEventArgs e)
|
||||
public void MouseMove(object? sender, MouseEventArgs e)
|
||||
{
|
||||
if (sender == null)
|
||||
return;
|
||||
if (!Drag.CanStartDrag)
|
||||
return;
|
||||
|
||||
|
@ -112,8 +126,10 @@ namespace PKHeX.WinForms.Controls
|
|||
HandleMovePKM(pb, encrypt);
|
||||
}
|
||||
|
||||
public void DragDrop(object sender, DragEventArgs e)
|
||||
public void DragDrop(object? sender, DragEventArgs e)
|
||||
{
|
||||
if (sender == null)
|
||||
return;
|
||||
PictureBox pb = (PictureBox)sender;
|
||||
var info = GetSlotInfo(pb);
|
||||
if (!info.CanWriteTo())
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace PKHeX.WinForms.Controls
|
|||
{
|
||||
var view = WinFormsUtil.FindFirstControlOfType<ISlotViewer<PictureBox>>(pb);
|
||||
if (view == null)
|
||||
throw new ArgumentNullException(nameof(view));
|
||||
throw new InvalidCastException(nameof(view));
|
||||
var data = view.GetSlotData(pb);
|
||||
var pk = data.Read(view.SAV);
|
||||
Slot = pb;
|
||||
|
|
|
@ -143,7 +143,10 @@ namespace PKHeX.WinForms.Controls
|
|||
for (var i = 0; i < names.Length; i++)
|
||||
{
|
||||
var name = names[i];
|
||||
Enum.TryParse<StorageSlotType>(name, out var val);
|
||||
bool result = Enum.TryParse<StorageSlotType>(name, out var val);
|
||||
if (!result)
|
||||
continue;
|
||||
|
||||
var label = new LabelType
|
||||
{
|
||||
Name = $"L_{name}",
|
||||
|
|
|
@ -110,7 +110,7 @@ namespace PKHeX.WinForms
|
|||
BAKprompt = false;
|
||||
|
||||
HaX = args.Any(x => string.Equals(x.Trim('-'), nameof(HaX), StringComparison.CurrentCultureIgnoreCase))
|
||||
|| Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().MainModule.FileName).EndsWith(nameof(HaX));
|
||||
|| Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().MainModule!.FileName!).EndsWith(nameof(HaX));
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -280,7 +280,7 @@ namespace PKHeX.WinForms
|
|||
BAKprompt = Settings.BAKPrompt = true;
|
||||
}
|
||||
|
||||
public static DrawConfig Draw = new DrawConfig();
|
||||
public static DrawConfig Draw { get; private set; } = new DrawConfig();
|
||||
|
||||
private void FormInitializeSecond()
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFrameworks>net46;netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFrameworks>net46;net5.0-windows</TargetFrameworks>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<PackageId>PKHeX</PackageId>
|
||||
<Company>Project Pokémon</Company>
|
||||
|
|
|
@ -56,6 +56,8 @@ namespace PKHeX.WinForms
|
|||
// Enable Click
|
||||
slot.MouseClick += (sender, e) =>
|
||||
{
|
||||
if (sender == null)
|
||||
return;
|
||||
switch (ModifierKeys)
|
||||
{
|
||||
case Keys.Control: ClickView(sender, e); break;
|
||||
|
@ -140,7 +142,7 @@ namespace PKHeX.WinForms
|
|||
return;
|
||||
}
|
||||
#endif
|
||||
if (path != null && path.Contains(Path.DirectorySeparatorChar))
|
||||
if (path?.Contains(Path.DirectorySeparatorChar) == true)
|
||||
{
|
||||
// Data from Database: Delete file from disk
|
||||
if (File.Exists(path))
|
||||
|
@ -438,12 +440,12 @@ namespace PKHeX.WinForms
|
|||
|
||||
// pre-filter based on the file path (if specified)
|
||||
if (!Menu_SearchBoxes.Checked)
|
||||
res = res.Where(pk => pk.Identifier != null && pk.Identifier.StartsWith(DatabasePath + Path.DirectorySeparatorChar, StringComparison.Ordinal));
|
||||
res = res.Where(pk => pk.Identifier?.StartsWith(DatabasePath + Path.DirectorySeparatorChar, StringComparison.Ordinal) == true);
|
||||
if (!Menu_SearchDatabase.Checked)
|
||||
{
|
||||
res = res.Where(pk => pk.Identifier != null && !pk.Identifier.StartsWith(DatabasePath + Path.DirectorySeparatorChar, StringComparison.Ordinal));
|
||||
res = res.Where(pk => pk.Identifier?.StartsWith(DatabasePath + Path.DirectorySeparatorChar, StringComparison.Ordinal) == false);
|
||||
#if LOADALL
|
||||
res = res.Where(pk => pk.Identifier != null && !pk.Identifier.StartsWith(EXTERNAL_SAV, StringComparison.Ordinal));
|
||||
res = res.Where(pk => pk.Identifier?.StartsWith(EXTERNAL_SAV, StringComparison.Ordinal) == false);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -634,8 +636,8 @@ namespace PKHeX.WinForms
|
|||
return;
|
||||
|
||||
var deleted = 0;
|
||||
var db = RawDB.Where(pk => pk.Identifier != null && pk.Identifier.StartsWith(DatabasePath + Path.DirectorySeparatorChar, StringComparison.Ordinal))
|
||||
.OrderByDescending(file => File.GetLastWriteTimeUtc(file.Identifier));
|
||||
var db = RawDB.Where(pk => pk.Identifier?.StartsWith(DatabasePath + Path.DirectorySeparatorChar, StringComparison.Ordinal) == true)
|
||||
.OrderByDescending(file => File.GetLastWriteTimeUtc(file.Identifier!));
|
||||
|
||||
var clones = SearchUtil.GetExtraClones(db);
|
||||
foreach (var pk in clones)
|
||||
|
|
|
@ -47,6 +47,8 @@ namespace PKHeX.WinForms
|
|||
// Enable Click
|
||||
slot.MouseClick += (sender, e) =>
|
||||
{
|
||||
if (sender == null)
|
||||
return;
|
||||
if (ModifierKeys == Keys.Control)
|
||||
ClickView(sender, e);
|
||||
};
|
||||
|
|
|
@ -183,7 +183,7 @@ namespace PKHeX.WinForms
|
|||
{
|
||||
var di = new DirectoryInfo(z);
|
||||
var root = di.Root.Name;
|
||||
var folder = di.Parent.Name;
|
||||
var folder = di.Parent?.Name ?? di.Name;
|
||||
if (root == folder)
|
||||
folder = di.Name;
|
||||
|
||||
|
@ -232,7 +232,7 @@ namespace PKHeX.WinForms
|
|||
public GameVersion Game => Save.Version;
|
||||
|
||||
public string Played => Save.PlayTimeString.PadLeft(9, '0');
|
||||
public string FileTime => File.GetLastWriteTimeUtc(Save.FilePath).ToString("yyyy.MM.dd:hh:mm:ss");
|
||||
public string FileTime => File.GetLastWriteTimeUtc(Save.FilePath!).ToString("yyyy.MM.dd:hh:mm:ss");
|
||||
|
||||
public string TID => Save.Generation >= 7 ? Save.TrainerID7.ToString("000000") : Save.TID.ToString("00000");
|
||||
public string SID => Save.Generation >= 7 ? Save.TrainerSID7.ToString("0000") : Save.SID.ToString("00000");
|
||||
|
@ -308,10 +308,10 @@ namespace PKHeX.WinForms
|
|||
{
|
||||
if (e.ColumnIndex == -1 || e.RowIndex == -1 || e.Button != MouseButtons.Right)
|
||||
return;
|
||||
|
||||
var c = ((DataGridView) sender)[e.ColumnIndex, e.RowIndex];
|
||||
c.DataGridView.ClearSelection();
|
||||
c.DataGridView.CurrentCell = c;
|
||||
var dgv = (DataGridView)sender;
|
||||
var c = dgv[e.ColumnIndex, e.RowIndex];
|
||||
dgv.ClearSelection();
|
||||
dgv.CurrentCell = c;
|
||||
c.Selected = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace PKHeX.WinForms
|
|||
slot.MouseClick += (sender, e) =>
|
||||
{
|
||||
if (ModifierKeys == Keys.Control)
|
||||
ClickView(sender, e);
|
||||
ClickView(sender!, e);
|
||||
};
|
||||
|
||||
slot.ContextMenuStrip = mnu;
|
||||
|
@ -95,9 +95,9 @@ namespace PKHeX.WinForms
|
|||
if (index < 0)
|
||||
return;
|
||||
var pk = Results[index].ConvertToPKM(SAV);
|
||||
pk = PKMConverter.ConvertToType(pk, SAV.PKMType, out _);
|
||||
pk = PKMConverter.ConvertToType(pk, SAV.PKMType, out var c);
|
||||
if (pk == null)
|
||||
throw new ArgumentNullException(nameof(pk)); // shouldn't happen
|
||||
throw new FormatException(c); // shouldn't happen
|
||||
SAV.AdaptPKM(pk);
|
||||
PKME_Tabs.PopulateFields(pk, false);
|
||||
slotSelected = index;
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace PKHeX.WinForms
|
|||
|
||||
private void ReadMain()
|
||||
{
|
||||
string[]? FlyDestA = null;
|
||||
string[]? FlyDestA;
|
||||
switch (SAV.Version)
|
||||
{
|
||||
case GameVersion.B:
|
||||
|
@ -107,6 +107,8 @@ namespace PKHeX.WinForms
|
|||
5, 6, 7, 22
|
||||
};
|
||||
break;
|
||||
|
||||
default: throw new ArgumentOutOfRangeException(nameof(SAV.Version));
|
||||
}
|
||||
uint valFly = BitConverter.ToUInt32(SAV.Data, ofsFly);
|
||||
CLB_FlyDest.Items.Clear();
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace PKHeX.WinForms
|
|||
for (int i = 0; i < CellCount; i++)
|
||||
{
|
||||
if (cells[i] > 2)
|
||||
throw new ArgumentException();
|
||||
throw new IndexOutOfRangeException("Unable to find cell index.");
|
||||
|
||||
dgv.Rows[i].Cells[0].Value = (i+1);
|
||||
dgv.Rows[i].Cells[1].Value = locations[i];
|
||||
|
@ -61,7 +61,7 @@ namespace PKHeX.WinForms
|
|||
string str = (string)dgv.Rows[i].Cells[2].Value;
|
||||
int val = Array.IndexOf(states, str);
|
||||
if (val < 0)
|
||||
throw new ArgumentException();
|
||||
throw new IndexOutOfRangeException("Unable to find cell index.");
|
||||
|
||||
constants[celloffset + i] = (ushort)val;
|
||||
}
|
||||
|
|
|
@ -202,16 +202,11 @@ namespace PKHeX.WinForms
|
|||
|
||||
private void B_Save_Click(object sender, EventArgs e)
|
||||
{
|
||||
HandleSpecialFlags();
|
||||
Editor.Save();
|
||||
Origin.Edited = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void HandleSpecialFlags()
|
||||
{
|
||||
}
|
||||
|
||||
private void ChangeCustomFlag(object sender, EventArgs e)
|
||||
{
|
||||
c_CustomFlag.Checked = SAV.GetFlag((int) NUD_Flag.Value);
|
||||
|
@ -269,7 +264,7 @@ namespace PKHeX.WinForms
|
|||
case GameVersion.C: return "c";
|
||||
case GameVersion.R: case GameVersion.S: case GameVersion.RS: return "rs";
|
||||
case GameVersion.FR: case GameVersion.LG: case GameVersion.FRLG: return "frlg";
|
||||
default: throw new ArgumentException(nameof(game));
|
||||
default: throw new IndexOutOfRangeException(nameof(game));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -226,7 +226,9 @@ namespace PKHeX.WinForms
|
|||
if (itemindex <= 0 && !HasNew) // Compression of Empty Slots
|
||||
continue;
|
||||
|
||||
int.TryParse(cells[ColumnCount].Value?.ToString(), out int itemcnt);
|
||||
bool result = int.TryParse(cells[ColumnCount].Value?.ToString(), out int itemcnt);
|
||||
if (!result)
|
||||
continue;
|
||||
if (!pouch.IsValidItemAndCount(SAV, itemindex, HasNew, Main.HaX, ref itemcnt))
|
||||
continue; // ignore item
|
||||
|
||||
|
|
|
@ -445,7 +445,7 @@ namespace PKHeX.WinForms
|
|||
{
|
||||
DialogResult ret = DialogResult.Abort;
|
||||
var s = p.Select((pkm, i) => ((sbyte)PKMNUDs[i].Value == entry) && ItemIsMail(pkm.HeldItem) ? pkm : null).ToArray();
|
||||
if (s.Count(v => v != null) == 0)
|
||||
if (s.All(v => v == null))
|
||||
return ret;
|
||||
System.Media.SystemSounds.Question.Play();
|
||||
var msg = $"{s.Select((v, i) => v == null ? string.Empty : $"{Environment.NewLine} {PKMLabels[i].Text}: {PKMHeldItems[i].Text} -> {CB_MailType.Items[0]}").Aggregate($"Modify PKM's HeldItem?{Environment.NewLine}", (tmp, v) => $"{tmp}{v}")}{Environment.NewLine}{Environment.NewLine}Yes: Delete Mail & Modify PKM{Environment.NewLine}No: Delete Mail";
|
||||
|
|
|
@ -384,8 +384,10 @@ namespace PKHeX.WinForms
|
|||
ViewGiftData(gift);
|
||||
}
|
||||
|
||||
private void BoxSlot_MouseDown(object sender, MouseEventArgs e)
|
||||
private void BoxSlot_MouseDown(object? sender, MouseEventArgs e)
|
||||
{
|
||||
if (sender == null)
|
||||
return;
|
||||
switch (ModifierKeys)
|
||||
{
|
||||
case Keys.Control: ClickView(sender, e); return;
|
||||
|
|
|
@ -161,7 +161,7 @@ namespace PKHeX.WinForms
|
|||
return (int)(cb.SelectedValue ?? 0);
|
||||
}
|
||||
|
||||
public static void PanelScroll(object sender, ScrollEventArgs e)
|
||||
public static void PanelScroll(object? sender, ScrollEventArgs e)
|
||||
{
|
||||
if (!(sender is ScrollableControl p) || e.NewValue < 0)
|
||||
return;
|
||||
|
@ -174,7 +174,7 @@ namespace PKHeX.WinForms
|
|||
p.VerticalScroll.Value = Clamp(e.NewValue, p.VerticalScroll);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
throw new IndexOutOfRangeException(nameof(e.ScrollOrientation));
|
||||
}
|
||||
static int Clamp(int value, ScrollProperties prop) => Math.Max(prop.Minimum, Math.Min(prop.Maximum, value));
|
||||
}
|
||||
|
@ -198,7 +198,12 @@ namespace PKHeX.WinForms
|
|||
control.ValueMember = nameof(ComboItem.Value);
|
||||
}
|
||||
|
||||
public static void RemoveDropCB(object sender, KeyEventArgs e) => ((ComboBox)sender).DroppedDown = false;
|
||||
public static void RemoveDropCB(object? sender, KeyEventArgs e)
|
||||
{
|
||||
if (sender == null)
|
||||
return;
|
||||
((ComboBox)sender).DroppedDown = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Iterates the Control's child controls recursively to obtain all controls of the specified type.
|
||||
|
@ -358,7 +363,7 @@ namespace PKHeX.WinForms
|
|||
|
||||
var path = sfd.FileName;
|
||||
if (path == null)
|
||||
throw new ArgumentNullException(nameof(sfd.FileName));
|
||||
throw new NullReferenceException(nameof(sfd.FileName));
|
||||
|
||||
ExportSAV(sav, path);
|
||||
return true;
|
||||
|
|
|
@ -28,7 +28,7 @@ PKHeX expects save files that are not encrypted with console-specific keys. Use
|
|||
|
||||
## Building
|
||||
|
||||
PKHeX is a Windows Forms application which requires [.NET Framework v4.6](https://www.microsoft.com/en-us/download/details.aspx?id=48137), with experimental support for [.NET Core 3](https://dotnet.microsoft.com/download/dotnet-core/3.0).
|
||||
PKHeX is a Windows Forms application which requires [.NET Framework v4.6](https://www.microsoft.com/en-us/download/details.aspx?id=48137), with experimental support for [.NET 5.0](https://dotnet.microsoft.com/download/dotnet/5.0).
|
||||
|
||||
The executable can be built with any compiler that supports C# 8.
|
||||
|
||||
|
|
|
@ -54,8 +54,9 @@ namespace PKHeX.Tests.Legality
|
|||
var format = PKX.GetPKMFormatFromExtension(file[^1], -1);
|
||||
format.Should().BeLessOrEqualTo(PKX.Generation, "filename is expected to have a valid extension");
|
||||
|
||||
ParseSettings.AllowGBCartEra = fi.DirectoryName.Contains("GBCartEra");
|
||||
ParseSettings.AllowGen1Tradeback = fi.DirectoryName.Contains("1 Tradeback");
|
||||
var dn = fi.DirectoryName ?? string.Empty;
|
||||
ParseSettings.AllowGBCartEra = dn.Contains("GBCartEra");
|
||||
ParseSettings.AllowGen1Tradeback = dn.Contains("1 Tradeback");
|
||||
var pkm = PKMConverter.GetPKMfromBytes(data, prefer: format);
|
||||
pkm.Should().NotBeNull($"the PKM '{new FileInfo(file).Name}' should have been loaded");
|
||||
if (pkm == null)
|
||||
|
@ -67,11 +68,12 @@ namespace PKHeX.Tests.Legality
|
|||
continue;
|
||||
}
|
||||
|
||||
var fn = Path.Combine(fi.Directory.Name, fi.Name);
|
||||
var fn = Path.Combine(dn, fi.Name);
|
||||
if (isValid)
|
||||
{
|
||||
var info = legality.Info;
|
||||
var result = legality.Results.Concat(info.Moves).Concat(info.Relearn);
|
||||
// ReSharper disable once ConstantConditionalAccessQualifier
|
||||
var invalid = result.Where(z => z?.Valid == false);
|
||||
var msg = string.Join(Environment.NewLine, invalid.Select(z => z.Comment));
|
||||
legality.Valid.Should().BeTrue($"because the file '{fn}' should be Valid, but found:{Environment.NewLine}{msg}");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace PKHeX.Tests.Simulator
|
|||
var first = encounters.FirstOrDefault();
|
||||
Assert.NotNull(first);
|
||||
|
||||
var egg = (EncounterEgg)first;
|
||||
var egg = (EncounterEgg)first!;
|
||||
var info = new SimpleTrainerInfo(GameVersion.SN);
|
||||
var pk = egg.ConvertToPKM(info);
|
||||
Assert.True(pk.Species != set.Species);
|
||||
|
@ -65,7 +65,7 @@ namespace PKHeX.Tests.Simulator
|
|||
var first = encs.FirstOrDefault();
|
||||
Assert.NotNull(first);
|
||||
|
||||
var wc3 = (WC3)first;
|
||||
var wc3 = (WC3)first!;
|
||||
var info = new SimpleTrainerInfo(GameVersion.R);
|
||||
var pk = wc3.ConvertToPKM(info);
|
||||
|
||||
|
@ -84,7 +84,7 @@ namespace PKHeX.Tests.Simulator
|
|||
var first = encs.FirstOrDefault();
|
||||
Assert.NotNull(first);
|
||||
|
||||
var enc = first;
|
||||
var enc = first!;
|
||||
var info = new SimpleTrainerInfo(GameVersion.SN);
|
||||
var pk = enc.ConvertToPKM(info);
|
||||
|
||||
|
@ -136,7 +136,7 @@ namespace PKHeX.Tests.Simulator
|
|||
var first = encs.FirstOrDefault();
|
||||
Assert.NotNull(first);
|
||||
|
||||
var enc = first;
|
||||
var enc = first!;
|
||||
var info = new SimpleTrainerInfo(GameVersion.SN);
|
||||
var pk = enc.ConvertToPKM(info);
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.IO;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace PKHeX.Tests
|
||||
{
|
||||
|
@ -8,7 +9,12 @@ namespace PKHeX.Tests
|
|||
{
|
||||
var folder = Directory.GetCurrentDirectory();
|
||||
while (!folder.EndsWith(nameof(Tests)))
|
||||
folder = Directory.GetParent(folder).FullName;
|
||||
{
|
||||
var dir = Directory.GetParent(folder);
|
||||
if (dir == null)
|
||||
throw new ArgumentNullException(nameof(dir));
|
||||
folder = dir.FullName;
|
||||
}
|
||||
return folder;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue