Add ProgressBar to Box Data Report

So it's not completely unresponsive while generating
This commit is contained in:
Kaisonic
2015-02-11 17:47:59 -05:00
parent 249b06ec5c
commit 277b8674f6
3 changed files with 18 additions and 2 deletions

View File

@@ -376,8 +376,8 @@ private void mainMenuBoxReport(object sender, EventArgs e)
{
frmReport ReportForm = new frmReport();
int offset = 0x27A00; if (savegame_oras) offset = 0x33000 + 0x5400;
ReportForm.Show();
ReportForm.PopulateData(savefile, savindex, offset);
ReportForm.ShowDialog();
}
private void mainMenuUnicode(object sender, EventArgs e)
{

View File

@@ -31,6 +31,7 @@ private void InitializeComponent()
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmReport));
this.dgData = new System.Windows.Forms.DataGridView();
this.BoxBar = new System.Windows.Forms.ProgressBar();
((System.ComponentModel.ISupportInitialize)(this.dgData)).BeginInit();
this.SuspendLayout();
//
@@ -49,11 +50,19 @@ private void InitializeComponent()
this.dgData.Size = new System.Drawing.Size(812, 461);
this.dgData.TabIndex = 0;
//
// BoxBar
//
this.BoxBar.Location = new System.Drawing.Point(13, 13);
this.BoxBar.Name = "BoxBar";
this.BoxBar.Size = new System.Drawing.Size(787, 23);
this.BoxBar.TabIndex = 1;
//
// frmReport
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(812, 461);
this.Controls.Add(this.BoxBar);
this.Controls.Add(this.dgData);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "frmReport";
@@ -68,5 +77,6 @@ private void InitializeComponent()
#endregion
private System.Windows.Forms.DataGridView dgData;
private System.Windows.Forms.ProgressBar BoxBar;
}
}

View File

@@ -28,11 +28,14 @@ public void PopulateData(byte[] InputData, int savindex, int baseoffset)
PokemonList PL = new PokemonList();
PKX.Structures.SaveGame SaveGame = new PKX.Structures.SaveGame("XY");
if (savindex > 1) savindex = 0;
BoxBar.Maximum = 930 + 100;
BoxBar.Step = 1;
for (int BoxNum = 0; BoxNum < 31; BoxNum++)
{
int boxoffset = baseoffset + 0x7F000 * savindex + BoxNum * (0xE8 * 30);
for (int SlotNum = 0; SlotNum < 30; SlotNum++)
{
BoxBar.PerformStep();
int offset = boxoffset + 0xE8 * SlotNum;
byte[] slotdata = new byte[0xE8];
Array.Copy(SaveData, offset, slotdata, 0, 0xE8);
@@ -46,11 +49,14 @@ public void PopulateData(byte[] InputData, int savindex, int baseoffset)
}
dgData.DataSource = PL;
dgData.AutoGenerateColumns = true;
BoxBar.Maximum = 930 + dgData.Columns.Count;
for (int i = 0; i < dgData.Columns.Count; i++)
{
BoxBar.PerformStep();
if (dgData.Columns[i] is DataGridViewImageColumn) continue; // Don't add sorting for Sprites
dgData.Columns[i].SortMode = DataGridViewColumnSortMode.Automatic;
}
BoxBar.Visible = false;
}
private void promptSaveCSV(object sender, FormClosingEventArgs e)
{
@@ -75,7 +81,7 @@ private void Export_CSV(string path)
var cells = row.Cells.Cast<DataGridViewCell>();
sb.AppendLine(string.Join(",", cells.Select(cell => "\"" + cell.Value + "\"").ToArray()));
}
System.IO.File.WriteAllText(path, sb.ToString(), Encoding.UTF8);
System.IO.File.WriteAllText(path, sb.ToString(), Encoding.UTF8);
}
public class PokemonList : SortableBindingList<PKX> { }