private void buttonResolveAll_Click(object sender, EventArgs e)
        {
            Dictionary <AsyncAction, AsyncAction> actions = new Dictionary <AsyncAction, AsyncAction>();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                PreCheckItemRow preCheckRow = row as PreCheckItemRow;
                if (preCheckRow != null && preCheckRow.Problem != null)
                {
                    bool        cancelled;
                    AsyncAction action = preCheckRow.Problem.SolveImmediately(out cancelled);
                    if (action != null)
                    {
                        actions.Add(action, preCheckRow.Problem.UnwindChanges());
                    }
                }
            }
            foreach (var asyncAction in actions.Keys)
            {
                _progressDialog = new ActionProgressDialog(asyncAction, ProgressBarStyle.Blocks);
                _progressDialog.ShowDialog(this);

                if (asyncAction.Succeeded && actions[asyncAction] != null)
                {
                    RevertActions.Add(actions[asyncAction]);
                }
                Program.Invoke(Program.MainWindow, RefreshRechecks);
            }
            Program.Invoke(Program.MainWindow, RefreshRechecks);
        }
        public override bool EnableNext()
        {
            int problemsCount = 0;

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                PreCheckItemRow preCheckRow = row as PreCheckItemRow;
                if (preCheckRow != null && preCheckRow.IsProblem)
                {
                    problemsCount++;
                }
            }

            if (_worker != null && _worker.IsBusy)
            {
                labelPrecheckStatus.Text = Messages.DR_WIZARD_PRECHECKPAGE_STATUS_RUNNING;
            }
            else
            {
                labelPrecheckStatus.Text = problemsCount > 0
                                               ? string.Format(Messages.DR_WIZARD_PRECHECKPAGE_STATUS_FAILURE, problemsCount)
                                               : Messages.DR_WIZARD_PRECHECKPAGE_STATUS_SUCCESS;
            }

            bool result = _worker != null && !_worker.IsBusy && problemsCount == 0;

            panelErrorsFound.Visible = !result;
            labelContinue.Visible    = result;

            return(result);
        }
            public override bool Equals(object obj)
            {
                PreCheckItemRow other = obj as PreCheckItemRow;

                if (other != null && other.Problem != null && _problem != null)
                {
                    return(_problem.CompareTo(other.Problem) == 0);
                }
                return(false);
            }
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            PreCheckItemRow preChecRow = dataGridView1.Rows[e.RowIndex] as PreCheckItemRow;

            if (preChecRow != null && e.ColumnIndex == 2)
            {
                ExecuteSolution(preChecRow);
                return;
            }
        }
        private void ExecuteSolution(PreCheckItemRow preCheckRow)
        {
            bool        cancelled;
            AsyncAction action = preCheckRow.Problem.SolveImmediately(out cancelled);

            if (action != null)
            {
                action.Completed += action_Completed;
                _progressDialog   = new ActionProgressDialog(action, ProgressBarStyle.Blocks);
                _progressDialog.ShowDialog(this);
                if (action.Succeeded)
                {
                    var revertAction = preCheckRow.Problem.UnwindChanges();
                    if (revertAction != null)
                    {
                        RevertActions.Add(revertAction);
                    }
                }
            }
        }
        void _worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (!e.Cancelled)
            {
                OnPageUpdated();
            }
            progressBar1.Value = 100;
            bool problemsFound = false;

            foreach (PreCheckGridRow row in dataGridView1.Rows)
            {
                PreCheckItemRow preCheckRow = row as PreCheckItemRow;
                if (preCheckRow != null && preCheckRow.Problem != null)
                {
                    problemsFound = true;
                    break;
                }
            }
            buttonResolveAll.Enabled      = problemsFound;
            buttonReCheckProblems.Enabled = true;
        }
        void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            try
            {
                var row = e.UserState as DataGridViewRow;
                if (row != null && !dataGridView1.Rows.Contains(row))
                {
                    PreCheckItemRow preCheckRow = row as PreCheckItemRow;
                    if (preCheckRow != null && preCheckRow.IsProblem)
                    {
                        preCheckRow.Visible = true;
                    }
                    else
                    {
                        row.Visible = !checkBoxViewPrecheckFailuresOnly.Checked;
                    }
                    dataGridView1.Rows.Add(row);
                }

                int step = (int)((1.0 / ((float)_numberChecks)) * e.ProgressPercentage);
                progressBar1.Value += (step + progressBar1.Value) > 100 ? 0 : step;
            }
            catch (Exception) { }
        }
 private void ExecuteSolution(PreCheckItemRow preCheckRow)
 {
     bool cancelled;
     AsyncAction action = preCheckRow.Problem.SolveImmediately(out cancelled);
     if (action != null)
     {
         action.Completed += action_Completed;
         _progressDialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks);
         _progressDialog.ShowDialog(this);
         if (action.Succeeded)
         {
             var revertAction = preCheckRow.Problem.UnwindChanges();
             if (revertAction != null)
                 RevertActions.Add(revertAction);
         }
     }
 }