private void SelectFileButton_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog fileDialog = new OpenFileDialog())
            {
                // fileDialog settings
                fileDialog.RestoreDirectory = true;
                fileDialog.Filter           = "N64 rom files|*.n64;*.z64;*.v64;*.N64;*.Z64;*.V64";

                // open dialog and get result
                DialogResult result = fileDialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    romFileName = fileDialog.FileName;

                    using (RomConverter romConverter = new RomConverter(romFileName))
                    {
                        RomConverter.RomFormat format = romConverter.GetFormat();

                        switch (format)
                        {
                        // invalid
                        case RomConverter.RomFormat.INVALID:
                            MessageBox.Show("Invalid ROM!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            // disable all buttons
                            ConvertButton1.Enabled = false;
                            ConvertButton2.Enabled = false;
                            ConvertButton3.Enabled = false;
                            // reset textboxes
                            RomFileInputText.Text = "";
                            RomInfoText.Text      = "";
                            return;

                        case RomConverter.RomFormat.N64:
                            ConvertButton1.Enabled = false;
                            ConvertButton2.Enabled = true;
                            ConvertButton3.Enabled = true;
                            break;

                        case RomConverter.RomFormat.V64:
                            ConvertButton1.Enabled = true;
                            ConvertButton2.Enabled = false;
                            ConvertButton3.Enabled = true;
                            break;

                        case RomConverter.RomFormat.Z64:
                            ConvertButton1.Enabled = true;
                            ConvertButton2.Enabled = true;
                            ConvertButton3.Enabled = false;
                            break;
                        }

                        RomFileInputText.Text = romFileName;
                        RomInfoText.Text      = $"FORMAT     | {format.ToString()}" + Environment.NewLine +
                                                $"HEADER     | {romConverter.RomHeader}" + Environment.NewLine +
                                                $"MD5 HASH | {romConverter.GetMd5Hash()}";
                    }
                }
            }
        }
        private void SelectFileButton_Clicked(object sender, EventArgs a)
        {
            FileChooserDialog fc =
                new FileChooserDialog("Select ROM",
                                      this,
                                      FileChooserAction.Open,
                                      "Cancel", ResponseType.Cancel,
                                      "Open", ResponseType.Accept);

            FileFilter fileFilter = new FileFilter();

            fileFilter.Name = "N64 rom";
            string[] allowedExtensions = { "n64", "z64", "v64" };
            foreach (string extension in allowedExtensions)
            {
                fileFilter.AddPattern("*." + extension.ToLower());
                fileFilter.AddPattern("*." + extension.ToUpper());
            }

            fc.AddFilter(fileFilter);

            if (fc.Run() != (int)ResponseType.Accept)
            {
                fc.Destroy();
                return;
            }

            FileName = fc.Filename;
            fc.Destroy();

            // since Gtk# lacks docs(thanks!)
            // I have no idea how to make the textview 'locked'
            // so if we use more characters than 48, our GUI will look ugly
            // so just..use a simple loop and trim the string
            if (FileName.Length <= 48)
            {
                RomFileInputText.Buffer.Text = FileName;
            }
            else
            {
                string trimmedFileName = null;

                for (int i = 0; i <= 48; i++)
                {
                    trimmedFileName += FileName[i];
                }

                RomFileInputText.Buffer.Text = trimmedFileName;
            }

            using (RomConverter romConverter = new RomConverter(FileName))
            {
                RomInfoText.Buffer.Text = $"FORMAT      | {romConverter.GetFormat()}" + Environment.NewLine +
                                          $"HEADER       | {romConverter.RomHeader}" + Environment.NewLine +
                                          $"MD5 HASH | {romConverter.GetMd5Hash()}";
            }
        }
        private void ConvertButton_Click(Button button, RomConverter.RomFormat format)
        {
            using (RomConverter romConverter = new RomConverter(romFileName))
            {
                using (SaveFileDialog fileDialog = new SaveFileDialog())
                {
                    fileDialog.Filter   = $"N64 rom(*.{format.ToString().ToLower()})|*.{format.ToString().ToLower()}";
                    fileDialog.FileName = Path.GetFileName(Regex.Replace(romFileName, romConverter.GetFormat().ToString(), format.ToString().ToLower(), RegexOptions.IgnoreCase));

                    if (fileDialog.ShowDialog() == DialogResult.OK)
                    {
                        romConverter.Convert(fileDialog.FileName, format);
                        MessageBox.Show("Converted successfully!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }
        private void ConvertButton_Click(Button button, RomConverter.RomFormat format)
        {
            using (RomConverter romConverter = new RomConverter(FileName))
            {
                // show error if we're trying to convert to the same format
                if (format.ToString().ToLower() ==
                    romConverter.GetFormat().ToString().ToLower())
                {
                    ShowDialog("Cannot convert to the same format!", MessageType.Error);
                    return;
                }

                FileChooserDialog fc =
                    new FileChooserDialog("Select ROM",
                                          this,
                                          FileChooserAction.Save,
                                          "Cancel", ResponseType.Cancel,
                                          "Save", ResponseType.Accept);

                FileFilter fileFilter = new FileFilter();

                fileFilter.Name = format.ToString();
                fileFilter.AddPattern("*." + format.ToString().ToUpper());
                fileFilter.AddPattern("*." + format.ToString().ToLower());

                fc.AddFilter(fileFilter);
                fc.CurrentName = System.IO.Path.GetFileName(
                    Regex.Replace(FileName,
                                  romConverter.GetFormat().ToString(),
                                  format.ToString().ToLower(),
                                  RegexOptions.IgnoreCase));

                if (fc.Run() != (int)ResponseType.Accept)
                {
                    fc.Destroy();
                    return;
                }

                string targetFileName = fc.Filename;
                fc.Destroy();

                romConverter.Convert(targetFileName, format);

                ShowDialog("Converted successfully!", MessageType.Info);
            }
        }