Ejemplo n.º 1
0
        private void Save(string FileName, bool UseDialog)
        {
            UpdateFileNames();

            //Archive files are IFIleFormats
            var FileFormat = ((IFileFormat)ArchiveFile);

            Cursor.Current = Cursors.WaitCursor;
            if (UseDialog)
            {
                List <IFileFormat> formats = new List <IFileFormat>();
                formats.Add(FileFormat);

                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Filter   = Utils.GetAllFilters(formats);
                sfd.FileName = FileFormat.FileName;

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    FileName = sfd.FileName;
                }
                else
                {
                    return;
                }
            }

            STFileSaver.SaveFileFormat(FileFormat, FileName);

            GC.Collect();
        }
Ejemplo n.º 2
0
        private void SaveFile(object sender, EventArgs e)
        {
            var selected = GetSelectedObjects <IFileFormat>();

            if (selected.Count == 0)
            {
                return;
            }

            SaveDialogCustom sfd  = new SaveDialogCustom();
            string           name = selected[0].FileInfo.FileName;

            sfd.AddFilter(selected[0]);
            sfd.FolderDialog = selected.Count > 1;
            sfd.FileName     = name;
            sfd.DefaultExt   = System.IO.Path.GetExtension(name);
            var result = sfd.ShowDialog();

            if (result == SaveDialogCustom.Result.OK)
            {
                if (selected.Count == 1)
                {
                    STFileSaver.SaveFileFormat(selected[0], sfd.FileName);
                }
                else
                {
                    foreach (var file in selected)
                    {
                        STFileSaver.SaveFileFormat(selected[0], $"{sfd.FolderPath}/{file.FileInfo.FileName}");
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void SaveNodeFormats(ObjectEditor editor, bool UseSaveDialog, bool UseCompressDialog)
        {
            foreach (var node in editor.GetNodes())
            {
                IFileFormat format = null;
                if (node is ArchiveBase)
                {
                    format = (IFileFormat)((ArchiveBase)node).ArchiveFile;
                }
                else if (node is IFileFormat)
                {
                    format = ((IFileFormat)node);
                }
                if (format != null)
                {
                    if (!format.CanSave)
                    {
                        return;
                    }

                    string FileName = format.FilePath;
                    if (!File.Exists(FileName))
                    {
                        UseSaveDialog = true;
                    }

                    if (UseSaveDialog)
                    {
                        SaveFileDialog sfd = new SaveFileDialog();
                        sfd.Filter   = Utils.GetAllFilters(format);
                        sfd.FileName = format.FileName;

                        if (sfd.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }

                        FileName = sfd.FileName;
                    }
                    Cursor.Current = Cursors.WaitCursor;

                    //Use the export method for particular formats like bfres for special save operations
                    if (format is STGenericWrapper && !(format is STGenericTexture))
                    {
                        ((STGenericWrapper)format).Export(FileName);
                        return;
                    }

                    if (node is ArchiveBase)
                    {
                        STFileSaver.SaveFileFormat(((IFileFormat)((ArchiveBase)node).ArchiveFile), FileName, UseCompressDialog);
                    }
                    else
                    {
                        STFileSaver.SaveFileFormat(((IFileFormat)node), FileName, UseCompressDialog);
                    }
                    Cursor.Current = Cursors.Default;
                }
            }
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            foreach (var arg in args)
            {
                if (Directory.Exists(arg))
                {
                    string folder      = Path.GetFileName(arg);
                    string daeFile     = $"{arg}/{folder}.dae";
                    var    importModel = (DaeFile)STFileLoader.OpenFileFormat(daeFile);

                    HSF hsf = new HSF()
                    {
                        FileInfo = new File_Info()
                    };
                    hsf.FromGeneric(importModel.Scene);
                    STFileSaver.SaveFileFormat(hsf, $"{folder}.new.hsf");
                }
                else if (File.Exists(arg))
                {
                    string folder = Path.GetFileNameWithoutExtension(arg);
                    if (!Directory.Exists(folder))
                    {
                        Directory.CreateDirectory(folder);
                    }

                    var file = STFileLoader.OpenFileFormat(arg);
                    Console.WriteLine($"file {file != null}");
                    DAE.Export($"{folder}/{folder}.dae", new DAE.ExportSettings()
                    {
                        ImageFolder = folder,
                    }, (IModelFormat)file);
                }
            }
        }
Ejemplo n.º 5
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ActiveAnimation != null && ActiveAnimation.FileInfo.CanSave)
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Filter   = Utils.GetAllFilters(ActiveAnimation.FileInfo);
                sfd.FileName = ActiveAnimation.FileInfo.FileName;

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    STFileSaver.SaveFileFormat(ActiveAnimation.FileInfo, sfd.FileName);
                }
            }

            if (ActiveLayout != null && ActiveLayout.FileInfo.CanSave)
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Filter   = Utils.GetAllFilters(ActiveLayout.FileInfo);
                sfd.FileName = ActiveLayout.FileInfo.FileName;

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    STFileSaver.SaveFileFormat(ActiveLayout.FileInfo, sfd.FileName);
                }
            }
        }
