public void SalvarItemListBinEncode() { try { using (SaveFileDialog save = new SaveFileDialog()) { save.Filter = "*.bin|*.bin"; save.Title = "Selecione onde deseja salvar sua ItemList.bin"; save.ShowDialog(); if (save.FileName != "") { byte[] toSave = Pak.ToByteArray(this.List); byte[] pKeyList = File.ReadAllBytes("./Keys.bin"); Array.Resize(ref pKeyList, pKeyList.Length + 1); for (int i = 0; i < toSave.Length; i++) { toSave[i] ^= (pKeyList[i & 63]); } File.Create(save.FileName).Close(); File.WriteAllBytes(save.FileName, toSave); MessageBox.Show($"Arquivo {save.FileName} salvo no modo Encode com sucesso!"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void SalvarItemListBin() { try { using (SaveFileDialog save = new SaveFileDialog()) { save.Filter = "*.bin|*.bin"; save.Title = "Selecione onde deseja salvar sua ItemList.bin"; save.ShowDialog(); if (save.FileName != "") { byte[] toSave = Pak.ToByteArray(this.List); for (int i = 0; i < toSave.Length; i++) { toSave[i] ^= 0x5A; } File.Create(save.FileName).Close(); File.WriteAllBytes(save.FileName, toSave); MessageBox.Show($"Arquivo {save.FileName} salvo com sucesso!"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void LoadItemList( ) { try { using (OpenFileDialog find = new OpenFileDialog( )) { find.Filter = "ItemList.bin|ItemList.bin"; find.Title = "Selecione sua ItemList.bin"; find.ShowDialog( ); if (find.CheckFileExists) { this.FilePath = find.FileName; if (File.Exists(this.FilePath)) { byte [] temp = File.ReadAllBytes(this.FilePath); if (temp.Length != 910004) { MessageBox.Show("Sua ItemList.bin é inválida! Selecione a original do seu cliente!", "ItemList.bin inválida", MessageBoxButtons.OK, MessageBoxIcon.Error); this.LoadItemList( ); } else { for (int i = 0; i < temp.Length; i++) { temp [i] ^= 0x5A; } this.List = Pak.ToStruct <st_ItemList> (temp); Task.Run(() => { this.listBox.Invoke(new MethodInvoker(delegate() { for (int i = 0; i < this.List.Item.Length; i++) { this.listBox.Items.Add($"{i.ToString ( ).PadLeft ( 4 , '0' )}: {this.List.Item [ i ].Name}"); } })); }); } } else { Environment.Exit(0); } } else { Environment.Exit(0); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void SalvaritemNameBin() { try { using (SaveFileDialog save = new SaveFileDialog()) { save.Filter = "*.bin|*.bin"; save.Title = "Selecione onde deseja salvar sua ItemName.bin"; save.ShowDialog(); if (save.FileName != "") { for (int i = 0; i < 6500; i++) { if (string.IsNullOrEmpty(this.List.Item[i].Name)) { continue; } this.ItemName.Item[i].Id = i; this.ItemName.Item[i].Name = this.List.Item[i].Name; } byte[] toSave = Pak.ToByteArray(this.ItemName); for (int i = 0; i < toSave.Length; i += 68) { for (int j = i + 4, k = 0; j < i + 68; j++, k++) { toSave[j] += (byte)(k); } } File.Create(save.FileName).Close(); File.WriteAllBytes(save.FileName, toSave); MessageBox.Show($"Arquivo {save.FileName} salvo com sucesso!"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void LoadItemList() { try { using (OpenFileDialog find = new OpenFileDialog()) { find.Filter = "ItemList.bin|ItemList.bin"; find.Title = "Selecione sua ItemList.bin"; find.ShowDialog(); if (find.CheckFileExists) { this.FilePath = find.FileName; if (File.Exists(this.FilePath)) { byte[] temp = File.ReadAllBytes(this.FilePath); if (temp.Length != 988004) { MessageBox.Show("Itemlist inválida", "ItemList.bin inválida", MessageBoxButtons.OK, MessageBoxIcon.Error); this.LoadItemList(); } else { byte[] pKeyList = File.ReadAllBytes("./Keys.bin"); Array.Resize(ref pKeyList, pKeyList.Length + 1); if (temp[0] == 0x5A && temp[1] == 0x5A) { for (int i = 0; i < temp.Length; i++) { temp[i] ^= 0x5A; } } else { for (int i = 0; i < temp.Length; i++) { temp[i] ^= (pKeyList[i & 63]); } } this.List = Pak.ToStruct <st_ItemList>(temp); Task.Run(() => { if (listBox.Items.Count > 0) { listBox.Items.Clear(); } itemCount = 0; this.listBox.Invoke(new MethodInvoker(delegate() { for (int i = 0; i < this.List.Item.Length; i++) { if (this.List.Item[i].Name != "") { itemCount++; label10.Text = "Quantidade de itens: (" + itemCount + " / 6500)"; } this.SaveItemName.Item[i].Id = i; this.SaveItemName.Item[i].Name = this.List.Item[i].Name; this.listBox.Items.Add($"{i.ToString().PadLeft(4, '0')}: {this.List.Item[i].Name}"); } })); }); abrirItemNamebinToolStripMenuItem.Enabled = true; } } else { Environment.Exit(0); } } else { Environment.Exit(0); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }