private void Filelistbox_SelectedIndexChanged(object sender, EventArgs e) { long currentaddress = 0; long currentFreeSpaceLength = 0; FileWrite File = new FileWrite(); string[] patchnames = new string[1]; dgv_FreeSpace.Rows.Clear(); switch (Filelistbox.SelectedIndex) { case 1: File = WORLDBIN; currentaddress = 0x5d400; patchnames = WORLDBIN.FindAllPatchNames(); break; default: File = BATTLEBIN; currentaddress = 0xe92ac; patchnames = BATTLEBIN.FindAllPatchNames(); break; } //Patches = new Patch[patchnames.Length]; int k = 0; long currentendaddress = 0; //Array.Sort(File.startaddress); for (k = 0; k < File.startaddress.Length; k++) { if (File.startaddress[k] != 0) { //if(startaddress < currentaddress) //{ // if (File.endaddress[k] > currentendaddress) ; // //currentaddress = File.endaddress[k]; //} //else //{ //currentFreeSpaceLength = startaddress - currentaddress; dgv_FreeSpace.Rows.Add(File.startaddress[k].ToString("X"), File.length[k].ToString("X"), "", "", File.Patchname[k]); //currentaddress = File.endaddress[k]; //} //if (k == 0x140) // this.Focus(); } } dgv_FreeSpace.Sort(dgv_FreeSpace.Columns[0], ListSortDirection.Ascending); for (int r = 0; r < dgv_FreeSpace.Rows.Count - 1; r++) { long start = Convert.ToInt64(dgv_FreeSpace.Rows[r].Cells[0].Value.ToString(), 16); long length = Convert.ToInt64(dgv_FreeSpace.Rows[r].Cells[1].Value.ToString(), 16); long nextstart; if (r != dgv_FreeSpace.Rows.Count - 2) { nextstart = Convert.ToInt64(dgv_FreeSpace.Rows[r + 1].Cells[0].Value.ToString(), 16); } else { nextstart = 0xF929B; } if (nextstart > (start + 1)) { dgv_FreeSpace.Rows[r].Cells[2].Value = String.Format("{0:X}", start + length); short number = (short)(nextstart - (start + length)); bool isnegative = false; if (nextstart - (start + length) < 0) { number = (short)(0 - number); isnegative = true; } if (isnegative) { dgv_FreeSpace.Rows[r].Cells[3].Value = "-" + String.Format("{0:X}", number); dgv_FreeSpace.Rows[r].Cells[3].Style.BackColor = Color.Red; } else { dgv_FreeSpace.Rows[r].Cells[3].Value = String.Format("{0:X}", number); } dgv_FreeSpace.Rows[r].Cells[5].Value = r.ToString(); } } lbl_NumberOfPatches.Text = File.ShortPatchnames.Length.ToString(); lbl_NumberOfWrites.Text = File.startaddress.Length.ToString(); }
private void Filelistbox_SelectedIndexChanged_1(object sender, EventArgs e) { Patcheslistview.Items.Clear(); string[] patchnames = new string[1]; FileWrite File = new FileWrite(); switch (Filelistbox.SelectedIndex) { case -1: patchnames = BATTLEBIN.FindAllPatchNames(); File = BATTLEBIN; break; case 0: patchnames = BATTLEBIN.FindAllPatchNames(); File = BATTLEBIN; break; case 1: patchnames = WORLDBIN.FindAllPatchNames(); File = WORLDBIN; break; case 2: patchnames = WLDCOREBIN.FindAllPatchNames(); File = WLDCOREBIN; break; case 3: patchnames = SCUS.FindAllPatchNames(); File = SCUS; break; case 4: patchnames = REQUIREOUT.FindAllPatchNames(); File = REQUIREOUT; break; case 5: patchnames = EQUIPOUT.FindAllPatchNames(); File = EQUIPOUT; break; } int k = 1; Patcheslistview.View = View.Details; Patcheslistview.HeaderStyle = ColumnHeaderStyle.None; Patcheslistview.Columns.Add(""); Patcheslistview.Columns[0].Width = 500; //Patcheslistview.AutoResizeColumn(0,ColumnHeaderAutoResizeStyle.ColumnContent); Patches = new Patch[patchnames.Length]; foreach (string name in patchnames) { Patches[k - 1] = new Patch(); Patches[k - 1].name = name; Patcheslistview.Items.Add(k + " " + name); CheckforConflicts(name, File, Patches, k); k++; } int j = 0; foreach (Patch patch in Patches) { patch.ConvertConflicts(patchnames, File); if (patch.Conflictexists) { Patcheslistview.Items[j].BackColor = Color.Red; } j++; } }