private void Execute()
        {
            using (FolderBrowserDialog dialog = new FolderBrowserDialog())
            {
                dialog.Description = "Select the destination folder.";

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    destination = dialog.SelectedPath;
                    logger.Info($"Destination: {destination}");
                }
            }

            if (!String.IsNullOrWhiteSpace(destination) && Directory.Exists(destination))
            {
                IsEnabled = false;
                IsWorking = true;
                Progress  = 0;
                logger.Info($"Sources: {String.Join(", ", folders)}");
                WorkArgs args = new WorkArgs();
                args.Destination           = new DirectoryInfo(destination);
                args.Folders               = folders;
                args.MirrorFolders         = mirrorFolders;
                worker.DoWork             += BackgroundWork;
                worker.ProgressChanged    += BackgroundWorkProgress;
                worker.RunWorkerCompleted += BackgroundWorkComplete;
                worker.RunWorkerAsync(args);
            }
            else
            {
                MessageBox.Show("The destination does not exist.");
            }
        }
示例#2
0
        private void backgroundWorker_StartWork_DoWork(object sender, DoWorkEventArgs e)
        {
            WorkArgs args = e.Argument as WorkArgs;

            foreach (string f in args.files)
            {
                string           newFilePath = Path.Combine(Properties.Settings.Default.OutputPath, Path.GetFileNameWithoutExtension(f) + args.fileExtension);
                VideoConvertTask vt          = new VideoConvertTask(args.TaskContainer.Count + 1, f, newFilePath);
                args.TaskContainer.Add(vt);
            }
        }
        private void ButtonAcquire_Click(object sender, EventArgs e)
        {
            UpdateChart();
            SetUpWorker();

            var args = new WorkArgs()
            {
                ReadMode      = (string)comboBoxReadMode.SelectedItem,
                Accumulations = (int)numericAccumulations.Value,
                TrackCenter   = (int)numericYcenter.Value,
                TrackHeight   = (int)numericYheight.Value
            };

            worker.RunWorkerAsync(args);
            OnTaskStarted(EventArgs.Empty);
        }
示例#4
0
 private void btn_Add_Click(object sender, EventArgs e)
 {
     if (DialogResult.OK == openFileDialog_PickVideo.ShowDialog())
     {
         string[] files         = openFileDialog_PickVideo.FileNames;
         string   fileExtension = (this.radioButton_mp4.Checked ? ".mp4" : ".mov");
         WorkArgs args          = new WorkArgs
         {
             outputPath    = this.textBox_OutDir.Text,
             TaskContainer = Tasks,
             files         = files,
             fileExtension = fileExtension,
         };
         if (!backgroundWorker_AddTask.IsBusy)
         {
             backgroundWorker_AddTask.RunWorkerAsync(args);
         }
     }
 }
示例#5
0
        /// <summary>
        /// Execute the background worker and the protection process.
        /// </summary>
        /// <param name="parameter"></param>
        private void Execute(object parameter)
        {
            logger.Debug("Preparing background worker.");
            IsEnabled                  = false;
            WorkerProgress             = 0;
            errorCount                 = 0;
            protectedCount             = 0;
            worker.DoWork             += Work;
            worker.ProgressChanged    += WorkProgress;
            worker.RunWorkerCompleted += WorkComplete;
            var extensions  = Properties.Settings.Default.TargetedFileExtensions.Split('|');
            var passwordBox = parameter as PasswordBox;
            var workArgs    = new WorkArgs()
            {
                Folder      = targetFolder,
                Extensions  = extensions,
                PasswordBox = passwordBox
            };

            logger.Debug("Initiating worker.");
            worker.RunWorkerAsync(workArgs);
        }
示例#6
0
        private static void bw_UpdaterDoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
            WorkArgs         args   = e.Argument as WorkArgs;

            string inputName    = args.InputName;
            bool   importByFile = args.ImportByFile;

            if (importByFile)
            {
                ImportFile(inputName);
            }
            else
            {
                string[] files = Directory.GetFiles(inputName, "*.json");

                foreach (string file in files)
                {
                    ImportFile(file);
                }
            }
        }