Add alt/shift click

Shift click setting is not accessible without the hotkey, not going to
add it as a Right Click Menu.

Main had to expose more methods (to access info from tabs); standardized
all references to the database path as well.
This commit is contained in:
Kurt 2015-11-14 19:41:39 -08:00
parent dc5fc1f175
commit f3ea73787b
2 changed files with 43 additions and 7 deletions

View file

@ -206,6 +206,7 @@ namespace PKHeX
public static int colorizedslot;
public static int largeWidth, shortWidth;
public static string eggname = "";
public static string DatabasePath = "db";
public static string[] lang_val = { "en", "ja", "fr", "it", "de", "es", "ko", "zh", "pt" };
public static string[] main_langlist =
{
@ -408,17 +409,16 @@ namespace PKHeX
{
DialogResult dr = Util.Prompt(MessageBoxButtons.YesNoCancel, "Press Yes to Import All from Folder." + Environment.NewLine + "Press No to Dump All to Folder.", "Press Cancel to Abort.");
if (dr == DialogResult.Cancel) return;
string exepath = Application.StartupPath;
string path = "";
bool dumptoboxes = false;
{
if (dr == DialogResult.Yes) // Import
{
if (Directory.Exists(Path.Combine(exepath, "db")))
if (Directory.Exists(DatabasePath))
{
DialogResult ld = Util.Prompt(MessageBoxButtons.YesNo, "Load from PKHeX's database?");
if (ld == DialogResult.Yes)
path = Path.Combine(exepath, "db");
path = DatabasePath;
else if (ld == DialogResult.No)
{
// open folder dialog
@ -443,7 +443,7 @@ namespace PKHeX
DialogResult ld = Util.Prompt(MessageBoxButtons.YesNo, "Save to PKHeX's database?");
if (ld == DialogResult.Yes)
{
path = Path.Combine(exepath, "db");
path = DatabasePath;
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
}
@ -2140,7 +2140,7 @@ namespace PKHeX
TB_Friendship.Text = (pk6.CurrentHandler == 0 ? pk6.OT_Friendship : pk6.HT_Friendship).ToString();
}
// Open/Save Array Manipulation //
private bool verifiedPKX()
public bool verifiedPKX()
{
if (ModifierKeys == (Keys.Control | Keys.Shift | Keys.Alt))
return true; // Override
@ -2178,7 +2178,7 @@ namespace PKHeX
invalid:
{ System.Media.SystemSounds.Exclamation.Play(); return false; }
}
private byte[] preparepkx(bool click = true)
public byte[] preparepkx(bool click = true)
{
if (click)
tabMain.Select(); // hack to make sure comboboxes are set (users scrolling through and immediately setting causes this)

View file

@ -50,6 +50,10 @@ namespace PKHeX
{
if (ModifierKeys == Keys.Control)
clickView(sender, args);
else if (ModifierKeys == Keys.Alt)
clickDelete(sender, args);
else if (ModifierKeys == Keys.Shift)
clickSet(sender, args);
};
}
@ -103,7 +107,7 @@ namespace PKHeX
}
private Main m_parent;
private PictureBox[] PKXBOXES;
private const string DatabasePath = "db";
private string DatabasePath = Main.DatabasePath;
private List<DatabaseList> Database = new List<DatabaseList>();
private List<PK6> Results;
private List<PK6> RawDB;
@ -179,9 +183,41 @@ namespace PKHeX
RawDB.Remove(pk);
Results.Remove(pk);
// Refresh database view.
L_Count.Text = String.Format(Counter, Results.Count);
FillPKXBoxes(SCR_Box.Value);
System.Media.SystemSounds.Asterisk.Play();
}
}
private void clickSet(object sender, EventArgs e)
{
// Don't care what slot was clicked, just add it to the database
if (!m_parent.verifiedPKX())
return;
PK6 pk = new PK6(m_parent.preparepkx());
if (!Directory.Exists(DatabasePath))
Directory.CreateDirectory(DatabasePath);
string path = Path.Combine(DatabasePath, Util.CleanFileName(pk.FileName));
if (RawDB.Any(p => p.Identifier == path))
{
Util.Alert("File already exists in database!");
return;
}
File.WriteAllBytes(path, pk.Data.Take(PK6.SIZE_STORED).ToArray());
pk.Identifier = path;
RawDB.Add(pk);
RawDB = new List<PK6>(RawDB.Distinct()); // just in case
Results.Add(pk);
Results = new List<PK6>(Results.Distinct()); // just in case
// Refresh database view.
L_Count.Text = String.Format(Counter, Results.Count);
FillPKXBoxes(SCR_Box.Value);
Util.Alert("Added Pokémon from tabs to database", "Please refresh the search to ensure it shows up; it may be at the bottom of the results.");
}
private void populateComboBoxes()
{
// Set the Text