Exemple #1
0
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            String[] filePaths = (String[])e.Argument;

            int numberProcessed = 1, progressPercentage = 0;
            int numberToProcess = filePaths.Length;

            foreach (var path in filePaths)
            {
                if (backgroundWorker.CancellationPending)
                {
                    e.Cancel = true;
                    break;
                }
                PhotoProcessor.ProcessImage(path);
                progressPercentage = (numberProcessed++ *100) / filePaths.Length;
                backgroundWorker.ReportProgress(progressPercentage);
            }
        }
Exemple #2
0
        public static void Main(String[] filePaths)
        {
            if (filePaths.Length < 1)
            {
                DisplayInstructions();
                return;
            }

            //If there's only 1 file don't bother to display the progress dialog.
            if (filePaths.Length == 1)
            {
                PhotoProcessor.ProcessImage(filePaths[0]);
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new ProgressDialog(filePaths));
            }
        }