Handle more messages

un-nest some classes, tooltip/menu disposing
This commit is contained in:
Kurt 2019-10-27 20:39:07 -07:00
parent 9fa36a98cb
commit a6b6383538
15 changed files with 320 additions and 278 deletions

View file

@ -16,7 +16,7 @@ namespace PKHeX.Core
/// <see cref="Apply"/>
public sealed class StringInstruction
{
public string PropertyName { get; private set; }
public string PropertyName { get; }
public string PropertyValue { get; private set; }
public bool Evaluator { get; private set; }

View file

@ -75,6 +75,8 @@ namespace PKHeX.Core
/// </summary>
Headbutt = 1 << 11,
Headbutt_Special = Headbutt | Special,
/// <summary>
/// Slot is encountered via the Poké Radar.
/// </summary>
@ -105,9 +107,6 @@ namespace PKHeX.Core
/// </summary>
Safari = 1 << 30, // always used as a modifier to another slot type
// Combined
Headbutt_Special = Headbutt | Special,
Grass_Safari = Grass | Safari,
Surf_Safari = Surf | Safari,
Old_Rod_Safari = Old_Rod | Safari,

View file

@ -551,9 +551,8 @@ namespace PKHeX.Core
if (CardID == 2046) // Greninja WC has variant PID and can arrive @ 36 or 37
return pkm.SM; // not USUM
if (PIDType == 0 && pkm.PID != PID)
return false;
return true;
return PIDType != 0 || pkm.PID == PID;
}
protected override bool IsMatchDeferred(PKM pkm)

View file

