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
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
namespace PKHeX.WinForms;
|
|
|
|
|
|
|
|
|
|
public sealed partial class SAV_BoxViewer : Form
|
2016-08-26 01:50:51 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
private readonly SAVEditor parent;
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public SAV_BoxViewer(SAVEditor p, SlotChangeManager m)
|
|
|
|
|
{
|
|
|
|
|
parent = p;
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
int deltaW = Width - Box.BoxPokeGrid.Width;
|
|
|
|
|
int deltaH = Height - Box.BoxPokeGrid.Height;
|
|
|
|
|
Box.Editor = new BoxEdit(m.SE.SAV);
|
|
|
|
|
Box.Setup(m);
|
|
|
|
|
Box.InitializeGrid();
|
2019-11-16 01:34:18 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
Width = Box.BoxPokeGrid.Width + deltaW + 2;
|
|
|
|
|
Height = Box.BoxPokeGrid.Height + deltaH + 2;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
Box.RecenterControls();
|
|
|
|
|
Box.HorizontallyCenter(this);
|
|
|
|
|
Box.Reset();
|
|
|
|
|
CenterToParent();
|
2016-08-26 01:50:51 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
AllowDrop = true;
|
|
|
|
|
GiveFeedback += (sender, e) => e.UseDefaultCursors = false;
|
|
|
|
|
DragEnter += Main_DragEnter;
|
|
|
|
|
DragDrop += (sender, e) =>
|
|
|
|
|
{
|
|
|
|
|
Cursor = DefaultCursor;
|
|
|
|
|
System.Media.SystemSounds.Asterisk.Play();
|
|
|
|
|
};
|
|
|
|
|
Owner = p.ParentForm;
|
2016-08-26 01:50:51 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
MouseWheel += (s, e) =>
|
|
|
|
|
{
|
|
|
|
|
if (parent.menu.mnuVSD.Visible)
|
|
|
|
|
return;
|
|
|
|
|
Box.CurrentBox = e.Delta > 1 ? Box.Editor.MoveLeft() : Box.Editor.MoveRight();
|
|
|
|
|
};
|
2018-07-26 02:29:41 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
foreach (PictureBox pb in Box.SlotPictureBoxes)
|
|
|
|
|
pb.ContextMenuStrip = parent.SlotPictureBoxes[0].ContextMenuStrip;
|
|
|
|
|
Box.ResetBoxNames(); // fix box names
|
|
|
|
|
Box.ResetSlots(); // refresh box background
|
|
|
|
|
p.EditEnv.Slots.Publisher.Subscribers.Add(Box);
|
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public int CurrentBox => Box.CurrentBox;
|
|
|
|
|
private void PB_BoxSwap_Click(object sender, EventArgs e) => Box.CurrentBox = parent.SwapBoxesViewer(Box.CurrentBox);
|
2016-08-26 01:50:51 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
private static void Main_DragEnter(object? sender, DragEventArgs? e)
|
|
|
|
|
{
|
|
|
|
|
if (e is null)
|
|
|
|
|
return;
|
|
|
|
|
if (e.AllowedEffect == (DragDropEffects.Copy | DragDropEffects.Link)) // external file
|
|
|
|
|
e.Effect = DragDropEffects.Copy;
|
|
|
|
|
else if (e.Data != null) // within
|
|
|
|
|
e.Effect = DragDropEffects.Move;
|
|
|
|
|
}
|
2016-08-26 01:50:51 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
private void SAV_BoxViewer_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Remove viewer from manager list
|
|
|
|
|
Box.M?.Boxes.Remove(Box);
|
|
|
|
|
parent.EditEnv.Slots.Publisher.Subscribers.Remove(Box);
|
2016-08-26 01:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|