Merge pull request #8 from SoujiSeta/master

Testing Pull Request to merge changes to help with mono compatibility.
This commit is contained in:
Kaphotics 2014-11-27 20:10:13 -08:00
commit da11afa639
4 changed files with 61 additions and 45 deletions

View file

@ -2770,7 +2770,7 @@ namespace PKHeX
} }
else if ((species == 521) && (gender == 1)) // Unfezant else if ((species == 521) && (gender == 1)) // Unfezant
{ {
file = file = "_" + species.ToString() + "f"; file = "_" + species.ToString() + "f";
} }
} }
if (species == 0) if (species == 0)

View file

@ -28,7 +28,7 @@ namespace PKHeX
{ {
if (m_parent.init) if (m_parent.init)
{ {
if (InvokeRequired) if (InvokeRequired && IsHandleCreated)
Invoke((MethodInvoker)delegate(){Close();}); Invoke((MethodInvoker)delegate(){Close();});
else else
Close(); Close();

View file

@ -188,60 +188,54 @@ namespace PKHeX
internal static int ToInt32(TextBox tb) internal static int ToInt32(TextBox tb)
{ {
string value = tb.Text; string value = tb.Text;
if (String.IsNullOrEmpty(value)) return ToInt32(value);
{ return 0; }
try
{ return Int32.Parse(value); }
catch
{ return 0; }
} }
internal static uint ToUInt32(TextBox tb) internal static uint ToUInt32(TextBox tb)
{ {
string value = tb.Text; string value = tb.Text;
if (String.IsNullOrEmpty(value)) return ToUInt32(value);
{ return 0; }
try
{ return UInt32.Parse(value); }
catch
{ return 0; }
} }
internal static int ToInt32(MaskedTextBox tb) internal static int ToInt32(MaskedTextBox tb)
{ {
string value = tb.Text; string value = tb.Text;
if (String.IsNullOrEmpty(value)) return ToInt32(value);
{ return 0; }
try
{ return Int32.Parse(value); }
catch
{ return 0; }
} }
internal static uint ToUInt32(MaskedTextBox tb) internal static uint ToUInt32(MaskedTextBox tb)
{ {
string value = tb.Text; string value = tb.Text;
if (String.IsNullOrEmpty(value)) return ToUInt32(value);
{ return 0; }
try
{ return UInt32.Parse(value); }
catch
{ return 0; }
} }
internal static int ToInt32(String value) internal static int ToInt32(String value)
{ {
if (String.IsNullOrEmpty(value)) if (String.IsNullOrEmpty(value))
{ return 0; } {
return 0;
}
try try
{ return Int32.Parse(value); } {
value = value.TrimEnd(new char[]{'_'});
return Int32.Parse(value);
}
catch catch
{ return 0; } {
return 0;
}
} }
internal static uint ToUInt32(String value) internal static uint ToUInt32(String value)
{ {
if (String.IsNullOrEmpty(value)) if (String.IsNullOrEmpty(value))
{ return 0; } {
return 0;
}
try try
{ return UInt32.Parse(value); } {
value = value.TrimEnd(new char[]{'_'});
return UInt32.Parse(value);
}
catch catch
{ return 0; } {
return 0;
}
} }
internal static uint getHEXval(TextBox tb) internal static uint getHEXval(TextBox tb)
{ {
@ -253,12 +247,20 @@ namespace PKHeX
internal static int getIndex(ComboBox cb) internal static int getIndex(ComboBox cb)
{ {
int val = 0; int val = 0;
try { val = Util.ToInt32(cb.SelectedValue.ToString()); } if (cb.SelectedValue == null)
{
return 0;
}
try
{
val = Util.ToInt32(cb.SelectedValue.ToString());
}
catch catch
{ {
val = cb.SelectedIndex; val = cb.SelectedIndex;
if (val < 0) val = 0; if (val < 0) val = 0;
}; }
return val; return val;
} }
internal static string getOnlyHex(string str) internal static string getOnlyHex(string str)

View file

@ -1481,9 +1481,15 @@ namespace PKHeX
origin_list.Add(item); origin_list.Add(item);
} }
CB_GameOrigin.DataSource = origin_list; /*
* Moving the assignment of the Display and ValueMemeber to before the DataSource is assigned
as assigning the DataSource causes a onSelectedIndexChanged which causes a call
to updateOriginGame which access the SelectedValue property, but since there is no
ValueMember assigned it uses the cbItem to string method which returns the Text member
*/
CB_GameOrigin.DisplayMember = "Text"; CB_GameOrigin.DisplayMember = "Text";
CB_GameOrigin.ValueMember = "Value"; CB_GameOrigin.ValueMember = "Value";
CB_GameOrigin.DataSource = origin_list;
#endregion #endregion
} }
@ -2789,7 +2795,10 @@ namespace PKHeX
int gameorigin = 0; int gameorigin = 0;
// Error handling for unset field // Error handling for unset field
try { gameorigin = Util.ToInt32(CB_GameOrigin.SelectedValue.ToString()); } try
{
gameorigin = Util.ToInt32(CB_GameOrigin.SelectedValue.ToString());
}
catch { gameorigin = 0; } catch { gameorigin = 0; }
if ((gameorigin <= 12) && (gameorigin >= 7)) if ((gameorigin <= 12) && (gameorigin >= 7))
@ -3980,7 +3989,7 @@ namespace PKHeX
}; };
for (int i = 0; i < cba.Length; i++) for (int i = 0; i < cba.Length; i++)
{ {
if (cba[i].BackColor != SystemColors.Window && cba[i].BackColor != Color.Empty) if (cba[i].BackColor != System.Drawing.SystemColors.Control && cba[i].BackColor != Color.Empty)
{ {
if (i < 6) // Main Tab if (i < 6) // Main Tab
tabMain.SelectedIndex = 0; tabMain.SelectedIndex = 0;
@ -6404,6 +6413,11 @@ namespace PKHeX
{ {
return Text; return Text;
} }
public int GetValue()
{
return Util.ToInt32 (Value.ToString());
}
} }
public class SaveGames public class SaveGames
{ {