Exemplo n.º 1
0
        //--------------------------------
        #region Converting

        private void OnConvert(object sender, RoutedEventArgs e)
        {
            string input       = Config.Convert.CurrentInput;
            string output      = (Config.Convert.UseInput ? Config.Convert.CurrentInput : Config.Convert.CurrentOutput);
            bool   allowImages = Config.Convert.AllowImages;
            bool   allowSounds = Config.Convert.AllowSounds;

            Thread thread;

            if (Config.Convert.Mode == InputModes.Folder)
            {
                if (!Helpers.DirectoryExistsSafe(input))
                {
                    TriggerMessageBox.Show(this, MessageIcon.Warning, "Could not find the input folder.", "Invalid Path");
                    return;
                }
                if (!Helpers.IsPathValid(output))
                {
                    TriggerMessageBox.Show(this, MessageIcon.Warning, "Output folder path is invalid.", "Invalid Path");
                    return;
                }
                input  = Helpers.FixPathSafe(input);
                output = Helpers.FixPathSafe(output);
                thread = new Thread(() => {
                    Processing.ConvertAll(input, output, allowImages, allowSounds);
                });
            }
            else
            {
                if (!Helpers.FileExistsSafe(input))
                {
                    TriggerMessageBox.Show(this, MessageIcon.Warning, "Could not find the input file", "Invalid Path");
                    return;
                }
                if (!Helpers.IsPathValid(output))
                {
                    TriggerMessageBox.Show(this, MessageIcon.Warning, "Output file path is invalid.", "Invalid Path");
                    return;
                }
                input  = Helpers.FixPathSafe(input);
                output = Helpers.FixPathSafe(output);
                thread = new Thread(() => {
                    Processing.ConvertSingleFile(input, output);
                });
            }
            Processing.StartProgressThread(this, "Converting...", Config.AutoCloseProgress, Config.CompressImages, Config.CompletionSound, thread);
        }