Misc clean / xmldoc updates

remove unused label in QR (use window Font)
escape & -> & for xmldoc proper style
This commit is contained in:
Kurt 2018-07-21 19:20:11 -07:00
parent 1c49b0681d
commit 0c5c9bc33c
22 changed files with 170 additions and 129 deletions

View File

@ -14,7 +14,10 @@ public class ShowdownSet
private static readonly string[] genderForms = {"", "F", ""};
private static readonly string[] StatNames = { "HP", "Atk", "Def", "SpA", "SpD", "Spe" };
private static readonly string[] Splitters = {"\r\n", "\n"};
private static readonly string[] StatSplitters = { " / ", " " };
private static readonly string[] LineSplit = {": "};
private static readonly string[] ItemSplit = {" @ "};
private static readonly int[] DashedSpecies = {784, 250, 032, 029}; // Kommo-o, Ho-Oh, Nidoran-M, Nidoran-F
private static int MAX_SPECIES => PKX.Personal.MaxSpeciesID;
private const string Language = "en";
private const int DefaultLanguageID = 2;
@ -353,7 +356,7 @@ private void ParseFirstLine(string first)
{
if (first.Contains(" @ "))
{
string[] pieces = first.Split(new[] { " @ " }, StringSplitOptions.None);
string[] pieces = first.Split(ItemSplit, StringSplitOptions.None);
string itemstr = pieces.Last().Trim();
ParseItemStr(itemstr);
@ -418,8 +421,7 @@ private bool ParseSpeciesForm(string spec)
return true;
// failure to parse, check edge cases
var edge = new[] {784, 250, 032, 029}; // all species with dashes in English Name (Kommo-o, Ho-Oh, Nidoran-M, Nidoran-F)
foreach (var e in edge)
foreach (var e in DashedSpecies)
{
if (!spec.StartsWith(Strings.Species[e].Replace("♂", "-M").Replace("♀", "-F")))
continue;
@ -477,7 +479,6 @@ private string ParseLineMove(string line)
type = ReplaceAll(type, string.Empty, "[", "]", "(", ")"); // Trim out excess data
int hpVal = Array.IndexOf(Strings.types, type) - 1; // Get HP Type
if (IVs.Any(z => z != 31))
{
if (!HiddenPower.SetIVsForType(hpVal, IVs, Format))
@ -492,17 +493,18 @@ private string ParseLineMove(string line)
}
private void ParseLineEVs(string line)
{
string[] evlist = SplitLineStats(line);
var evlist = SplitLineStats(line);
if (evlist.Length == 1)
InvalidLines.Add("Unknown EV input.");
for (int i = 0; i < evlist.Length / 2; i++)
{
bool valid = ushort.TryParse(evlist[i * 2 + 0], out ushort EV);
int index = Array.IndexOf(StatNames, evlist[i * 2 + 1]);
int pos = i * 2;
bool valid = ushort.TryParse(evlist[pos + 0], out ushort EV);
int index = Array.IndexOf(StatNames, evlist[pos + 1]);
if (valid && index > -1)
EVs[index] = EV;
else
InvalidLines.Add($"Unknown EV Type input: {evlist[i * 2]}");
InvalidLines.Add($"Unknown EV Type input: {evlist[pos]}");
}
EVs = EVsSpeedFirst;
}
@ -608,7 +610,7 @@ private static string[] SplitLineStats(string line)
return line
.Replace("SAtk", "SpA").Replace("Sp Atk", "SpA")
.Replace("SDef", "SpD").Replace("Sp Def", "SpD")
.Replace("Spd", "Spe").Replace("Speed", "Spe").Split(new[] { " / ", " " }, StringSplitOptions.None);
.Replace("Spd", "Spe").Replace("Speed", "Spe").Split(StatSplitters, StringSplitOptions.None);
}
private static string ReplaceAll(string original, string to, params string[] toBeReplaced)
{

View File

@ -60,7 +60,6 @@ public static string[] GetStrings(string ident, string lang, string type = "text
public static IReadOnlyList<ComboItem> MoveDataSource => Strings.MoveDataSource;
public static IReadOnlyList<ComboItem> LanguageDataSource(int gen) => GameStrings.LanguageDataSource(gen);
/// <summary>
/// Gets Country and Region strings for corresponding IDs and language.
/// </summary>

View File

@ -166,11 +166,14 @@ private byte[] Write()
/// <summary>
/// The date the Pokémon was met.
/// </summary>
/// <returns>A DateTime representing the date the Pokémon was met, or null if either the <see cref="PKM"/> format does not support dates or the stored date is invalid.</returns>
/// <remarks>Not all <see cref="PKM"/> types support the <see cref="MetDate"/> property. In these cases, this property will return null.
///
/// If null is assigned to this property, it will be cleared.</remarks>
public virtual DateTime? MetDate
/// <returns>
/// A DateTime representing the date the Pokémon was met.
/// Returns null if either the <see cref="PKM"/> format does not support dates or the stored date is invalid.</returns>
/// <remarks>
/// Not all <see cref="PKM"/> types support the <see cref="MetDate"/> property. In these cases, this property will return null.
/// If null is assigned to this property, it will be cleared.
/// </remarks>
public DateTime? MetDate
{
get
{
@ -206,11 +209,14 @@ private byte[] Write()
/// <summary>
/// The date a Pokémon was met as an egg.
/// </summary>
/// <returns>A DateTime representing the date the Pokémon was met as an egg, or null if the <see cref="PKM"/> format does not support dates.</returns>
/// <remarks>Not all <see cref="PKM"/> types support the <see cref="EggMetDate"/> property. In these cases, this property will return null.
///
/// If null is assigned to this property, it will be cleared.</remarks>
public virtual DateTime? EggMetDate
/// <returns>
/// A DateTime representing the date the Pokémon was met as an egg.
/// Returns null if either the <see cref="PKM"/> format does not support dates or the stored date is invalid.</returns>
/// <remarks>
/// Not all <see cref="PKM"/> types support the <see cref="EggMetDate"/> property. In these cases, this property will return null.
/// If null is assigned to this property, it will be cleared.
/// </remarks>
public DateTime? EggMetDate
{
get
{

View File

@ -1,7 +1,7 @@
namespace PKHeX.Core
{
/// <summary>
/// <see cref="PersonalInfo"/> class with values from the Black 2 & White 2 games.
/// <see cref="PersonalInfo"/> class with values from the Black 2 &amp; White 2 games.
/// </summary>
public class PersonalInfoB2W2 : PersonalInfoBW
{

View File

@ -3,7 +3,7 @@
namespace PKHeX.Core
{
/// <summary>
/// <see cref="PersonalInfo"/> class with values from the Black & White games.
/// <see cref="PersonalInfo"/> class with values from the Black &amp; White games.
/// </summary>
public class PersonalInfoBW : PersonalInfo
{

View File

@ -1,7 +1,7 @@
namespace PKHeX.Core
{
/// <summary>
/// <see cref="PersonalInfo"/> class with values from the OR & AS games.
/// <see cref="PersonalInfo"/> class with values from the OR &amp; AS games.
/// </summary>
public class PersonalInfoORAS : PersonalInfoXY
{

View File

@ -3,7 +3,7 @@
namespace PKHeX.Core
{
/// <summary>
/// <see cref="PersonalInfo"/> class with values from the Sun/Moon games.
/// <see cref="PersonalInfo"/> class with values from the Sun &amp; Moon games.
/// </summary>
public class PersonalInfoSM : PersonalInfoXY
{

View File

@ -1,7 +1,7 @@
namespace PKHeX.Core
{
/// <summary>
/// <see cref="PersonalInfo"/> class with values from the X & Y games.
/// <see cref="PersonalInfo"/> class with values from the X &amp; Y games.
/// </summary>
public class PersonalInfoXY : PersonalInfoBW
{

View File

@ -518,7 +518,6 @@ public override void SetDaycareRNGSeed(int loc, string seed)
}
}
// Storage
public override int PartyCount
{

View File

@ -1139,6 +1139,7 @@ public static IEnumerable<byte[]> GetXorpadsFromFiles(IEnumerable<string> files)
yield return xorpad;
}
}
/// <summary>
/// Decrypts an input array with a xorpad.
/// </summary>
@ -1149,15 +1150,17 @@ public static void DecryptFromXorpad(IList<byte> input, IReadOnlyList<byte> xorp
for (int z = 0; z < input.Count; z++)
input[z] ^= xorpad[z];
}
/// <summary>
/// Gets the "main" save file from an input data array.
/// </summary>
/// <param name="input">Input data array</param>
/// <param name="shift">Offset shift to rip from</param>
/// <returns>Output data array containing raw save data</returns>
public static byte[] GetMainFromSaveContainer(byte[] input)
public static byte[] GetMainFromSaveContainer(byte[] input, int shift = 0)
{
// Check the validity of the decrypted content by finding the checksum block
const int mainOffset = 0x5400;
int mainOffset = 0x5400 + shift;
foreach (int size in mainSizes.OrderByDescending(z => z))
{
int chkBlockOffset = mainOffset + size - 0x1F0;

View File

@ -521,22 +521,14 @@ private bool TryLoadXorpadSAV(byte[] input, string path)
DialogResult sdr = WinFormsUtil.Prompt(MessageBoxButtons.YesNoCancel, MsgFileLoadXorpad1, MsgFileLoadXorpad2);
if (sdr == DialogResult.Cancel)
return true;
int savshift = sdr == DialogResult.Yes ? 0 : 0x7F000;
byte[] psdata = input.Skip(0x5400 + savshift).Take(SaveUtil.SIZE_G6ORAS).ToArray();
var psdata = SaveUtil.GetMainFromSaveContainer(input, savshift);
if (psdata != null)
return TryLoadSAV(psdata, path);
if (BitConverter.ToUInt32(psdata, SaveUtil.SIZE_G6ORAS - 0x1F0) == SaveUtil.BEEF)
Array.Resize(ref psdata, SaveUtil.SIZE_G6ORAS); // set to ORAS size
else if (BitConverter.ToUInt32(psdata, SaveUtil.SIZE_G6XY - 0x1F0) == SaveUtil.BEEF)
Array.Resize(ref psdata, SaveUtil.SIZE_G6XY); // set to X/Y size
else if (BitConverter.ToUInt32(psdata, SaveUtil.SIZE_G7SM - 0x1F0) == SaveUtil.BEEF)
Array.Resize(ref psdata, SaveUtil.SIZE_G7SM); // set to S/M size
else
{
WinFormsUtil.Error(MsgFileLoadSaveFail, path);
return true;
}
return TryLoadSAV(psdata, path);
WinFormsUtil.Error(MsgFileLoadSaveFail, path);
return true;
}
private bool TryLoadSAV(byte[] input, string path)
{

View File

@ -34,47 +34,36 @@ protected override void Dispose(bool disposing)
/// </summary>
private void InitializeComponent()
{
ComponentResourceManager resources = new ComponentResourceManager(typeof(QR));
this.PB_QR = new PictureBox();
this.FontLabel = new Label();
this.NUD_Box = new NumericUpDown();
this.label1 = new Label();
this.label2 = new Label();
this.NUD_Slot = new NumericUpDown();
this.label3 = new Label();
this.NUD_Copies = new NumericUpDown();
this.B_Refresh = new Button();
((ISupportInitialize)(this.PB_QR)).BeginInit();
((ISupportInitialize)(this.NUD_Box)).BeginInit();
((ISupportInitialize)(this.NUD_Slot)).BeginInit();
((ISupportInitialize)(this.NUD_Copies)).BeginInit();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(QR));
this.PB_QR = new System.Windows.Forms.PictureBox();
this.NUD_Box = new System.Windows.Forms.NumericUpDown();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.NUD_Slot = new System.Windows.Forms.NumericUpDown();
this.label3 = new System.Windows.Forms.Label();
this.NUD_Copies = new System.Windows.Forms.NumericUpDown();
this.B_Refresh = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.PB_QR)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_Box)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_Slot)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_Copies)).BeginInit();
this.SuspendLayout();
//
// PB_QR
//
this.PB_QR.Anchor = ((AnchorStyles)(((AnchorStyles.Top | AnchorStyles.Left)
| AnchorStyles.Right)));
this.PB_QR.BackgroundImageLayout = ImageLayout.None;
this.PB_QR.Location = new Point(2, 1);
this.PB_QR.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.PB_QR.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.PB_QR.Location = new System.Drawing.Point(2, 1);
this.PB_QR.Name = "PB_QR";
this.PB_QR.Size = new Size(405, 455);
this.PB_QR.Size = new System.Drawing.Size(405, 455);
this.PB_QR.TabIndex = 0;
this.PB_QR.TabStop = false;
this.PB_QR.Click += new EventHandler(this.PB_QR_Click);
//
// FontLabel
//
this.FontLabel.AutoSize = true;
this.FontLabel.Location = new Point(388, 393);
this.FontLabel.Name = "FontLabel";
this.FontLabel.Size = new Size(19, 13);
this.FontLabel.TabIndex = 1;
this.FontLabel.Text = "<3";
this.FontLabel.Visible = false;
this.PB_QR.Click += new System.EventHandler(this.PB_QR_Click);
//
// NUD_Box
//
this.NUD_Box.Location = new Point(38, 465);
this.NUD_Box.Location = new System.Drawing.Point(38, 465);
this.NUD_Box.Maximum = new decimal(new int[] {
32,
0,
@ -86,7 +75,7 @@ private void InitializeComponent()
0,
0});
this.NUD_Box.Name = "NUD_Box";
this.NUD_Box.Size = new Size(61, 20);
this.NUD_Box.Size = new System.Drawing.Size(61, 20);
this.NUD_Box.TabIndex = 2;
this.NUD_Box.Value = new decimal(new int[] {
1,
@ -97,24 +86,24 @@ private void InitializeComponent()
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new Point(4, 467);
this.label1.Location = new System.Drawing.Point(4, 467);
this.label1.Name = "label1";
this.label1.Size = new Size(28, 13);
this.label1.Size = new System.Drawing.Size(28, 13);
this.label1.TabIndex = 3;
this.label1.Text = "Box:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new Point(105, 467);
this.label2.Location = new System.Drawing.Point(105, 467);
this.label2.Name = "label2";
this.label2.Size = new Size(28, 13);
this.label2.Size = new System.Drawing.Size(28, 13);
this.label2.TabIndex = 5;
this.label2.Text = "Slot:";
//
// NUD_Slot
//
this.NUD_Slot.Location = new Point(139, 465);
this.NUD_Slot.Location = new System.Drawing.Point(139, 465);
this.NUD_Slot.Maximum = new decimal(new int[] {
30,
0,
@ -126,7 +115,7 @@ private void InitializeComponent()
0,
0});
this.NUD_Slot.Name = "NUD_Slot";
this.NUD_Slot.Size = new Size(61, 20);
this.NUD_Slot.Size = new System.Drawing.Size(61, 20);
this.NUD_Slot.TabIndex = 4;
this.NUD_Slot.Value = new decimal(new int[] {
1,
@ -137,15 +126,15 @@ private void InitializeComponent()
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new Point(211, 467);
this.label3.Location = new System.Drawing.Point(211, 467);
this.label3.Name = "label3";
this.label3.Size = new Size(42, 13);
this.label3.Size = new System.Drawing.Size(42, 13);
this.label3.TabIndex = 7;
this.label3.Text = "Copies:";
//
// NUD_Copies
//
this.NUD_Copies.Location = new Point(259, 465);
this.NUD_Copies.Location = new System.Drawing.Point(259, 465);
this.NUD_Copies.Maximum = new decimal(new int[] {
960,
0,
@ -157,7 +146,7 @@ private void InitializeComponent()
0,
0});
this.NUD_Copies.Name = "NUD_Copies";
this.NUD_Copies.Size = new Size(52, 20);
this.NUD_Copies.Size = new System.Drawing.Size(52, 20);
this.NUD_Copies.TabIndex = 6;
this.NUD_Copies.Value = new decimal(new int[] {
1,
@ -167,19 +156,19 @@ private void InitializeComponent()
//
// B_Refresh
//
this.B_Refresh.Location = new Point(317, 464);
this.B_Refresh.Location = new System.Drawing.Point(317, 464);
this.B_Refresh.Name = "B_Refresh";
this.B_Refresh.Size = new Size(80, 23);
this.B_Refresh.Size = new System.Drawing.Size(80, 23);
this.B_Refresh.TabIndex = 8;
this.B_Refresh.Text = "Refresh";
this.B_Refresh.UseVisualStyleBackColor = true;
this.B_Refresh.Click += new EventHandler(this.UpdateBoxSlotCopies);
this.B_Refresh.Click += new System.EventHandler(this.UpdateBoxSlotCopies);
//
// QR
//
this.AutoScaleDimensions = new SizeF(6F, 13F);
this.AutoScaleMode = AutoScaleMode.Font;
this.ClientSize = new Size(409, 407);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(409, 407);
this.Controls.Add(this.B_Refresh);
this.Controls.Add(this.label3);
this.Controls.Add(this.NUD_Copies);
@ -187,19 +176,18 @@ private void InitializeComponent()
this.Controls.Add(this.NUD_Slot);
this.Controls.Add(this.label1);
this.Controls.Add(this.NUD_Box);
this.Controls.Add(this.FontLabel);
this.Controls.Add(this.PB_QR);
this.FormBorderStyle = FormBorderStyle.FixedSingle;
this.Icon = ((Icon)(resources.GetObject("$this.Icon")));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "QR";
this.StartPosition = FormStartPosition.CenterParent;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "PKHeX QR Code (Click QR to Copy Image)";
((ISupportInitialize)(this.PB_QR)).EndInit();
((ISupportInitialize)(this.NUD_Box)).EndInit();
((ISupportInitialize)(this.NUD_Slot)).EndInit();
((ISupportInitialize)(this.NUD_Copies)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.PB_QR)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_Box)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_Slot)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_Copies)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@ -208,7 +196,6 @@ private void InitializeComponent()
#endregion
private PictureBox PB_QR;
private Label FontLabel;
private NumericUpDown NUD_Box;
private Label label1;
private Label label2;

View File

@ -45,15 +45,22 @@ public QR(Image qr, Image icon, PKM pk, params string[] lines)
private void RefreshImage()
{
Font font = !Main.Unicode ? FontLabel.Font : FontUtil.GetPKXFont((float)8.25);
Font font = !Main.Unicode ? Font : FontUtil.GetPKXFont((float)8.25);
Image preview = new Bitmap(45, 45);
using (Graphics gfx = Graphics.FromImage(preview))
{
gfx.FillRectangle(new SolidBrush(Color.White), 0, 0, preview.Width, preview.Height);
gfx.DrawImage(icon, preview.Width / 2 - icon.Width / 2, preview.Height / 2 - icon.Height / 2);
int x = (preview.Width / 2) - (icon.Width / 2);
int y = (preview.Height / 2) - (icon.Height / 2);
gfx.DrawImage(icon, x, y);
}
// Layer on Preview Image
Image pic = ImageUtil.LayerImage(qr, preview, qr.Width / 2 - preview.Width / 2, qr.Height / 2 - preview.Height / 2);
Image pic;
{
int x = (qr.Width / 2) - (preview.Width / 2);
int y = (qr.Height / 2) - (preview.Height / 2);
pic = ImageUtil.LayerImage(qr, preview, x, y);
}
Image newpic = new Bitmap(PB_QR.Width, PB_QR.Height);
using (Graphics g = Graphics.FromImage(newpic))
@ -104,6 +111,7 @@ internal static byte[] GetQRData(string address)
try { return DecodeQRJson(data); }
catch (Exception e) { WinFormsUtil.Alert(MsgQRUrlFailConvert, e.Message); return null; }
}
private static byte[] DecodeQRJson(string data)
{
const string cap = "\",\"error\":null}]}]";
@ -184,10 +192,8 @@ public static string GetQRServer(int format)
{
switch (format)
{
case 6:
return QR6Path;
default:
return QR6PathBad;
case 6: return QR6Path;
default: return QR6PathBad;
}
}
}

View File

@ -55,12 +55,14 @@ private static bool CheckNETFramework()
Error("Your version of Mono needs to target the .NET Framework 4.6 or higher for this version of PKHeX to run.");
return false;
}
private static bool IsOnWindows()
{
// 4 -> UNIX, 6 -> Mac OSX, 128 -> UNIX (old)
int p = (int)Environment.OSVersion.Platform;
return p != 4 && p != 6 && p != 128;
}
private static int GetFrameworkVersion()
{
const string subkey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\";

View File

@ -19,6 +19,7 @@ public partial class SAV_Database : Form
private readonly SaveFile SAV;
private readonly SAVEditor BoxView;
private readonly PKMEditor PKME_Tabs;
public SAV_Database(PKMEditor f1, SAVEditor saveditor)
{
InitializeComponent();
@ -111,6 +112,7 @@ public SAV_Database(PKMEditor f1, SAVEditor saveditor)
private readonly string Viewed;
private const int MAXFORMAT = PKX.Generation;
private readonly string EXTERNAL_SAV = new DirectoryInfo(Main.BackupPath).Name + Path.DirectorySeparatorChar;
private static string Hash(PKM pk)
{
switch (pk.Format)
@ -144,6 +146,7 @@ private void ClickView(object sender, EventArgs e)
FillPKXBoxes(SCR_Box.Value);
L_Viewed.Text = string.Format(Viewed, Results[index].Identifier);
}
private void ClickDelete(object sender, EventArgs e)
{
sender = WinFormsUtil.GetUnderlyingControl(sender);
@ -201,6 +204,7 @@ private void ClickDelete(object sender, EventArgs e)
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
@ -239,6 +243,7 @@ private void ClickSet(object sender, EventArgs e)
FillPKXBoxes(SCR_Box.Value);
WinFormsUtil.Alert(MsgDBAddFromTabsSuccess);
}
private void PopulateComboBoxes()
{
// Set the Text
@ -284,6 +289,7 @@ private void PopulateComboBoxes()
// Trigger a Reset
ResetFilters(null, null);
}
private void ResetFilters(object sender, EventArgs e)
{
CHK_Shiny.Checked = CHK_IsEgg.Checked = true;
@ -311,6 +317,7 @@ private void ResetFilters(object sender, EventArgs e)
if (sender != null)
System.Media.SystemSounds.Asterisk.Play();
}
private void GenerateDBReport(object sender, EventArgs e)
{
if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgDBCreateReportPrompt, MsgDBCreateReportWarning)
@ -383,6 +390,7 @@ private void OpenDB(object sender, EventArgs e)
if (Directory.Exists(DatabasePath))
Process.Start("explorer.exe", DatabasePath);
}
private void Menu_Export_Click(object sender, EventArgs e)
{
if (Results == null || Results.Count == 0)
@ -401,6 +409,7 @@ private void Menu_Export_Click(object sender, EventArgs e)
foreach (PKM pkm in Results)
File.WriteAllBytes(Path.Combine(path, Util.CleanFileName(pkm.FileName)), pkm.DecryptedBoxData);
}
private void Menu_Import_Click(object sender, EventArgs e)
{
if (!BoxView.GetBulkImportSettings(out var clearAll, out var noSetb))
@ -559,6 +568,7 @@ private static IEnumerable<PKM> FilterByLVL(IEnumerable<PKM> res, int option, st
return res.Where(pk => pk.Stat_Level >= level);
}
}
private static IEnumerable<PKM> FilterByEVs(IEnumerable<PKM> res, int option)
{
switch (option)
@ -574,6 +584,7 @@ private static IEnumerable<PKM> FilterByEVs(IEnumerable<PKM> res, int option)
return res.Where(pk => pk.EVTotal >= 508);
}
}
private static IEnumerable<PKM> FilterByIVs(IEnumerable<PKM> res, int option)
{
switch (option)
@ -616,11 +627,13 @@ private async void B_Search_Click(object sender, EventArgs e)
System.Media.SystemSounds.Asterisk.Play();
B_Search.Enabled = true;
}
private void UpdateScroll(object sender, ScrollEventArgs e)
{
if (e.OldValue != e.NewValue)
FillPKXBoxes(e.NewValue);
}
private void SetResults(List<PKM> res)
{
Results = res;
@ -635,6 +648,7 @@ private void SetResults(List<PKM> res)
L_Count.Text = string.Format(Counter, Results.Count);
B_Search.Enabled = true;
}
private void FillPKXBoxes(int start)
{
if (Results == null)
@ -661,16 +675,19 @@ private void ToggleESV(object sender, EventArgs e)
{
L_ESV.Visible = MT_ESV.Visible = CHK_IsEgg.CheckState == CheckState.Checked;
}
private void ChangeLevel(object sender, EventArgs e)
{
if (CB_Level.SelectedIndex == 0)
TB_Level.Text = string.Empty;
}
private void ChangeGame(object sender, EventArgs e)
{
if (CB_GameOrigin.SelectedIndex != 0)
CB_Generation.SelectedIndex = 0;
}
private void ChangeGeneration(object sender, EventArgs e)
{
if (CB_Generation.SelectedIndex != 0)
@ -684,10 +701,8 @@ private void Menu_SearchAdvanced_Click(object sender, EventArgs e)
else Size = MaximumSize;
}
private void Menu_Exit_Click(object sender, EventArgs e)
{
Close();
}
private void Menu_Exit_Click(object sender, EventArgs e) => Close();
protected override void OnMouseWheel(MouseEventArgs e)
{
if (!PAN_Box.RectangleToScreen(PAN_Box.ClientRectangle).Contains(MousePosition))

View File

@ -11,6 +11,7 @@ public static Bitmap GetBitmap(CGearBackground bg)
{
return ImageUtil.GetBitmap(bg.GetImageData(), CGearBackground.Width, CGearBackground.Height);
}
public static CGearBackground GetCGearBackground(Bitmap img)
{
const int Width = CGearBackground.Width;

View File

@ -8,6 +8,7 @@ public partial class SAV_SimplePokedex : Form
{
private readonly SaveFile Origin;
private readonly SaveFile SAV;
public SAV_SimplePokedex(SaveFile sav)
{
InitializeComponent();

View File

@ -97,6 +97,7 @@ private static void UpdateTranslations()
private static void DumpStringsMessage() => DumpStrings(typeof(MessageStrings));
private static void DumpStringsLegality() => DumpStrings(typeof(LegalityCheckStrings));
private static void DumpStrings(Type t, bool sort = false)
{
var dir = GetResourcePath();

View File

@ -5,7 +5,7 @@ namespace QRCoder
{
using System;
public class QRCode : AbstractQRCode<Bitmap>, IDisposable
public sealed class QRCode : AbstractQRCode<Bitmap>, IDisposable
{
public QRCode(QRCodeData data) : base(data) {}

View File

@ -277,7 +277,7 @@ public static int MaskCode(ref QRCodeData qrCode, int version, ref List<Rectangl
}
var formatStr = GetFormatString(eccLevel, Convert.ToInt32((pattern.Name.Substring(7, 1)))-1);
var formatStr = GetFormatString(eccLevel, Convert.ToInt32(pattern.Name.Substring(7, 1))-1);
ModulePlacer.PlaceFormat(ref qrTemp, formatStr);
if (version >= 7)
{
@ -622,7 +622,6 @@ public static int Score(ref QRCodeData qrCode)
public static bool Pattern7(int x, int y) => (((x * y) % 2) + ((x * y) % 3)) % 2 == 0;
public static bool Pattern8(int x, int y) => (((x + y) % 2) + ((x * y) % 3)) % 2 == 0;
}
}
private List<string> CalculateECCWords(string bitString, ECCInfo eccInfo)
@ -662,11 +661,11 @@ private Polynom ConvertToAlphaNotation(Polynom poly)
{
var newPoly = new Polynom();
for (var i = 0; i < poly.PolyItems.Count; i++)
newPoly.PolyItems.Add(
new PolynomItem(
(poly.PolyItems[i].Coefficient != 0
? this.GetAlphaExpFromIntVal(poly.PolyItems[i].Coefficient)
: 0), poly.PolyItems[i].Exponent));
{
var coeff = poly.PolyItems[i].Coefficient != 0 ? GetAlphaExpFromIntVal(poly.PolyItems[i].Coefficient) : 0;
newPoly.PolyItems.Add(new PolynomItem(coeff, poly.PolyItems[i].Exponent));
}
return newPoly;
}
@ -824,7 +823,7 @@ private int GetDataLength(EncodingMode encoding, string plainText, string codedT
private bool IsUtf8(EncodingMode encoding, string plainText)
{
return (encoding == EncodingMode.Byte && !this.IsValidISO(plainText));
return encoding == EncodingMode.Byte && !this.IsValidISO(plainText);
}
private bool IsValidISO(string input)
@ -962,7 +961,7 @@ private Polynom MultiplyAlphaPolynoms(Polynom polynomBase, Polynom polynomMultip
var polItemRes = new PolynomItem
(
ShrinkAlphaExp(polItemBase.Coefficient + polItemMulti.Coefficient),
(polItemBase.Exponent + polItemMulti.Exponent)
polItemBase.Exponent + polItemMulti.Exponent
);
resultPolynom.PolyItems.Add(polItemRes);
}
@ -1299,7 +1298,7 @@ public override string ToString()
//this.PolyItems.ForEach(x => sb.Append("a^" + x.Coefficient + "*x^" + x.Exponent + " + "));
foreach (var polyItem in this.PolyItems)
{
sb.Append("a^" + polyItem.Coefficient + "*x^" + polyItem.Exponent + " + ");
sb.Append("a^").Append(polyItem.Coefficient).Append("*x^").Append(polyItem.Exponent).Append(" + ");
}
return sb.ToString().TrimEnd(new[] { ' ', '+' });

View File

@ -15,6 +15,7 @@ public void Initialize(SaveFile sav)
if (Game == GameVersion.FRLG)
Game = sav.Personal == PersonalTable.FR ? GameVersion.FR : GameVersion.LG;
}
private GameVersion Game;
private static int GetDeoxysForm(GameVersion game)
@ -94,7 +95,7 @@ private static Image LayerOverImageItem(Image baseImage, int item, int generatio
itemimg = Resources.item_tm;
// Redraw
int x = 22 + (15 - itemimg.Width) / 2;
int x = 22 + ((15 - itemimg.Width) / 2);
if (x + itemimg.Width > baseImage.Width)
x = baseImage.Width - itemimg.Width;
int y = 15 + (15 - itemimg.Height);
@ -103,7 +104,6 @@ private static Image LayerOverImageItem(Image baseImage, int item, int generatio
private static Image LayerOverImageShiny(Image baseImage, bool isBoxBGRed)
{
// Add shiny star to top left of image.
var rare = isBoxBGRed ? Resources.rare_icon_alt : Resources.rare_icon;
return ImageUtil.LayerImage(baseImage, rare, 0, 0, 0.7);

View File

@ -16,12 +16,13 @@ public static class WinFormsUtil
internal static void CenterToForm(this Control child, Control parent)
{
int x = parent.Location.X + (parent.Width - child.Width) / 2;
int y = parent.Location.Y + (parent.Height - child.Height) / 2;
int x = parent.Location.X + ((parent.Width - child.Width) / 2);
int y = parent.Location.Y + ((parent.Height - child.Height) / 2);
child.Location = new Point(Math.Max(x, 0), Math.Max(y, 0));
}
public static Form FirstFormOfType<T>(this Form f) => Array.Find(f.OwnedForms, form => form is T);
public static T FindFirstControlOfType<T>(Control aParent) where T : class
{
while (true)
@ -36,6 +37,7 @@ internal static void CenterToForm(this Control child, Control parent)
return null;
}
}
public static Control GetUnderlyingControl(object sender) => ((sender as ToolStripItem)?.Owner as ContextMenuStrip)?.SourceControl ?? sender as PictureBox;
#region Message Displays
@ -78,6 +80,10 @@ internal static DialogResult Prompt(MessageBoxButtons btn, params string[] lines
}
#endregion
/// <summary>
/// Gets the selected value of the input <see cref="cb"/>. If no value is selected, will return 0.
/// </summary>
/// <param name="cb">ComboBox to retrieve value for.</param>
internal static int GetIndex(ComboBox cb)
{
return (int)(cb?.SelectedValue ?? 0);
@ -109,6 +115,13 @@ public static void InitializeBinding(this ListControl control)
}
public static void RemoveDropCB(object sender, KeyEventArgs e) => ((ComboBox)sender).DroppedDown = false;
/// <summary>
/// Iterates the Control's child controls recursively to obtain all controls of the specified type.
/// </summary>
/// <param name="control"></param>
/// <param name="type"></param>
/// <returns></returns>
public static IEnumerable<Control> GetAllControlsOfType(Control control, Type type)
{
var controls = control.Controls.Cast<Control>().ToList();
@ -123,7 +136,12 @@ public static IEnumerable<Control> GetAllControlsOfType(Control control, Type ty
public static bool IsClickonceDeployed => false;
#endif
/// <summary>
/// Reads in custom extension types that allow the program to open more extensions.
/// </summary>
/// <param name="exts">Extensions to add</param>
public static void AddSaveFileExtensions(IEnumerable<string> exts) => CustomSaveExtensions.AddRange(exts);
private static readonly List<string> CustomSaveExtensions = new List<string>
{
// THESE ARE SAVE FILE EXTENSION TYPES. SAVE STATE (RAM SNAPSHOT) EXTENSIONS DO NOT GO HERE.
@ -135,6 +153,7 @@ public static IEnumerable<Control> GetAllControlsOfType(Control control, Type ty
"fla", // flashcard
"SaveRAM", // BizHawk
};
private static string ExtraSaveExtensions => ";" + string.Join(";", CustomSaveExtensions.Select(z => $"*.{z}"));
/// <summary>
@ -179,6 +198,7 @@ public static bool OpenSAVPKMDialog(IEnumerable<string> Extensions, out string p
path = ofd.FileName;
return true;
}
/// <summary>
/// Opens a dialog to save a <see cref="PKM"/> file.
/// </summary>
@ -203,6 +223,7 @@ public static bool SavePKMDialog(PKM pk)
SavePKM(pk, sfd.FileName, pkx);
return true;
}
private static void SavePKM(PKM pk, string path, string pkx)
{
SaveBackup(path);
@ -210,6 +231,7 @@ private static void SavePKM(PKM pk, string path, string pkx)
var data = $".{pkx}" == ext ? pk.DecryptedBoxData : pk.EncryptedPartyData;
File.WriteAllBytes(path, data);
}
private static void SaveBackup(string path)
{
if (!File.Exists(path))
@ -268,6 +290,7 @@ public static bool SaveSAVDialog(SaveFile SAV, int CurrentBox = 0)
}
return true;
}
/// <summary>
/// Opens a dialog to save a <see cref="MysteryGift"/> file.
/// </summary>
@ -297,14 +320,19 @@ public static bool SaveMGDialog(MysteryGift gift)
return true;
}
/// <summary>
/// Gets the File Dialog filter for a Mystery Gift I/O operation.
/// </summary>
/// <param name="Format">Format specifier for the </param>
public static string GetMysterGiftFilter(int Format)
{
const string all = "|All Files|*.*";
switch (Format)
{
case 4: return "Gen4 Mystery Gift|*.pgt;*.pcd;*.wc4|All Files|*.*";
case 5: return "Gen5 Mystery Gift|*.pgf|All Files|*.*";
case 6: return "Gen6 Mystery Gift|*.wc6;*.wc6full|All Files|*.*";
case 7: return "Gen7 Mystery Gift|*.wc7;*.wc7full|All Files|*.*";
case 4: return "Gen4 Mystery Gift|*.pgt;*.pcd;*.wc4" + all;
case 5: return "Gen5 Mystery Gift|*.pgf" + all;
case 6: return "Gen6 Mystery Gift|*.wc6;*.wc6full" + all;
case 7: return "Gen7 Mystery Gift|*.wc7;*.wc7full" + all;
default: return string.Empty;
}
}