@ -156,196 +156,6 @@ namespace PKHeX.Core
public Tile[] Tiles { get; }
public TileMap Map { get; }
public sealed class Tile
{
internal const int SIZE_TILE = 0x20;
private const int TileWidth = 8;
private const int TileHeight = 8;
internal readonly int[] ColorChoices;
private byte[] PixelData;
private byte[]? PixelDataX;
private byte[]? PixelDataY;
internal Tile() : this(new byte[SIZE_TILE]) { }
internal Tile(byte[] data)
{
if (data.Length != SIZE_TILE)
throw new ArgumentException(nameof(data));
ColorChoices = new int[TileWidth * TileHeight];
for (int i = 0; i < data.Length; i++)
{
var ofs = i * 2;
ColorChoices[ofs + 0] = data[i] & 0xF;
ColorChoices[ofs + 1] = data[i] >> 4;
}
PixelData = Array.Empty<byte>();
}
internal void SetTile(int[] Palette) => PixelData = GetTileData(Palette);
private byte[] GetTileData(IReadOnlyList<int> Palette)
{
const int pixels = TileWidth * TileHeight;
byte[] data = new byte[pixels * 4];
for (int i = 0; i < pixels; i++)
{
var choice = ColorChoices[i];
var val = Palette[choice];
var o = 4 * i;
data[o + 0] = (byte)(val & 0xFF);
data[o + 1] = (byte)(val >> 8 & 0xFF);
data[o + 2] = (byte)(val >> 16 & 0xFF);
data[o + 3] = (byte)(val >> 24 & 0xFF);
}
return data;
}
internal byte[] Write()
{
byte[] data = new byte[SIZE_TILE];
for (int i = 0; i < data.Length; i++)
{
var ofs = i * 2;
data[i] |= (byte)(ColorChoices[ofs+0] & 0xF);
data[i] |= (byte)((ColorChoices[ofs+1] & 0xF) << 4);
}
return data;
}
public byte[] Rotate(int rotFlip)
{
if (rotFlip == 0)
return PixelData;
if ((rotFlip & 4) > 0)
return PixelDataX ??= FlipX(PixelData, TileWidth);
if ((rotFlip & 8) > 0)
return PixelDataY ??= FlipY(PixelData, TileHeight);
return PixelData;
}
private static byte[] FlipX(IReadOnlyList<byte> data, int width, int bpp = 4)
{
byte[] result = new byte[data.Count];
int pixels = data.Count / bpp;
for (int i = 0; i < pixels; i++)
{
int x = i % width;
int y = i / width;
x = width - x - 1; // flip x
int dest = ((y * width) + x) * bpp;
var o = 4 * i;
result[dest + 0] = data[o + 0];
result[dest + 1] = data[o + 1];
result[dest + 2] = data[o + 2];
result[dest + 3] = data[o + 3];
}
return result;
}
private static byte[] FlipY(IReadOnlyList<byte> data, int height, int bpp = 4)
{
byte[] result = new byte[data.Count];
int pixels = data.Count / bpp;
int width = pixels / height;
for (int i = 0; i < pixels; i++)
{
int x = i % width;
int y = i / width;
y = height - y - 1; // flip x
int dest = ((y * width) + x) * bpp;
var o = 4 * i;
result[dest + 0] = data[o + 0];
result[dest + 1] = data[o + 1];
result[dest + 2] = data[o + 2];
result[dest + 3] = data[o + 3];
}
return result;
}
internal int GetRotationValue(int[] tileColors)
{
// Check all rotation types
if (ColorChoices.SequenceEqual(tileColors))
return 0;
if (IsMirrorX(tileColors))
return 4;
if (IsMirrorY(tileColors))
return 8;
if (IsMirrorXY(tileColors))
return 12;
return -1;
}
private bool IsMirrorX(int[] tileColors)
{
for (int i = 0; i < 64; i++)
{
if (ColorChoices[(7 - (i & 7)) + (8 * (i / 8))] != tileColors[i])
return false;
}
return true;
}
private bool IsMirrorY(int[] tileColors)
{
for (int i = 0; i < 64; i++)
{
if (ColorChoices[64 - (8 * (1 + (i / 8))) + (i & 7)] != tileColors[i])
return false;
}
return true;
}
private bool IsMirrorXY(int[] tileColors)
{
for (int i = 0; i < 64; i++)
{
if (ColorChoices[63 - i] != tileColors[i])
return false;
}
return true;
}
}
public sealed class TileMap
{
public readonly int[] TileChoices;
public readonly int[] Rotations;
internal TileMap(byte[] data)
{
TileChoices = new int[data.Length/2];
Rotations = new int[data.Length/2];
for (int i = 0; i < data.Length; i += 2)
{
TileChoices[i/2] = data[i];
Rotations[i/2] = data[i+1];
}
}
internal byte[] Write()
{
byte[] data = new byte[TileChoices.Length * 2];
for (int i = 0; i < data.Length; i += 2)
{
data[i] = (byte)TileChoices[i/2];
data[i+1] = (byte)Rotations[i/2];
}
return data;
}
}
private static int ValToIndex(int val)
{
if ((val & 0x3FF) < 0xA0 || (val & 0x3FF) > 0x280)
@ -515,4 +325,194 @@ namespace PKHeX.Core
return data;
}
}
public sealed class Tile
{
internal const int SIZE_TILE = 0x20;
private const int TileWidth = 8;
private const int TileHeight = 8;
internal readonly int[] ColorChoices;
private byte[] PixelData;
private byte[]? PixelDataX;
private byte[]? PixelDataY;
internal Tile() : this(new byte[SIZE_TILE]) { }
internal Tile(byte[] data)
{
if (data.Length != SIZE_TILE)
throw new ArgumentException(nameof(data));
ColorChoices = new int[TileWidth * TileHeight];
for (int i = 0; i < data.Length; i++)
{
var ofs = i * 2;
ColorChoices[ofs + 0] = data[i] & 0xF;
ColorChoices[ofs + 1] = data[i] >> 4;
}
PixelData = Array.Empty<byte>();
}
internal void SetTile(int[] Palette) => PixelData = GetTileData(Palette);
private byte[] GetTileData(IReadOnlyList<int> Palette)
{
const int pixels = TileWidth * TileHeight;
byte[] data = new byte[pixels * 4];
for (int i = 0; i < pixels; i++)
{
var choice = ColorChoices[i];
var val = Palette[choice];
var o = 4 * i;
data[o + 0] = (byte)(val & 0xFF);
data[o + 1] = (byte)(val >> 8 & 0xFF);
data[o + 2] = (byte)(val >> 16 & 0xFF);
data[o + 3] = (byte)(val >> 24 & 0xFF);
}
return data;
}
internal byte[] Write()
{
byte[] data = new byte[SIZE_TILE];
for (int i = 0; i < data.Length; i++)
{
var ofs = i * 2;
data[i] |= (byte)(ColorChoices[ofs + 0] & 0xF);
data[i] |= (byte)((ColorChoices[ofs + 1] & 0xF) << 4);
}
return data;
}
public byte[] Rotate(int rotFlip)
{
if (rotFlip == 0)
return PixelData;
if ((rotFlip & 4) > 0)
return PixelDataX ??= FlipX(PixelData, TileWidth);
if ((rotFlip & 8) > 0)
return PixelDataY ??= FlipY(PixelData, TileHeight);
return PixelData;
}
private static byte[] FlipX(IReadOnlyList<byte> data, int width, int bpp = 4)
{
byte[] result = new byte[data.Count];
int pixels = data.Count / bpp;
for (int i = 0; i < pixels; i++)
{
int x = i % width;
int y = i / width;
x = width - x - 1; // flip x
int dest = ((y * width) + x) * bpp;
var o = 4 * i;
result[dest + 0] = data[o + 0];
result[dest + 1] = data[o + 1];
result[dest + 2] = data[o + 2];
result[dest + 3] = data[o + 3];
}
return result;
}
private static byte[] FlipY(IReadOnlyList<byte> data, int height, int bpp = 4)
{
byte[] result = new byte[data.Count];
int pixels = data.Count / bpp;
int width = pixels / height;
for (int i = 0; i < pixels; i++)
{
int x = i % width;
int y = i / width;
y = height - y - 1; // flip x
int dest = ((y * width) + x) * bpp;
var o = 4 * i;
result[dest + 0] = data[o + 0];
result[dest + 1] = data[o + 1];
result[dest + 2] = data[o + 2];
result[dest + 3] = data[o + 3];
}
return result;
}
internal int GetRotationValue(int[] tileColors)
{
// Check all rotation types
if (ColorChoices.SequenceEqual(tileColors))
return 0;
if (IsMirrorX(tileColors))
return 4;
if (IsMirrorY(tileColors))
return 8;
if (IsMirrorXY(tileColors))
return 12;
return -1;
}
private bool IsMirrorX(int[] tileColors)
{
for (int i = 0; i < 64; i++)
{
if (ColorChoices[(7 - (i & 7)) + (8 * (i / 8))] != tileColors[i])
return false;
}
return true;
}
private bool IsMirrorY(int[] tileColors)
{
for (int i = 0; i < 64; i++)
{
if (ColorChoices[64 - (8 * (1 + (i / 8))) + (i & 7)] != tileColors[i])
return false;
}
return true;
}
private bool IsMirrorXY(int[] tileColors)
{
for (int i = 0; i < 64; i++)
{
if (ColorChoices[63 - i] != tileColors[i])
return false;
}
return true;
}
}
public sealed class TileMap
{
public readonly int[] TileChoices;
public readonly int[] Rotations;
internal TileMap(byte[] data)
{
TileChoices = new int[data.Length / 2];
Rotations = new int[data.Length / 2];
for (int i = 0; i < data.Length; i += 2)
{
TileChoices[i / 2] = data[i];
Rotations[i / 2] = data[i + 1];
}
}
internal byte[] Write()
{
byte[] data = new byte[TileChoices.Length * 2];
for (int i = 0; i < data.Length; i += 2)
{
data[i] = (byte)TileChoices[i / 2];
data[i + 1] = (byte)Rotations[i / 2];
}
return data;
}
}
}

