PKHeX/SAV/frmReport.cs

60 lines
2.2 KiB
C#
Raw Normal View History

2014-07-22 05:47:18 +00:00
using System;
2014-10-11 07:22:22 +00:00
using System.Collections.Generic;
using System.ComponentModel;
2014-07-22 05:47:18 +00:00
using System.Data;
2014-10-11 07:22:22 +00:00
using System.Drawing;
2014-07-22 05:47:18 +00:00
using System.Linq;
using System.Text;
2014-10-11 07:22:22 +00:00
using System.Windows.Forms;
2014-07-22 05:47:18 +00:00
using System.Security.Cryptography;
2014-07-24 16:20:08 +00:00
using System.Reflection;
2014-10-11 07:22:22 +00:00
using System.Text.RegularExpressions;
2014-07-22 05:47:18 +00:00
namespace PKHeX
{
2014-10-11 07:22:22 +00:00
public partial class frmReport : Form
2014-07-22 05:47:18 +00:00
{
private byte[] SaveData;
private const int PIDOFFSET = 0x18;
private const int TIDOFFSET = 0x0C;
private const int SIDOFFSET = 0x0E;
2014-10-11 07:22:22 +00:00
public frmReport()
2014-07-22 05:47:18 +00:00
{
InitializeComponent();
2014-07-24 16:20:08 +00:00
dgData.DoubleBuffered(true);
2014-07-22 05:47:18 +00:00
}
2014-10-11 07:22:22 +00:00
public void PopulateData(byte[] InputData, int savindex)
2014-07-22 05:47:18 +00:00
{
SaveData = new byte[InputData.Length];
Array.Copy(InputData, SaveData, InputData.Length);
PokemonList PL = new PokemonList();
SaveGames.SaveStruct SaveGame = new SaveGames.SaveStruct("XY");
2014-07-24 16:20:08 +00:00
if (savindex > 1) savindex = 0;
2014-07-22 05:47:18 +00:00
for (int BoxNum = 0; BoxNum < 31; BoxNum++)
{
int boxoffset = 0x27A00 + 0x7F000 * savindex + BoxNum * (0xE8 * 30);
for (int SlotNum = 0; SlotNum < 30; SlotNum++)
{
int offset = boxoffset + 0xE8 * SlotNum;
byte[] slotdata = new Byte[0xE8];
Array.Copy(SaveData, offset, slotdata, 0, 0xE8);
2014-10-11 07:22:22 +00:00
byte[] dslotdata = PKX.decryptArray(slotdata);
2014-07-22 05:47:18 +00:00
PKX pkm = new PKX(dslotdata);
if ((pkm.EC == "00000000") && (pkm.Species == "---")) continue;
2014-07-22 05:47:18 +00:00
PL.Add(pkm);
}
}
dgData.DataSource = PL;
dgData.AutoGenerateColumns = true;
}
public class PokemonList : System.Collections.ObjectModel.ObservableCollection<PKX> { }
}
2014-07-24 16:20:08 +00:00
public static class ExtensionMethods // Speed up scrolling
{
public static void DoubleBuffered(this DataGridView dgv, bool setting)
{
Type dgvType = dgv.GetType();
PropertyInfo pi = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
pi.SetValue(dgv, setting, null);
}
}
2014-10-11 07:22:22 +00:00
}