Example #1
0
        /// <summary>
        /// Begins progress display where client manually updates progress</summary>
        /// <param name="message">Message to display with progress meter</param>
        /// <param name="canCancel">Should the cancel button appear and be enabled?</param>
        /// <param name="argument">Worker argument</param>
        /// <param name="workHandler">Background thread delegate</param>
        /// <param name="autoIncrement">Whether to auto increment the progress meter</param>
        /// <returns>True if the thread was cancelled</returns>
        public bool RunProgressDialog(string message, bool canCancel, object argument, DoWorkEventHandler workHandler, bool autoIncrement)
        {
            var vm = new ProgressViewModel()
            {
                Cancellable     = canCancel,
                Description     = message,
                IsIndeterminate = autoIncrement
            };

            vm.RunWorkerThread(argument, workHandler);

            ProgressDialog progressDialog = new ProgressDialog();

            progressDialog.DataContext = vm;
            progressDialog.Owner       = DialogUtil.GetActiveWindow();
            progressDialog.ShowDialog();

            ProgressResult = vm.Result;
            ProgressError  = vm.Error;

            return(vm.Cancelled);
        }