View file

@ -10,21 +10,6 @@ namespace PKHeX.Core
private const int FashionLength = 0x1A08;
// Every fashion item is 2 bits, New Flag (high) & Owned Flag (low)
public sealed class FashionItem7
{
public bool IsOwned { get; set; }
public bool IsNew { get; set; }
public FashionItem7(byte b)
{
IsOwned = (b & 1) != 0;
IsNew = (b & 2) != 0;
}
public byte Value => (byte)((IsOwned ? 1 : 0) | (IsNew ? 2 : 0));
}
public FashionItem7[] Wardrobe
{
get
@ -59,4 +44,19 @@ namespace PKHeX.Core
SAV.Data[Offset + ofs] = 3; // owned | new
}
}
// Every fashion item is 2 bits, New Flag (high) & Owned Flag (low)
public sealed class FashionItem7
{
public bool IsOwned { get; set; }
public bool IsNew { get; set; }
public FashionItem7(byte b)
{
IsOwned = (b & 1) != 0;
IsNew = (b & 2) != 0;
}
public byte Value => (byte)((IsOwned ? 1 : 0) | (IsNew ? 2 : 0));
}
}

View file

@ -29,6 +29,7 @@
public void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.Menu_File = new System.Windows.Forms.ToolStripMenuItem();
this.Menu_Open = new System.Windows.Forms.ToolStripMenuItem();
@ -66,6 +67,7 @@
this.L_UpdateAvailable = new System.Windows.Forms.LinkLabel();
this.C_SAV = new PKHeX.WinForms.Controls.SAVEditor();
this.PKME_Tabs = new PKHeX.WinForms.Controls.PKMEditor();
this.dragTip = new System.Windows.Forms.ToolTip(this.components);
this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dragout)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.PB_Legal)).BeginInit();
@ -101,7 +103,7 @@
this.Menu_Open.Name = "Menu_Open";
this.Menu_Open.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
this.Menu_Open.ShowShortcutKeys = false;
this.Menu_Open.Size = new System.Drawing.Size(180, 22);
this.Menu_Open.Size = new System.Drawing.Size(139, 22);
this.Menu_Open.Text = "&Open...";
this.Menu_Open.Click += new System.EventHandler(this.MainMenuOpen);
//
@ -111,7 +113,7 @@
this.Menu_Save.Name = "Menu_Save";
this.Menu_Save.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
this.Menu_Save.ShowShortcutKeys = false;
this.Menu_Save.Size = new System.Drawing.Size(180, 22);
this.Menu_Save.Size = new System.Drawing.Size(139, 22);
this.Menu_Save.Text = "&Save PKM...";
this.Menu_Save.Click += new System.EventHandler(this.MainMenuSave);
//
@ -123,7 +125,7 @@
this.Menu_ExportSAV.Enabled = false;
this.Menu_ExportSAV.Image = global::PKHeX.WinForms.Properties.Resources.saveSAV;
this.Menu_ExportSAV.Name = "Menu_ExportSAV";
this.Menu_ExportSAV.Size = new System.Drawing.Size(180, 22);
this.Menu_ExportSAV.Size = new System.Drawing.Size(139, 22);
this.Menu_ExportSAV.Text = "&Export SAV...";
//
// Menu_ExportMAIN
@ -132,7 +134,7 @@
this.Menu_ExportMAIN.Name = "Menu_ExportMAIN";
this.Menu_ExportMAIN.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.E)));
this.Menu_ExportMAIN.ShowShortcutKeys = false;
this.Menu_ExportMAIN.Size = new System.Drawing.Size(180, 22);
this.Menu_ExportMAIN.Size = new System.Drawing.Size(142, 22);
this.Menu_ExportMAIN.Text = "&Export main";
this.Menu_ExportMAIN.Click += new System.EventHandler(this.ClickExportSAV);
//
@ -142,7 +144,7 @@
this.Menu_ExportBAK.Name = "Menu_ExportBAK";
this.Menu_ExportBAK.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.B)));
this.Menu_ExportBAK.ShowShortcutKeys = false;
this.Menu_ExportBAK.Size = new System.Drawing.Size(180, 22);
this.Menu_ExportBAK.Size = new System.Drawing.Size(142, 22);
this.Menu_ExportBAK.Text = "Export &Backup";
this.Menu_ExportBAK.Click += new System.EventHandler(this.ClickExportSAVBAK);
//
@ -152,7 +154,7 @@
this.Menu_Exit.Name = "Menu_Exit";
this.Menu_Exit.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Q)));
this.Menu_Exit.ShowShortcutKeys = false;
this.Menu_Exit.Size = new System.Drawing.Size(180, 22);
this.Menu_Exit.Size = new System.Drawing.Size(139, 22);
this.Menu_Exit.Text = "&Quit";
this.Menu_Exit.Click += new System.EventHandler(this.MainMenuExit);
//
@ -176,7 +178,7 @@
this.Menu_ShowdownExportCurrentBox});
this.Menu_Showdown.Image = global::PKHeX.WinForms.Properties.Resources.showdown;
this.Menu_Showdown.Name = "Menu_Showdown";
this.Menu_Showdown.Size = new System.Drawing.Size(180, 22);
this.Menu_Showdown.Size = new System.Drawing.Size(133, 22);
this.Menu_Showdown.Text = "Showdown";
//
// Menu_ShowdownImportPKM
@ -237,7 +239,7 @@
this.Menu_BatchEditor});
this.Menu_Data.Image = global::PKHeX.WinForms.Properties.Resources.data;
this.Menu_Data.Name = "Menu_Data";
this.Menu_Data.Size = new System.Drawing.Size(180, 22);
this.Menu_Data.Size = new System.Drawing.Size(133, 22);
this.Menu_Data.Text = "Data";
//
// Menu_LoadBoxes
@ -320,7 +322,7 @@
this.Menu_Folder.Name = "Menu_Folder";
this.Menu_Folder.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F)));
this.Menu_Folder.ShowShortcutKeys = false;
this.Menu_Folder.Size = new System.Drawing.Size(180, 22);
this.Menu_Folder.Size = new System.Drawing.Size(133, 22);
this.Menu_Folder.Text = "Open Folder";
this.Menu_Folder.Click += new System.EventHandler(this.MainMenuFolder);
//
@ -342,7 +344,7 @@
this.CB_MainLanguage});
this.Menu_Language.Image = global::PKHeX.WinForms.Properties.Resources.language;
this.Menu_Language.Name = "Menu_Language";
this.Menu_Language.Size = new System.Drawing.Size(180, 22);
this.Menu_Language.Size = new System.Drawing.Size(164, 22);
this.Menu_Language.Text = "Language";
//
// CB_MainLanguage
@ -359,7 +361,7 @@
this.Menu_Undo.Name = "Menu_Undo";
this.Menu_Undo.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.U)));
this.Menu_Undo.ShowShortcutKeys = false;
this.Menu_Undo.Size = new System.Drawing.Size(180, 22);
this.Menu_Undo.Size = new System.Drawing.Size(164, 22);
this.Menu_Undo.Text = "Undo Last Change";
this.Menu_Undo.Click += new System.EventHandler(this.ClickUndo);
//
@ -370,7 +372,7 @@
this.Menu_Redo.Name = "Menu_Redo";
this.Menu_Redo.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Y)));
this.Menu_Redo.ShowShortcutKeys = false;
this.Menu_Redo.Size = new System.Drawing.Size(180, 22);
this.Menu_Redo.Size = new System.Drawing.Size(164, 22);
this.Menu_Redo.Text = "Redo Last Change";
this.Menu_Redo.Click += new System.EventHandler(this.ClickRedo);
//
@ -381,7 +383,7 @@
this.Menu_Settings.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.S)));
this.Menu_Settings.ShowShortcutKeys = false;
this.Menu_Settings.Size = new System.Drawing.Size(180, 22);
this.Menu_Settings.Size = new System.Drawing.Size(164, 22);
this.Menu_Settings.Text = "Settings";
this.Menu_Settings.Click += new System.EventHandler(this.MainMenuSettings);
//
@ -391,7 +393,7 @@
this.Menu_About.Name = "Menu_About";
this.Menu_About.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.P)));
this.Menu_About.ShowShortcutKeys = false;
this.Menu_About.Size = new System.Drawing.Size(180, 22);
this.Menu_About.Size = new System.Drawing.Size(164, 22);
this.Menu_About.Text = "About &PKHeX";
this.Menu_About.Click += new System.EventHandler(this.MainMenuAbout);
//
@ -534,6 +536,7 @@
private System.Windows.Forms.ToolStripMenuItem Menu_Settings;
private System.Windows.Forms.ToolStripMenuItem Menu_ShowdownExportCurrentBox;
private System.Windows.Forms.ToolStripMenuItem Menu_EncDatabase;
private System.Windows.Forms.ToolTip dragTip;
}
}

