private void ConvertOsageSkinParameters(BinaryFormat format)
        {
            var filePaths =
                ModuleImportUtilities.SelectModuleImportMultiselect <OsageSkinParameterSet>(
                    "Select file(s) to convert.");

            if (filePaths == null)
            {
                return;
            }

            using (var folderBrowserDialog = new VistaFolderBrowserDialog
            {
                Description = "Select a folder to save file(s) to.", UseDescriptionForTitle = true
            })
            {
                if (folderBrowserDialog.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                new Thread(() =>
                {
                    try
                    {
                        Invoke(new Action(() => Enabled = false));

                        string extension = format.IsModern() ? ".osp" : ".txt";

                        foreach (string filePath in filePaths)
                        {
                            var ospSet = BinaryFile.Load <OsageSkinParameterSet>(filePath);

                            ospSet.Format = format;
                            ospSet.Save(Path.Combine(folderBrowserDialog.SelectedPath,
                                                     Path.GetFileNameWithoutExtension(filePath) + extension));
                        }
                    }
                    finally
                    {
                        Invoke(new Action(() => Enabled = true));
                    }
                }).Start();
            }
        }
        protected override void Initialize()
        {
            AddImportHandler <Texture>(filePath =>
            {
                var texture = TextureEncoder.EncodeFromFile(filePath, TextureFormat.Unknown, Parent.FindParent <SpriteSetNode>() == null);
                {
                    texture.Name = Path.GetFileNameWithoutExtension(filePath);
                    texture.Id   = MurmurHash.Calculate(texture.Name);
                }

                Data.Textures.Add(texture);
            });
            AddExportHandler <TextureSet>(filePath => Data.Save(filePath));
            AddReplaceHandler <TextureSet>(BinaryFile.Load <TextureSet>);

            AddCustomHandler("Export All", () =>
            {
                string filePath = ModuleExportUtilities.SelectModuleExport <Texture>(
                    "Select a folder to export textures to.", "Enter into a directory and press Save");

                if (string.IsNullOrEmpty(filePath))
                {
                    return;
                }

                string directoryPath = Path.GetDirectoryName(filePath);
                string extension     = Path.GetExtension(filePath).Trim('.');

                foreach (var texture in Data.Textures)
                {
                    TextureDecoder.DecodeToFile(texture, Path.Combine(directoryPath, $"{texture.Name}.{extension}"));
                }
            }, Keys.Control | Keys.Shift | Keys.E);

            AddCustomHandler("Export All (Flipped)", () =>
            {
                string filePath = ModuleExportUtilities.SelectModuleExport <Bitmap>(
                    "Select a folder to export textures to.", "Enter into a directory and press Save");

                if (string.IsNullOrEmpty(filePath))
                {
                    return;
                }

                string directoryPath = Path.GetDirectoryName(filePath);
                string extension     = Path.GetExtension(filePath).Trim('.');

                foreach (var texture in Data.Textures)
                {
                    using (var bitmap = TextureDecoder.DecodeToBitmap(texture))
                    {
                        bitmap.RotateFlip(RotateFlipType.Rotate180FlipX);
                        bitmap.Save(Path.Combine(directoryPath, $"{texture.Name}.{extension}"));
                    }
                }
            });

            AddCustomHandlerSeparator();

            AddDirtyCustomHandler("Replace All", () =>
            {
                var fileNames = ModuleImportUtilities.SelectModuleImportMultiselect <Texture>();

                if (fileNames == null)
                {
                    return(false);
                }

                bool any = false;

                foreach (string fileName in fileNames)
                {
                    string textureName = Path.GetFileNameWithoutExtension(fileName);

                    int textureIndex = Data.Textures.FindIndex(x => x.Name.Equals(textureName, StringComparison.OrdinalIgnoreCase));

                    if (textureIndex == -1)
                    {
                        continue;
                    }

                    any = true;

                    var texture = Data.Textures[textureIndex];

                    var newTexture = TextureEncoder.EncodeFromFile(fileName,
                                                                   texture.IsYCbCr ? TextureFormat.RGBA8 : texture.Format, texture.MipMapCount != 1);

                    newTexture.Name = texture.Name;
                    newTexture.Id   = texture.Id;

                    Data.Textures[textureIndex] = newTexture;
                }

                return(any);
            }, Keys.Control | Keys.Shift | Keys.R, CustomHandlerFlags.Repopulate | CustomHandlerFlags.ClearMementos);

            AddDirtyCustomHandler("Replace All (Flipped)", () =>
            {
                var fileNames = ModuleImportUtilities.SelectModuleImportMultiselect <Bitmap>();

                if (fileNames == null)
                {
                    return(false);
                }

                bool any = false;

                foreach (string fileName in fileNames)
                {
                    // Boy do I love duplicate code C:

                    string textureName = Path.GetFileNameWithoutExtension(fileName);

                    int textureIndex = Data.Textures.FindIndex(x => x.Name.Equals(textureName, StringComparison.OrdinalIgnoreCase));

                    if (textureIndex == -1)
                    {
                        continue;
                    }

                    any = true;

                    var texture = Data.Textures[textureIndex];

                    Texture newTexture;

                    using (var bitmap = new Bitmap(fileName))
                    {
                        bitmap.RotateFlip(RotateFlipType.Rotate180FlipX);

                        newTexture = TextureEncoder.EncodeFromBitmap(bitmap,
                                                                     texture.IsYCbCr ? TextureFormat.RGBA8 : texture.Format, texture.MipMapCount != 1);
                    }

                    newTexture.Name = texture.Name;
                    newTexture.Id   = texture.Id;

                    Data.Textures[textureIndex] = newTexture;
                }

                return(any);
            }, Keys.None, CustomHandlerFlags.Repopulate | CustomHandlerFlags.ClearMementos);

            base.Initialize();
        }