Ejemplo n.º 6
0
            private void Save(object sender, EventArgs args)
            {
                SaveFileDialog sfd = new SaveFileDialog();

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    STFileSaver.SaveFileFormat(CameraFile, sfd.FileName);
                }
            }
Ejemplo n.º 7
0
        private void SaveAction(object sender, EventArgs args)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter   = Utils.GetAllFilters(this);
            sfd.FileName = FileName;

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                STFileSaver.SaveFileFormat(this, sfd.FileName);
            }
        }
Ejemplo n.º 8
0
        public void Save(object sender, EventArgs args)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter     = "Supported Formats|*.kcl";
            sfd.FileName   = Text;
            sfd.DefaultExt = ".kcl";

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                STFileSaver.SaveFileFormat(this, sfd.FileName, IFileInfo.Alignment);
            }
        }
Ejemplo n.º 9
0
        private void Save(object sender, EventArgs args)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.DefaultExt = "gtx";
            sfd.Filter     = "Supported Formats|*.gtx;";
            sfd.FileName   = FileName;

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                STFileSaver.SaveFileFormat(this, sfd.FileName);
            }
        }
Ejemplo n.º 10
0
        private void SaveFileFormat(IFileFormat fileFormat, string path)
        {
            var log = STFileSaver.SaveFileFormat(fileFormat, path);

            string compInfo = "";

            if (fileFormat.FileInfo.Compression != null)
            {
                string compType = fileFormat.FileInfo.Compression.ToString();
                compInfo = $"Compressed with {compType}.";
            }

            TinyFileDialog.MessageBoxInfoOk($"File {path} has been saved! { log.SaveTime}. {compInfo}");
        }
Ejemplo n.º 11
0
        private void Save(object sender, EventArgs args)
        {
            List <IFileFormat> formats = new List <IFileFormat>();

            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter   = Utils.GetAllFilters(formats);
            sfd.FileName = FileName;

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                STFileSaver.SaveFileFormat(this, sfd.FileName, IFileInfo.Alignment);
            }
        }
Ejemplo n.º 12
0
 private void SaveActiveFile(bool ForceDialog = false)
 {
     if (ActiveLayout != null && ActiveLayout.FileInfo.CanSave)
     {
         var fileFormat = ActiveLayout.FileInfo;
         if (fileFormat.IFileInfo.ArchiveParent != null && !ForceDialog)
         {
             this.DialogResult = DialogResult.OK;
             IsSaving          = true;
             this.Close();
         }
         else
         {
             STFileSaver.SaveFileFormat(ActiveLayout.FileInfo, fileFormat.FilePath);
         }
     }
 }
Ejemplo n.º 13
0
        private void Save(object sender, EventArgs args)
        {
            Cursor.Current = Cursors.WaitCursor;
            List <IFileFormat> formats = new List <IFileFormat>();

            formats.Add(this);

            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter   = Utils.GetAllFilters(formats);
            sfd.FileName = FileName;

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                STFileSaver.SaveFileFormat(this, sfd.FileName);
            }
            GC.Collect();
        }
Ejemplo n.º 14
0
        private void SaveFile(object sender, EventArgs e)
        {
            var selected = GetSelectedTags <IFileFormat>();

            if (selected.Count == 0)
            {
                return;
            }

            SaveFileDialog sfd  = new SaveFileDialog();
            string         name = selected[0].FileInfo.FileName;

            sfd.FileName   = name;
            sfd.DefaultExt = System.IO.Path.GetExtension(name);
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                STFileSaver.SaveFileFormat(selected[0], sfd.FileName);
            }
        }
Ejemplo n.º 15
0
        private void SaveActiveFile(IFileFormat fileFormat, bool ForceDialog = false)
        {
            if (fileFormat.CanSave)
            {
                if (fileFormat.IFileInfo != null &&
                    fileFormat.IFileInfo.ArchiveParent != null && !ForceDialog)
                {
                    if (fileFormat is IEditorFormParameters)
                    {
                        ((IEditorFormParameters)fileFormat).OnSave.Invoke(fileFormat, new EventArgs());
                    }

                    MessageBox.Show($"Saved {fileFormat.FileName} to archive!");
                }
                else
                {
                    STFileSaver.SaveFileFormat(fileFormat, fileFormat.FilePath);
                }
            }
        }
Ejemplo n.º 16
0
        private void SaveAction(object sender, EventArgs args)
        {
            //Archive files are IFIleFormats
            var FileFormat = ((IFileFormat)ArchiveFile);

            Cursor.Current = Cursors.WaitCursor;
            List <IFileFormat> formats = new List <IFileFormat>();

            formats.Add(FileFormat);

            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter   = Utils.GetAllFilters(formats);
            sfd.FileName = FileFormat.FileName;

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                STFileSaver.SaveFileFormat(FileFormat, sfd.FileName);
            }
            GC.Collect();
        }
Ejemplo n.º 17
0
        private void SaveNodeFormats(ObjectEditor editor, bool UseSaveDialog, bool UseCompressDialog)
        {
            foreach (var node in editor.treeViewCustom1.Nodes)
            {
                if (node is IFileFormat)
                {
                    var format = ((IFileFormat)node);

                    if (!format.CanSave)
                    {
                        return;
                    }

                    string FileName = format.FilePath;
                    if (!File.Exists(FileName))
                    {
                        UseSaveDialog = true;
                    }

                    if (UseSaveDialog)
                    {
                        SaveFileDialog sfd = new SaveFileDialog();
                        sfd.Filter   = Utils.GetAllFilters(format);
                        sfd.FileName = format.FileName;

                        if (sfd.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }

                        FileName = sfd.FileName;
                    }
                    Cursor.Current = Cursors.WaitCursor;

                    STFileSaver.SaveFileFormat(((IFileFormat)node), FileName, UseCompressDialog);

                    Cursor.Current = Cursors.Default;
                }
            }
        }
Ejemplo n.º 18
0
            public void ConvertBEtoLE(object sender, EventArgs args)
            {
                var byamlF = new BYAML();

                byamlF.IFileInfo = new IFileInfo();

                OpenFileDialog ofd = new OpenFileDialog();

                ofd.Filter = Utils.GetAllFilters(byamlF);
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    byamlF.Load(new FileStream(ofd.FileName, FileMode.Open));
                    byamlF.BymlData.byteOrder = Syroot.BinaryData.ByteOrder.LittleEndian;

                    SaveFileDialog sfd = new SaveFileDialog();
                    sfd.Filter = Utils.GetAllFilters(byamlF);
                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        STFileSaver.SaveFileFormat(byamlF, sfd.FileName);
                    }
                }
            }