View file

@ -153,7 +153,7 @@ namespace PKHeX.WinForms
C_SAV.EnableDragDrop(Main_DragEnter, Main_DragDrop);
// ToolTips for Drag&Drop
new ToolTip().SetToolTip(dragout, "PKM QuickSave");
dragTip.SetToolTip(dragout, "PKM QuickSave");
// Box to Tabs D&D
dragout.AllowDrop = true;

View file

@ -27,7 +27,6 @@ namespace PKHeX.WinForms
InitializeComponent();
WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
mnu.Items.AddRange(new ToolStripItem[] { mnuView, mnuDelete });
SAV = saveditor.SAV;
BoxView = saveditor;
@ -53,6 +52,7 @@ namespace PKHeX.WinForms
}
};
slot.ContextMenuStrip = mnu;
if (Settings.Default.HoverSlotShowText)
slot.MouseEnter += ShowHoverTextForSlot;
}
@ -62,10 +62,6 @@ namespace PKHeX.WinForms
L_Viewed.Text = string.Empty; // invisible for now
PopulateComboBoxes();
// Assign to datagridview
foreach (PictureBox p in PKXBOXES)
p.ContextMenuStrip = mnu;
// Load Data
B_Search.Enabled = false;
L_Count.Text = "Loading...";

View file

