private void replaceFileToolStripMenuItem_Click(object sender, EventArgs e) { int i = this.listBox.SelectedIndex; if (i != -1) { BAR.BARFile b = this.bar.fileList[i]; try { typeEntry t = typeMap[b.type]; openFileDialog.Filter = t.name + " file|*." + t.ext + "|All Files|*.*"; openFileDialog.DefaultExt = t.ext; } catch (KeyNotFoundException) { openFileDialog.Filter = "All Files|*.*"; openFileDialog.DefaultExt = "bin"; } openFileDialog.FileName = b.id + " [0x" + b.type.ToString("X2") + "]." + openFileDialog.DefaultExt; if (openFileDialog.ShowDialog() == DialogResult.OK) { b.data = System.IO.File.ReadAllBytes(openFileDialog.FileName); } } }
private void buttonAddSelect_Click(object sender, EventArgs e) { BAR.BARFile b = new BAR.BARFile() { type = (uint)this.inputType.Value, id = this.inputIDS.Text }; try { typeEntry t = typeMap[b.type]; openFileDialog.Filter = t.name + " file|*." + t.ext + "|All Files|*.*"; openFileDialog.DefaultExt = t.ext; } catch (KeyNotFoundException) { openFileDialog.Filter = "All Files|*.*"; openFileDialog.DefaultExt = "bin"; } openFileDialog.FileName = b.id + " [0x" + b.type.ToString("X2") + "]." + openFileDialog.DefaultExt; if (openFileDialog.ShowDialog() == DialogResult.OK) { b.data = System.IO.File.ReadAllBytes(openFileDialog.FileName); this.bar.fileList.Add(b); this.listBox.Items.Add(b.id + " [0x" + b.type.ToString("X2") + "]"); this.inputType.Value = 0; this.inputIDS.Text = ""; } }