Exemple #1
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);
        }
Exemple #2
0
        private void MainForm_Shown(object sender, EventArgs e)
        {
            Arguments arguments;

            try
            {
                arguments = Arguments.Parse(_args);
            }
            catch (Exception ex)
            {
                TaskDialogEx.Error(this, "Failed to parse arguments.", ex.Message);
                Dispose();
                return;
            }

            StartConversion(arguments);
        }