@ -61,9 +61,12 @@
this.TypeFilters = new System.Windows.Forms.FlowLayoutPanel();
this.RTB_Instructions = new System.Windows.Forms.RichTextBox();
this.hover = new System.Windows.Forms.ToolTip(this.components);
this.mnu = new System.Windows.Forms.ContextMenuStrip(this.components);
this.mnuView = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.P_Results.SuspendLayout();
this.TLP_Filters.SuspendLayout();
this.mnu.SuspendLayout();
this.SuspendLayout();
//
// SCR_Box
@ -441,6 +444,21 @@
this.RTB_Instructions.TabIndex = 119;
this.RTB_Instructions.Text = "";
//
// mnu
//
this.mnu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.mnuView});
this.mnu.Name = "contextMenuStrip1";
this.mnu.Size = new System.Drawing.Size(181, 48);
//
// mnuView
//
this.mnuView.Image = global::PKHeX.WinForms.Properties.Resources.other;
this.mnuView.Name = "mnuView";
this.mnuView.Size = new System.Drawing.Size(180, 22);
this.mnuView.Text = "View";
this.mnuView.Click += new System.EventHandler(this.ClickView);
//
// SAV_Encounters
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -468,6 +486,7 @@
this.P_Results.ResumeLayout(false);
this.TLP_Filters.ResumeLayout(false);
this.TLP_Filters.PerformLayout();
this.mnu.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@ -507,5 +526,7 @@
private Controls.PokeGrid pokeGrid1;
private System.Windows.Forms.FlowLayoutPanel TypeFilters;
private System.Windows.Forms.ToolTip hover;
private System.Windows.Forms.ContextMenuStrip mnu;
private System.Windows.Forms.ToolStripMenuItem mnuView;
}
}

View file

@ -23,11 +23,6 @@ namespace PKHeX.WinForms
{
InitializeComponent();
ToolStripMenuItem mnuView = new ToolStripMenuItem {Name = "mnuView", Text = "View", Image = Resources.other };
ContextMenuStrip mnu = new ContextMenuStrip();
mnu.Items.AddRange(new ToolStripItem[] { mnuView });
PKME_Tabs = f1;
pokeGrid1.InitializeGrid(6, 11);
@ -43,6 +38,7 @@ namespace PKHeX.WinForms
if (ModifierKeys == Keys.Control)
ClickView(sender, e);
};
slot.ContextMenuStrip = mnu;
}
Counter = L_Count.Text;
@ -50,15 +46,6 @@ namespace PKHeX.WinForms
L_Viewed.MouseEnter += (sender, e) => hover.SetToolTip(L_Viewed, L_Viewed.Text);
PopulateComboBoxes();
// Assign event handlers
mnuView.Click += ClickView;
// Add to main context menu
// Assign to datagridview
foreach (PictureBox p in PKXBOXES)
p.ContextMenuStrip = mnu;
WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
GetTypeFilters();

View file

@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.SCR_Box = new System.Windows.Forms.VScrollBar();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.Menu_Close = new System.Windows.Forms.ToolStripMenuItem();
@ -39,6 +40,7 @@
this.Menu_Export = new System.Windows.Forms.ToolStripMenuItem();
this.Menu_Import = new System.Windows.Forms.ToolStripMenuItem();
this.P_Results = new System.Windows.Forms.Panel();
this.pokeGrid1 = new PKHeX.WinForms.Controls.PokeGrid();
this.CB_HeldItem = new System.Windows.Forms.ComboBox();
this.CB_Species = new System.Windows.Forms.ComboBox();
this.CB_Move4 = new System.Windows.Forms.ComboBox();
@ -65,12 +67,17 @@
this.L_Format = new System.Windows.Forms.Label();
this.FLP_Level = new System.Windows.Forms.FlowLayoutPanel();
this.RTB_Instructions = new System.Windows.Forms.RichTextBox();
this.pokeGrid1 = new PKHeX.WinForms.Controls.PokeGrid();
this.mnu = new System.Windows.Forms.ContextMenuStrip(this.components);
this.mnuView = new System.Windows.Forms.ToolStripMenuItem();
this.mnuSaveMG = new System.Windows.Forms.ToolStripMenuItem();
this.mnuSavePK = new System.Windows.Forms.ToolStripMenuItem();
this.hover = new System.Windows.Forms.ToolTip(this.components);
this.menuStrip1.SuspendLayout();
this.P_Results.SuspendLayout();
this.FLP_Egg.SuspendLayout();
this.TLP_Filters.SuspendLayout();
this.FLP_Format.SuspendLayout();
this.mnu.SuspendLayout();
this.SuspendLayout();
//
// SCR_Box
@ -178,6 +185,15 @@
this.P_Results.Size = new System.Drawing.Size(285, 352);
this.P_Results.TabIndex = 66;
//
// pokeGrid1
//
this.pokeGrid1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.pokeGrid1.Location = new System.Drawing.Point(2, 2);
this.pokeGrid1.Margin = new System.Windows.Forms.Padding(0);
this.pokeGrid1.Name = "pokeGrid1";
this.pokeGrid1.Size = new System.Drawing.Size(251, 346);
this.pokeGrid1.TabIndex = 2;
//
// CB_HeldItem
//
this.CB_HeldItem.Anchor = System.Windows.Forms.AnchorStyles.Left;
@ -535,13 +551,38 @@
this.RTB_Instructions.TabIndex = 119;
this.RTB_Instructions.Text = "";
//
// pokeGrid1
// mnu
//
this.pokeGrid1.Location = new System.Drawing.Point(2, 2);
this.pokeGrid1.Margin = new System.Windows.Forms.Padding(0);
this.pokeGrid1.Name = "pokeGrid1";
this.pokeGrid1.Size = new System.Drawing.Size(251, 346);
this.pokeGrid1.TabIndex = 2;
this.mnu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.mnuView,
this.mnuSaveMG,
this.mnuSavePK});
this.mnu.Name = "contextMenuStrip1";
this.mnu.Size = new System.Drawing.Size(127, 70);
//
// mnuView
//
this.mnuView.Image = global::PKHeX.WinForms.Properties.Resources.other;
this.mnuView.Name = "mnuView";
this.mnuView.Size = new System.Drawing.Size(126, 22);
this.mnuView.Text = "View";
this.mnuView.Click += new System.EventHandler(this.ClickView);
//
// mnuSaveMG
//
this.mnuSaveMG.Image = global::PKHeX.WinForms.Properties.Resources.gift;
this.mnuSaveMG.Name = "mnuSaveMG";
this.mnuSaveMG.Size = new System.Drawing.Size(126, 22);
this.mnuSaveMG.Text = "Save Gift";
this.mnuSaveMG.Click += new System.EventHandler(this.ClickSaveMG);
//
// mnuSavePK
//
this.mnuSavePK.Image = global::PKHeX.WinForms.Properties.Resources.savePKM;
this.mnuSavePK.Name = "mnuSavePK";
this.mnuSavePK.Size = new System.Drawing.Size(126, 22);
this.mnuSavePK.Text = "Save PKM";
this.mnuSavePK.Click += new System.EventHandler(this.ClickSavePK);
//
// SAV_MysteryGiftDB
//
@ -573,6 +614,7 @@
this.TLP_Filters.ResumeLayout(false);
this.TLP_Filters.PerformLayout();
this.FLP_Format.ResumeLayout(false);
this.mnu.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@ -618,5 +660,10 @@
private System.Windows.Forms.ToolStripMenuItem Menu_SearchAdvanced;
private System.Windows.Forms.ToolStripMenuItem Menu_Import;
private Controls.PokeGrid pokeGrid1;
private System.Windows.Forms.ContextMenuStrip mnu;
private System.Windows.Forms.ToolStripMenuItem mnuView;
private System.Windows.Forms.ToolStripMenuItem mnuSaveMG;
private System.Windows.Forms.ToolStripMenuItem mnuSavePK;
private System.Windows.Forms.ToolTip hover;
}
}

