Esempio n. 1
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (e.CloseReason == CloseReason.UserClosing)
     {
         var result = TaskDialogEx.Confirm(this, "Are you sure you want to cancel conversion?");
         if (result != DialogResult.Yes)
         {
             e.Cancel = true;
         }
     }
 }
Esempio n. 2
0
        private void StartConversion(Arguments arguments)
        {
            string path = Path.GetFullPath(arguments.Directory);

            if (path[path.Length - 1] == Path.DirectorySeparatorChar)
            {
                path = path.Substring(0, path.Length - 1);
            }

            var files = new List <string>();

            ProgressForm.Show(this, Text, progress =>
            {
                progress.SetLabel("Finding files to convert");
                progress.SetProgress(-1);

                foreach (string fileName in Directory.GetFiles(path, "*.wav", SearchOption.AllDirectories))
                {
                    if (!fileName.StartsWith(path, StringComparison.OrdinalIgnoreCase))
                    {
                        throw new Exception("Expected found path to start with prefix");
                    }
                    string subFileName = fileName.Substring(path.Length);

                    if (Include(subFileName, arguments))
                    {
                        files.Add(fileName);
                    }
                }
            });

            if (files.Count == 0)
            {
                TaskDialogEx.Error(this, "Found no files to convert.", icon: TaskDialogIcon.Information);
                Dispose();
                return;
            }

            var controls = QueueFiles(files);

            var result = TaskDialogEx.Confirm(this, $"Found {files.Count} to convert. Do you want to start the conversion?", icon: TaskDialogIcon.Information);

            if (result != DialogResult.Yes)
            {
                Dispose();
                return;
            }

            StartConversion(files, controls, arguments);
        }