2022-06-18 18:04:24 +00:00
|
|
|
using System;
|
2018-09-30 17:16:45 +00:00
|
|
|
using System.Windows.Forms;
|
|
|
|
using PKHeX.Core;
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
namespace PKHeX.WinForms.Controls;
|
|
|
|
|
|
|
|
public partial class CatchRate : UserControl
|
2018-09-30 17:16:45 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
private PK1? Entity;
|
|
|
|
public CatchRate() => InitializeComponent();
|
|
|
|
|
2024-01-04 07:06:09 +00:00
|
|
|
public void LoadPK1(PK1 pk) => NUD_CatchRate.Value = (Entity = pk).CatchRate;
|
2022-06-18 18:04:24 +00:00
|
|
|
|
|
|
|
private void ChangeValue(object sender, EventArgs e)
|
2018-09-30 17:16:45 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
if (Entity is null)
|
|
|
|
return;
|
2024-01-04 07:06:09 +00:00
|
|
|
Entity.CatchRate = (byte)NUD_CatchRate.Value;
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
2018-09-30 17:16:45 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
private void Clear(object sender, EventArgs e) => NUD_CatchRate.Value = 0;
|
2018-09-30 17:16:45 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
private void Reset(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
if (Entity is null)
|
|
|
|
return;
|
|
|
|
var sav = WinFormsUtil.FindFirstControlOfType<IMainEditor>(this)?.RequestSaveFile;
|
|
|
|
if (sav == null)
|
|
|
|
return;
|
|
|
|
NUD_CatchRate.Value = CatchRateApplicator.GetSuggestedCatchRate(Entity, sav);
|
2018-09-30 17:16:45 +00:00
|
|
|
}
|
|
|
|
}
|