View file

@ -24,13 +24,7 @@ namespace PKHeX.WinForms
{
InitializeComponent();
ToolStripMenuItem mnuView = new ToolStripMenuItem { Name = "mnuView", Text = "View", Image = Resources.other };
ToolStripMenuItem mnuSaveMG = new ToolStripMenuItem { Name = "mnuSaveMG", Text = "Save Gift", Image = Resources.gift };
ToolStripMenuItem mnuSavePK = new ToolStripMenuItem { Name = "mnuSavePK", Text = "Save PKM", Image = Resources.savePKM };
WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
ContextMenuStrip mnu = new ContextMenuStrip();
mnu.Items.AddRange(new ToolStripItem[] { mnuView, mnuSaveMG, mnuSavePK });
SAV = sav.SAV;
BoxView = sav;
@ -52,23 +46,15 @@ namespace PKHeX.WinForms
if (ModifierKeys == Keys.Control)
ClickView(sender, e);
};
slot.ContextMenuStrip = mnu;
}
Counter = L_Count.Text;
Viewed = L_Viewed.Text;
L_Viewed.Text = string.Empty; // invis for now
var hover = new ToolTip();
L_Viewed.MouseEnter += (sender, e) => hover.SetToolTip(L_Viewed, L_Viewed.Text);
// Assign event handlers
mnuView.Click += ClickView;
mnuSaveMG.Click += ClickSaveMG;
mnuSavePK.Click += ClickSavePK;
// Assign to datagridview
foreach (PictureBox p in PKXBOXES)
p.ContextMenuStrip = mnu;
// Load Data
B_Search.Enabled = false;
L_Count.Text = "Loading...";