Ejemplo n.º 19
0
        private void SaveFileFormat(IFileFormat fileFormat, bool useDialog = false)
        {
            string filePath = fileFormat.FileInfo.FilePath;

            if (useDialog)
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.DefaultExt = Path.GetExtension(fileFormat.FileInfo.FileName);
                sfd.FileName   = fileFormat.FileInfo.FileName;
                if (sfd.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                filePath = sfd.FileName;
            }

            STFileSaver.SaveFileFormat(fileFormat, filePath);
            if (ActiveMdiChild is ObjectView && fileFormat.FileInfo.KeepOpen)
            {
                ((ObjectView)ActiveMdiChild).ReloadFile(fileFormat);
            }
        }
Ejemplo n.º 20
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("");
                Console.WriteLine("Tool made by KillzXGaming.");
                Console.WriteLine("Mdl research thanks to opeyx and SpaceCats.");
                Console.WriteLine("");
                Console.WriteLine("Arguments:");
                Console.WriteLine("");
                Console.WriteLine("Convert .mdl to .dae/.png/.json formats:");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("  ModelConverter.exe (target .mdl file)");
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("");
                Console.WriteLine("Create a new .mdl file:");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("  ModelConverter.exe (extracted .mdl folder or .dae) (originalFile.mdl)");
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("Optional Arguments:");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("-skel (Uses custom skeleton when creating new mdl)");
                Console.ForegroundColor = ConsoleColor.White;
                return;
            }

            string folder            = "";
            string target            = "";
            string originalMdlTarget = "";

            string appFolder = AppDomain.CurrentDomain.BaseDirectory;


            //Input is a folder
            if (Directory.Exists(args[0]))
            {
                folder = args[0];

                var daeFiles = Directory
                               .EnumerateFiles(folder, "*.*", SearchOption.AllDirectories)
                               .Where(s => Path.GetExtension(s).ToLowerInvariant() == ".dae").ToList();
                if (daeFiles.Count == 0)
                {
                    throw new Exception("No .dae files found in folder!");
                }

                target = daeFiles[0];
            }
            else
            {
                folder = Path.GetDirectoryName(args[0]);
                target = args[0];
            }

            if (Utils.GetExtension(target) == ".dae")
            {
                if (args.Length > 1)
                {
                    originalMdlTarget = args[1];
                }
                else if (File.Exists($"{folder}.mdl"))
                {
                    originalMdlTarget = $"{folder}.mdl";
                }
                else if (File.Exists(target.Replace(".dae", ".mdl")))
                {
                    originalMdlTarget = target.Replace(".dae", ".mdl");
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Error! Make sure you input the original .mdl file.");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("");
                    Console.WriteLine("  ModelConverter.exe (extracted .mdl folder or .dae) (originalFile.mdl)");
                    Console.ForegroundColor = ConsoleColor.White;
                    return;
                }
            }

            var importedModel = (IModelFormat)STFileLoader.OpenFileFormat(target);

            if (importedModel is MDL)
            {
                ExportModel((MDL)importedModel);
            }
            else
            {
                var importModel = importedModel.ToGeneric();
                importModel.OrderBones(importModel.Skeleton.Bones.OrderBy(x => GetBoneIndex(x.Name)).ToList());
                //Load any extra texture maps not referenced by the model itself for texture animations
                foreach (var file in Directory.GetFiles(Path.GetDirectoryName(target)))
                {
                    if (Utils.GetExtension(file) == ".png")
                    {
                        string texname = Path.GetFileNameWithoutExtension(file);
                        if (!importModel.Textures.Any(x => x.Name == texname))
                        {
                            importModel.Textures.Add(new GenericBitmapTexture(file));
                        }
                    }
                }

                if (originalMdlTarget != string.Empty && !args.Contains("-skel"))
                {
                    var mdl = (IModelFormat)STFileLoader.OpenFileFormat(originalMdlTarget);
                    importModel.Skeleton = mdl.ToGeneric().Skeleton;

                    //Recalculate the bone indices on the original skeleton
                    foreach (var mesh in importModel.Meshes)
                    {
                        for (int v = 0; v < mesh.Vertices.Count; v++)
                        {
                            for (int j = 0; j < mesh.Vertices[v].BoneNames.Count; j++)
                            {
                                var boneName  = mesh.Vertices[v].BoneNames[j];
                                var boneIndex = importModel.Skeleton.Bones.FindIndex(x => x.Name == boneName);
                                mesh.Vertices[v].BoneIndices[j] = boneIndex;
                            }
                        }
                    }
                }

                var model = new MDL();
                model.FileInfo = new File_Info();
                model.Header   = new MDL_Parser();

                if (File.Exists($"{folder}\\SamplerList.json"))
                {
                    string json = File.ReadAllText($"{folder}\\SamplerList.json");
                    model.ReplaceSamplers(json);
                }

                STGenericScene scene = new STGenericScene();
                scene.Models.Add(importModel);
                model.FromGeneric(scene);

                //Reset the indices and assign by json file
                foreach (var node in model.Header.Nodes)
                {
                    node.ShapeCount = 0;
                    node.ShapeIndex = 0;
                }

                Node[] nodeList = new Node[model.Header.Nodes.Length];
                for (int i = 0; i < nodeList.Length; i++)
                {
                    nodeList[i] = new Node();
                }


                var drawElements = model.Header.DrawElements;
                for (int i = 0; i < importModel.Meshes.Count; i++)
                {
                    ushort nodeIndex = 0;

                    //Check both the default and the imported mesh names. and inject data to these slots
                    if (File.Exists($"{folder}\\{importModel.Meshes[i].Name}.json"))
                    {
                        string json = File.ReadAllText($"{folder}\\{importModel.Meshes[i].Name}.json");
                        nodeIndex = model.ReplaceMaterial(json, drawElements[i]);
                    }
                    else if (File.Exists($"{appFolder}\\Defaults.json"))
                    {
                        string json = File.ReadAllText($"{appFolder}\\Defaults.json");
                        nodeIndex = model.ReplaceMaterial(json, drawElements[i]);
                    }

                    //Here we add our draw elements to the assigned node they use from the json files
                    if (nodeIndex < model.Header.Nodes.Length)
                    {
                        nodeList[nodeIndex].DrawElements.Add(drawElements[i]);
                    }
                    else
                    {
                        nodeList[0].DrawElements.Add(drawElements[i]);
                    }
                }

                //Create a new draw list in proper order
                List <DrawElement> sortedElements = new List <DrawElement>();
                for (int i = 0; i < nodeList.Length; i++)
                {
                    sortedElements.AddRange(nodeList[i].DrawElements);
                }

                model.Header.DrawElements = sortedElements.ToArray();

                //Set the referenced draw elements/shapes used for the node lists
                ushort index = 0;
                for (int i = 0; i < nodeList.Length; i++)
                {
                    model.Header.Nodes[i].ShapeIndex = index;
                    model.Header.Nodes[i].ShapeCount = (ushort)nodeList[i].DrawElements.Count;

                    index += (ushort)nodeList[i].DrawElements.Count;
                }

                Console.WriteLine("Saving file..");

                string name = Path.GetFileName(folder);
                STFileSaver.SaveFileFormat(model, $"{name}.new.mdl");

                Console.WriteLine($"Saved model " + $"{name}.new.mdl!");
            }
        }
