private void OpenFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter           = "MIB texture file (*.mib)|*.mib";
            openFileDialog.RestoreDirectory = true;
            openFileDialog.ShowHelp         = false;
            openFileDialog.Multiselect      = false;
            openFileDialog.Title            = "Open Texture";
            DialogResult result = openFileDialog.ShowDialog();

            if (result == DialogResult.OK || result == DialogResult.Yes)
            {
                RefreshDefault();
                currentMIB = new MIBFile(openFileDialog.FileName);
                if (currentMIB.IsValid() && currentMIB.GetPaletteFile().IsValid())
                {
                    currentMIB.Render();
                }
                attributeTextBox.Text = $"Texture file: {currentMIB.GetFileName()}\r\n\r\nPalette file: {currentMIB.GetPaletteFile().GetFileName()}\r\n\r\nBits per pixel: {currentMIB.GetBPP()}bpp\r\n\r\nWidth: {currentMIB.GetWidth()}px\r\n\r\nHeight: {currentMIB.GetHeight()}px";
                texturePicBox.Image   = currentMIB.GetImage();
                convertCurrentFileToolStripMenuItem.Enabled = true;
                closeFileToolStripMenuItem.Enabled          = true;
            }
            // Refresh();
        }
        private void BatchConvertToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CommonOpenFileDialog folderBrowserDialog = new CommonOpenFileDialog();

            folderBrowserDialog.IsFolderPicker   = true;
            folderBrowserDialog.RestoreDirectory = true;
            folderBrowserDialog.Title            = "Open folder for batch MIB processing";
            var result = folderBrowserDialog.ShowDialog();

            if (result == CommonFileDialogResult.Ok)
            {
                int      exportCount = 0;
                string[] workFiles   = Directory.GetFiles(folderBrowserDialog.FileName);
                foreach (string filePath in workFiles)
                {
                    if (filePath.ToLower().EndsWith(".mib"))
                    {
                        currentMIB = new MIBFile(filePath);
                        if (currentMIB.IsValid() && currentMIB.GetPaletteFile().IsValid())
                        {
                            currentMIB.Render();
                        }
                        string savePath = filePath + ".png";
                        currentMIB.GetImage().Save(savePath, System.Drawing.Imaging.ImageFormat.Png);
                        exportCount++;
                    }
                }
                MessageBox.Show($"Converted {exportCount} files.");
            }
        }
 private void RefreshDefault()
 {
     currentMIB            = null;
     currentP1I            = null;
     texturePicBox.Image   = null;
     attributeTextBox.Text = "Texture file: \r\n\r\nPalette file: \r\n\r\nBits per pixel: \r\n\r\nWidth: \r\n\r\nHeight: ";
     convertCurrentFileToolStripMenuItem.Enabled = false;
     convertCurrentP1IToolStripMenuItem.Enabled  = false;
     closeFileToolStripMenuItem.Enabled          = false;
 }