Example #1
0
        private void replace(string filename)
        {
            byte[] gbc_data_arr = File.ReadAllBytes(filename);
            object h            = listBox1.SelectedItem;

            if (h == null)
            {
                MessageBox.Show("No item is selected.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (h is Stateheader)
            {
                try {
                    GameBoyAdvanceSRAM new_data = loaded_sram.CopyAndReplace((Stateheader)h, gbc_data_arr);
                    loaded_sram = new_data;
                    dirty       = true;

                    int sel = listBox1.SelectedIndex;
                    headerScan();
                    if (listBox1.Items.Count > sel)
                    {
                        listBox1.SelectedIndex = sel;
                    }
                } catch (GoombaException e) {
                    MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("You cannot replace data for this type of header.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }