PKHeX.CodeGenerator.B_Import_Click C# (CSharp) Method

B_Import_Click() private method

private B_Import_Click ( object sender, EventArgs e ) : void
sender object
e EventArgs
return void
        private void B_Import_Click(object sender, EventArgs e)
        {
            // Gotta read in the textbox.
            if (RTB_Code.Text.Length < 1) return;
            byte[] data = new byte[0];
            // Get Actual Lines
            for (int i = 0; i < RTB_Code.Lines.Count(); i++)
            {
                if (RTB_Code.Lines[i].Length <= 0) continue;

                if (RTB_Code.Lines[i].Length <= 2 * 8 && RTB_Code.Lines[i].Length > 2 * 8 + 2)
                { Util.Error("Invalid code pasted (Type)"); return; }

                try
                {
                    // Grab Line Data
                    string line = RTB_Code.Lines[i];
                    string[] rip = Regex.Split(line, " ");
                    Array.Resize(ref data, data.Length + 4);
                    Array.Copy(BitConverter.GetBytes(UInt32.Parse(rip[1], NumberStyles.HexNumber)), 0, data, data.Length - 4, 4);
                }
                catch (Exception x)
                { Util.Error("Invalid code pasted (Content):", x.ToString()); return; }
            }
            // Go over the data
            if ((data.Length == 232 - 4) || (data.Length == 260 - 4))
            {
                Array.Resize(ref data, data.Length + 4);
                Array.Copy(data, 0, data, 4, data.Length);
                data[0] = data[1] = data[2] = data[3] = 0;
            }
            if ((data.Length == 232) || (data.Length == 260))
            { returnArray = data; Close(); }
            else { Util.Error("Invalid code pasted (Length)"); }
        }