View file

@ -28,12 +28,15 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.dgv = new System.Windows.Forms.DataGridView();
this.B_Save = new System.Windows.Forms.Button();
this.B_Cancel = new System.Windows.Forms.Button();
this.B_All = new System.Windows.Forms.Button();
this.B_Sort = new System.Windows.Forms.Button();
this.B_None = new System.Windows.Forms.Button();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.toolTip2 = new System.Windows.Forms.ToolTip(this.components);
((System.ComponentModel.ISupportInitialize)(this.dgv)).BeginInit();
this.SuspendLayout();
//
@ -144,5 +147,7 @@
private System.Windows.Forms.Button B_All;
private System.Windows.Forms.Button B_Sort;
private System.Windows.Forms.Button B_None;
private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.ToolTip toolTip2;
}
}

View file

@ -19,8 +19,8 @@ namespace PKHeX.WinForms
Setup(puffs.Length);
LoadPuffs(puffs);
new ToolTip().SetToolTip(B_Sort, "Hold CTRL to reverse sort.");
new ToolTip().SetToolTip(B_All, "Hold CTRL to best instead of varied.");
toolTip1.SetToolTip(B_Sort, "Hold CTRL to reverse sort.");
toolTip2.SetToolTip(B_All, "Hold CTRL to best instead of varied.");
}
private readonly string[] pfa = GameInfo.Strings.puffs;

View file

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using PKHeX.Core;
@ -117,11 +116,11 @@ namespace PKHeX.WinForms
{
CB_AppearPKM1.Items.Clear();
CB_AppearPKM1.InitializeBinding();
CB_AppearPKM1.DataSource = new BindingSource(GameInfo.SpeciesDataSource.Where(id => id.Value <= sav.MaxSpeciesID).ToList(), null);
CB_AppearPKM1.DataSource = new BindingSource(GameInfo.FilteredSources.Species.ToList(), null);
}
else if (Gen == 4 || Gen == 5)
{
var species = GameInfo.SpeciesDataSource.Where(id => id.Value <= sav.MaxSpeciesID).ToList();
var species = GameInfo.FilteredSources.Species.ToList();
foreach (ComboBox a in AppearPKMs)
{
a.Items.Clear();
@ -138,13 +137,13 @@ namespace PKHeX.WinForms
new ComboItem("Platinum", (int)GameVersion.Pt),
new ComboItem("HeartGold", (int)GameVersion.HG),
new ComboItem("SoulSilver", (int)GameVersion.SS),
}.ToList()
}
: new[] {
new ComboItem("Black", (int)GameVersion.B),
new ComboItem("White", (int)GameVersion.W),
new ComboItem("Black2", (int)GameVersion.B2),
new ComboItem("White2", (int)GameVersion.W2),
}.ToList(), null);
}, null);
CB_AuthorLang.Items.Clear();
CB_AuthorLang.InitializeBinding();
@ -157,7 +156,7 @@ namespace PKHeX.WinForms
new ComboItem("GER", 5),
new ComboItem("ESP", 7),
new ComboItem("KOR", 8),
}.ToList(), null);
}, null);
}
var ItemList = GameInfo.Strings.GetItemStrings(Gen, SAV.Version);
@ -574,7 +573,7 @@ namespace PKHeX.WinForms
private void LoadOTlabel()
{
Label_OTGender.Text = gendersymbols[LabelValue_GenderF ? 1 : 0];
Label_OTGender.ForeColor = LabelValue_GenderF ? Color.Red : Color.Blue;
Label_OTGender.ForeColor = Main.Draw.GetGenderColor(LabelValue_GenderF ? 1 : 0);
}
private void Label_OTGender_Click(object sender, EventArgs e)