Ejemplo n.º 21
0
        public static void GenerateProbeBoundings()
        {
            OpenFileDialog ofd1 = new OpenFileDialog();

            ofd1.Filter = Utils.GetAllFilters(typeof(AAMP));
            if (ofd1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            //Load the AAMP
            var File = STFileLoader.OpenFileFormat(ofd1.FileName);

            if (File == null || !(File is AAMP))
            {
                throw new Exception("File not a valid AAMP file!");
            }

            //Load bfres for generating the bounds
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = Utils.GetAllFilters(typeof(BFRES));

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                //Open and check bfres
                var Bfres = STFileLoader.OpenFileFormat(ofd.FileName);
                if (Bfres == null || !(Bfres is BFRES))
                {
                    throw new Exception("File not a valid BFRES file!");
                }

                //Check version instance
                if (((AAMP)File).aampFileV1 != null)
                {
                    foreach (var val in ((AAMP)File).aampFileV1.RootNode.childParams)
                    {
                        foreach (var param in val.paramObjects)
                        {
                            switch (param.HashString)
                            {
                            case "grid":
                                GenerateGridData((BFRES)Bfres, param.paramEntries);
                                break;
                            }
                        }
                    }

                    foreach (var param in ((AAMP)File).aampFileV1.RootNode.paramObjects)
                    {
                        switch (param.HashString)
                        {
                        case "root_grid":
                            GenerateGridData((BFRES)Bfres, param.paramEntries);
                            break;
                        }
                    }
                }
                else
                {
                    foreach (var val in ((AAMP)File).aampFileV2.RootNode.childParams)
                    {
                        foreach (var param in val.paramObjects)
                        {
                            switch (param.HashString)
                            {
                            case "grid":
                                GenerateGridData((BFRES)Bfres, param.paramEntries);
                                break;
                            }
                        }
                    }

                    foreach (var param in ((AAMP)File).aampFileV2.RootNode.paramObjects)
                    {
                        switch (param.HashString)
                        {
                        case "root_grid":
                            GenerateGridData((BFRES)Bfres, param.paramEntries);
                            break;
                        }
                    }
                }

                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Filter = Utils.GetAllFilters(File);
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    //Save the aamp back
                    STFileSaver.SaveFileFormat(File, sfd.FileName);
                }

                File.Unload();
                Bfres.Unload();
            }
        }
