Esempio n. 1
0
 private static void RunMultiDumper(ref Settings settings)
 {
     if (settings.MultidumperPath == null || settings.VgmFile == null || settings.InputFiles != null)
     {
         return;
     }
     // We normalize the VGM path here because we need to know its directory...
     settings.VgmFile = Path.GetFullPath(settings.VgmFile);
     // Check if we have WAVs. Note that we use "natural" sorting to make sure 10 comes after 9.
     settings.InputFiles = Directory.EnumerateFiles(
         Path.GetDirectoryName(settings.VgmFile) ?? throw new Exception($"Can't get path from VGM \"{settings.VgmFile}\""),
         Path.GetFileNameWithoutExtension(settings.VgmFile) + " - *.wav")
                           .OrderByAlphaNumeric(s => s)
                           .ToList();
     if (!settings.InputFiles.Any())
     {
         Console.WriteLine("Running MultiDumper...");
         // Let's run it
         var wrapper   = new MultiDumperWrapper(settings.MultidumperPath);
         var song      = wrapper.GetSongs(settings.VgmFile).First();
         var filenames = wrapper.Dump(song, d => Console.Write($"\r{d:P0}"));
         settings.InputFiles = filenames.OrderByAlphaNumeric(s => s).ToList();
         Console.WriteLine($" done. {settings.InputFiles.Count} files found.");
     }
     else
     {
         Console.WriteLine($"Skipping MultiDumper as {settings.InputFiles.Count} files were already present.");
     }
 }
Esempio n. 2
0
        private void OkButtonClick(object sender, EventArgs e)
        {
            if (!(Subsongs.SelectedItem is MultiDumperWrapper.Song song))
            {
                return;
            }

            if (song.GetLength() <= TimeSpan.Zero)
            {
                // Try to parse the text box
                if (!TimeSpan.TryParseExact(lengthBox.Text, "m\\:ss", null, out var length))
                {
                    return;
                }

                song.ForceLength = length;
            }

            OKButton.Enabled = false;

            // We start a task to wrap the load task
            Task.Factory.StartNew(() =>
            {
                try
                {
                    Filenames = _wrapper.Dump(song,
                                              progress =>
                    {
                        ProgressBar.BeginInvoke(
                            new Action(() => ProgressBar.Value = (int)(progress * 100)));
                    }).ToList();

                    BeginInvoke(new Action(() =>
                    {
                        DialogResult = DialogResult.OK;
                        Close();
                    }));
                }
                catch (Exception)
                {
                    BeginInvoke(new Action(() =>
                    {
                        DialogResult = DialogResult.Cancel;
                        Filenames    = null;
                        Close();
                    }));
                }
            });
        }
Esempio n. 3
0
        private void OkButtonClick(object sender, EventArgs e)
        {
            // We start a task to wrap the load task
            OKButton.Enabled = false;

            if (Subsongs.SelectedItem is MultiDumperWrapper.Song song)
            {
                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        Filenames = _wrapper.Dump(song,
                                                  progress =>
                        {
                            ProgressBar.BeginInvoke(
                                new Action(() => ProgressBar.Value = (int)(progress * 100)));
                        }).ToList();

                        BeginInvoke(new Action(() =>
                        {
                            DialogResult = DialogResult.OK;
                            Close();
                        }));
                    }
                    catch (Exception)
                    {
                        BeginInvoke(new Action(() =>
                        {
                            DialogResult = DialogResult.Cancel;
                            Filenames    = null;
                            Close();
                        }));
                    }
                });
            }
        }