2017-06-18 04:49:14 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows.Forms;
|
2019-09-29 16:47:06 +00:00
|
|
|
|
using PKHeX.Drawing;
|
2017-06-18 04:49:14 +00:00
|
|
|
|
using PKHeX.WinForms.Properties;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX.WinForms.Controls
|
|
|
|
|
{
|
|
|
|
|
public partial class ShinyLeaf : UserControl
|
|
|
|
|
{
|
|
|
|
|
public ShinyLeaf()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2019-10-02 01:12:08 +00:00
|
|
|
|
Flags = new[] { CHK_1, CHK_2, CHK_3, CHK_4, CHK_5, CHK_C };
|
2017-06-18 04:49:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private readonly CheckBox[] Flags;
|
|
|
|
|
|
2019-10-02 01:12:08 +00:00
|
|
|
|
public void CheckAll(bool all = true) => SetValue(all ? 0b00111111 : 0);
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2019-10-02 01:12:08 +00:00
|
|
|
|
public int GetValue()
|
|
|
|
|
{
|
|
|
|
|
int value = 0;
|
|
|
|
|
for (int i = 0; i < Flags.Length; i++)
|
2017-06-18 04:49:14 +00:00
|
|
|
|
{
|
2019-10-02 01:12:08 +00:00
|
|
|
|
if (Flags[i].Checked)
|
|
|
|
|
value |= 1 << i;
|
2017-06-18 04:49:14 +00:00
|
|
|
|
}
|
2019-10-02 01:12:08 +00:00
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetValue(int value)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < Flags.Length; i++)
|
|
|
|
|
Flags[i].Checked = (value >> i & 1) == 1;
|
2017-06-18 04:49:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateFlagState(object sender, EventArgs e)
|
|
|
|
|
{
|
2020-12-23 05:24:41 +00:00
|
|
|
|
if (sender is not CheckBox c)
|
2017-06-18 04:49:14 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2019-10-02 01:12:08 +00:00
|
|
|
|
Image resource;
|
2017-06-18 04:49:14 +00:00
|
|
|
|
if (CHK_C == c)
|
2018-07-27 02:34:27 +00:00
|
|
|
|
{
|
2019-10-02 01:12:08 +00:00
|
|
|
|
resource = Resources.crown;
|
2018-07-27 02:34:27 +00:00
|
|
|
|
}
|
2017-06-18 04:49:14 +00:00
|
|
|
|
else
|
2017-06-18 05:16:24 +00:00
|
|
|
|
{
|
2019-10-02 01:12:08 +00:00
|
|
|
|
resource = Resources.leaf;
|
2017-06-18 05:16:24 +00:00
|
|
|
|
if (!c.Checked)
|
|
|
|
|
CHK_C.Checked = CHK_C.Enabled = false;
|
|
|
|
|
else if (Flags.Take(5).All(z => z.Checked))
|
|
|
|
|
CHK_C.Enabled = true;
|
|
|
|
|
}
|
2019-10-02 01:12:08 +00:00
|
|
|
|
if (!c.Checked)
|
|
|
|
|
resource = ImageUtil.ChangeOpacity(resource, 0.4);
|
|
|
|
|
c.Image = resource;
|
2017-06-18 04:49:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|