PKHeX/PKHeX.WinForms/Subforms/Save Editors/SAV_BoxViewer.cs
Kurt 11b2dc35d7 Refactor main form into smaller pieces
pkm editor, sav editor, menus, and a manager to glue the storage slots
together
decouples the pkm/sav editors from a static savefile reference.

improves dragdrop/click view/set/delete indication, hides unavailable
contextmenuitems, and fixes a few incorrect references. Box Subviewer
slots now have all the indication/events that the main save editor slots
have.

pls report behavior bugs 👍
2017-05-22 21:55:12 -07:00

47 lines
1.6 KiB
C#

using System;
using System.Windows.Forms;
using PKHeX.WinForms.Controls;
namespace PKHeX.WinForms
{
public partial class SAV_BoxViewer : Form
{
private readonly SAVEditor parent;
public SAV_BoxViewer(SAVEditor p, SlotChangeManager m)
{
parent = p;
InitializeComponent();
Box.Setup(m);
CenterToParent();
AllowDrop = true;
GiveFeedback += (sender, e) => { e.UseDefaultCursors = false; };
DragEnter += tabMain_DragEnter;
DragDrop += (sender, e) =>
{
Cursor = DefaultCursor;
System.Media.SystemSounds.Asterisk.Play();
};
foreach (PictureBox pb in Box.SlotPictureBoxes)
pb.ContextMenuStrip = parent.SlotPictureBoxes[0].ContextMenuStrip;
}
public int CurrentBox => Box.CurrentBox;
private void PB_BoxSwap_Click(object sender, EventArgs e) => Box.CurrentBox = parent.swapBoxesViewer(Box.CurrentBox);
public void setPKXBoxes() => Box.ResetSlots();
private void tabMain_DragEnter(object sender, DragEventArgs e)
{
if (e.AllowedEffect == (DragDropEffects.Copy | DragDropEffects.Link)) // external file
e.Effect = DragDropEffects.Copy;
else if (e.Data != null) // within
e.Effect = DragDropEffects.Move;
}
private void SAV_BoxViewer_FormClosing(object sender, FormClosingEventArgs e)
{
// Remove viewer from manager list
Box.M.Boxes.Remove(Box);
}
}
}