2016-08-26 01:50:51 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Windows.Forms;
|
2019-08-21 02:50:28 +00:00
|
|
|
|
using PKHeX.Core;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
using PKHeX.WinForms.Controls;
|
2016-08-26 01:50:51 +00:00
|
|
|
|
|
2017-01-08 07:54:09 +00:00
|
|
|
|
namespace PKHeX.WinForms
|
2016-08-26 01:50:51 +00:00
|
|
|
|
{
|
2018-04-11 00:00:28 +00:00
|
|
|
|
public sealed partial class SAV_BoxViewer : Form
|
2016-08-26 01:50:51 +00:00
|
|
|
|
{
|
2017-05-23 04:55:05 +00:00
|
|
|
|
private readonly SAVEditor parent;
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2017-05-23 04:55:05 +00:00
|
|
|
|
public SAV_BoxViewer(SAVEditor p, SlotChangeManager m)
|
2016-08-26 01:50:51 +00:00
|
|
|
|
{
|
|
|
|
|
parent = p;
|
2017-05-23 04:55:05 +00:00
|
|
|
|
InitializeComponent();
|
2019-08-21 02:50:28 +00:00
|
|
|
|
Box.Editor = new BoxEdit(m.SE.SAV);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
Box.Setup(m);
|
2019-10-03 03:04:12 +00:00
|
|
|
|
Box.InitializeGrid();
|
2018-12-26 21:06:58 +00:00
|
|
|
|
Box.Reset();
|
2016-08-26 01:50:51 +00:00
|
|
|
|
CenterToParent();
|
|
|
|
|
|
|
|
|
|
AllowDrop = true;
|
2017-07-06 06:05:49 +00:00
|
|
|
|
GiveFeedback += (sender, e) => e.UseDefaultCursors = false;
|
2017-06-18 01:37:19 +00:00
|
|
|
|
DragEnter += Main_DragEnter;
|
2016-08-26 01:50:51 +00:00
|
|
|
|
DragDrop += (sender, e) =>
|
|
|
|
|
{
|
|
|
|
|
Cursor = DefaultCursor;
|
|
|
|
|
System.Media.SystemSounds.Asterisk.Play();
|
|
|
|
|
};
|
2018-01-23 06:39:12 +00:00
|
|
|
|
Owner = p.ParentForm;
|
2016-08-26 01:50:51 +00:00
|
|
|
|
|
2018-07-26 02:29:41 +00:00
|
|
|
|
MouseWheel += (s, e) =>
|
|
|
|
|
{
|
2018-08-15 02:39:14 +00:00
|
|
|
|
if (parent.menu.mnuVSD.Visible)
|
2018-08-12 18:01:21 +00:00
|
|
|
|
return;
|
2019-08-21 02:50:28 +00:00
|
|
|
|
Box.CurrentBox = e.Delta > 1 ? Box.Editor.MoveLeft() : Box.Editor.MoveRight();
|
2018-07-26 02:29:41 +00:00
|
|
|
|
};
|
|
|
|
|
|
2017-05-23 04:55:05 +00:00
|
|
|
|
foreach (PictureBox pb in Box.SlotPictureBoxes)
|
|
|
|
|
pb.ContextMenuStrip = parent.SlotPictureBoxes[0].ContextMenuStrip;
|
2018-12-26 21:06:58 +00:00
|
|
|
|
Box.ResetBoxNames(); // fix box names
|
|
|
|
|
Box.ResetSlots(); // refresh box background
|
2019-09-03 02:30:58 +00:00
|
|
|
|
p.EditEnv.Slots.Publisher.Subscribers.Add(Box);
|
2016-08-26 01:50:51 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2017-05-23 04:55:05 +00:00
|
|
|
|
public int CurrentBox => Box.CurrentBox;
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void PB_BoxSwap_Click(object sender, EventArgs e) => Box.CurrentBox = parent.SwapBoxesViewer(Box.CurrentBox);
|
2016-08-26 01:50:51 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private static void Main_DragEnter(object sender, DragEventArgs e)
|
2016-08-26 01:50:51 +00:00
|
|
|
|
{
|
|
|
|
|
if (e.AllowedEffect == (DragDropEffects.Copy | DragDropEffects.Link)) // external file
|
|
|
|
|
e.Effect = DragDropEffects.Copy;
|
|
|
|
|
else if (e.Data != null) // within
|
|
|
|
|
e.Effect = DragDropEffects.Move;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-23 04:55:05 +00:00
|
|
|
|
private void SAV_BoxViewer_FormClosing(object sender, FormClosingEventArgs e)
|
2016-08-26 01:50:51 +00:00
|
|
|
|
{
|
2017-05-23 04:55:05 +00:00
|
|
|
|
// Remove viewer from manager list
|
|
|
|
|
Box.M.Boxes.Remove(Box);
|
2019-09-03 02:30:58 +00:00
|
|
|
|
parent.EditEnv.Slots.Publisher.Subscribers.Remove(Box);
|
2016-08-26 01:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|