Ejemplo n.º 22
0
        public void SaveActiveFile(bool UseSaveDialog = true, bool UseCompressDialog = true)
        {
            if (ActiveMdiChild != null)
            {
                if (ActiveMdiChild is ObjectEditor)
                {
                    SaveNodeFormats((ObjectEditor)ActiveMdiChild, UseSaveDialog, UseCompressDialog);
                }
                else
                {
                    var format = GetActiveIFileFormat();

                    if (!format.CanSave)
                    {
                        return;
                    }

                    string FileName = format.FilePath;
                    if (!File.Exists(FileName))
                    {
                        UseSaveDialog = true;
                    }

                    if (UseSaveDialog)
                    {
                        if (format is VGAdudioFile)
                        {
                            SaveFileDialog sfd = new SaveFileDialog();

                            List <IFileFormat> formats = new List <IFileFormat>();
                            foreach (VGAdudioFile fileFormat in FileManager.GetVGAudioFileFormats())
                            {
                                formats.Add((IFileFormat)fileFormat);
                            }
                            sfd.Filter = Utils.GetAllFilters(formats);

                            if (sfd.ShowDialog() != DialogResult.OK)
                            {
                                return;
                            }

                            foreach (var fileFormat in formats)
                            {
                                foreach (var ext in format.Extension)
                                {
                                    if (Utils.HasExtension(sfd.FileName, ext))
                                    {
                                        ((VGAdudioFile)format).Format = fileFormat;
                                    }
                                }
                            }

                            FileName = sfd.FileName;
                        }
                        else
                        {
                            SaveFileDialog sfd = new SaveFileDialog();
                            sfd.Filter   = Utils.GetAllFilters(format);
                            sfd.FileName = format.FileName;

                            if (sfd.ShowDialog() != DialogResult.OK)
                            {
                                return;
                            }

                            FileName = sfd.FileName;
                        }
                    }
                    Cursor.Current = Cursors.WaitCursor;
                    STFileSaver.SaveFileFormat(format, FileName, UseCompressDialog);
                    Cursor.Current = Cursors.Default;
                }
            }
        }