示例#1
0
        private void B_ImportCGB_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog
            {
                Filter = CGearBackground.Filter + "|PokeStock C-Gear Skin|*.psk"
            };

            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            var len = new FileInfo(ofd.FileName).Length;

            if (len != CGearBackground.SIZE_CGB)
            {
                WinFormsUtil.Error($"Incorrect size, got {len} bytes, expected {CGearBackground.SIZE_CGB} bytes.");
                return;
            }

            byte[] data = File.ReadAllBytes(ofd.FileName);
            if (!CGearBackground.getIsCGB(data))
            {
                bool B2W2 = data[0x2000] != 0x00;
                data = CGearBackground.PSKtoCGB(data, B2W2);
            }

            bg = new CGearBackground(data);
            PB_Background.Image = bg.GetImage();
        }