private void BgwProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            if (e.UserState == null)
            {
                if (e.ProgressPercentage >= progressBar.Minimum && e.ProgressPercentage <= progressBar.Maximum)
                {
                    progressBar.Value = e.ProgressPercentage;
                }
                return;
            }
            bgwSetRange bgwSr = e.UserState as bgwSetRange;

            if (bgwSr != null)
            {
                progressBar.Minimum = 0;
                progressBar.Maximum = bgwSr.MaxVal;
                progressBar.Value   = 0;
                return;
            }

            bgwText bgwT = e.UserState as bgwText;

            if (bgwT != null)
            {
                lblStatus.Text = bgwT.Text;
            }
        }
        private void BgwProgressChanged(object e)
        {
            bgwShowFix bgwSf = e as bgwShowFix;

            if (bgwSf != null)
            {
                DataGridViewRow dgrq = (DataGridViewRow)dataGridView1.RowTemplate.Clone();
                dgrq.CreateCells(dataGridView1, bgwSf.FixDir, bgwSf.FixZip, bgwSf.FixFile, bgwSf.Size, bgwSf.Dir, bgwSf.SourceDir, bgwSf.SourceZip, bgwSf.SourceFile);
                _rowQueue.Enqueue(dgrq);
                return;
            }

            bgwShowFixError bgwSFE = e as bgwShowFixError;

            if (bgwSFE != null)
            {
                int iRow = dataGridView1.Rows.Count - 1;
                dataGridView1.Rows[iRow].Cells[4].Style.BackColor = Color.Red;
                dataGridView1.Rows[iRow].Cells[4].Style.ForeColor = Color.Black;
                dataGridView1.Rows[iRow].Cells[4].Value           = bgwSFE.FixError;
                return;
            }

            bgwProgress bgwProg = e as bgwProgress;

            if (bgwProg != null)
            {
                if (bgwProg.Progress >= progressBar.Minimum && bgwProg.Progress <= progressBar.Maximum)
                {
                    progressBar.Value = bgwProg.Progress;
                }
                UpdateStatusText();
                return;
            }

            bgwText bgwT = e as bgwText;

            if (bgwT != null)
            {
                label.Text = bgwT.Text;
                return;
            }
            bgwSetRange bgwSR = e as bgwSetRange;

            if (bgwSR != null)
            {
                progressBar.Minimum = 0;
                progressBar.Maximum = bgwSR.MaxVal >= 0 ? bgwSR.MaxVal : 0;
                progressBar.Value   = 0;
                UpdateStatusText();
            }
        }
Exemple #3
0
        private void BgwProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            if (e.UserState == null)
            {
                if (e.ProgressPercentage >= progressBar.Minimum && e.ProgressPercentage <= progressBar.Maximum)
                {
                    progressBar.Value = e.ProgressPercentage;
                }
                UpdateStatusText();
                return;
            }

            bgwText bgwT = e.UserState as bgwText;

            if (bgwT != null)
            {
                label.Text = bgwT.Text;
                return;
            }
            bgwSetRange bgwSR = e.UserState as bgwSetRange;

            if (bgwSR != null)
            {
                progressBar.Minimum = 0;
                progressBar.Maximum = bgwSR.MaxVal >= 0 ? bgwSR.MaxVal : 0;
                progressBar.Value   = 0;
                UpdateStatusText();
                return;
            }


            bgwText2 bgwT2 = e.UserState as bgwText2;

            if (bgwT2 != null)
            {
                label2.Text = bgwT2.Text;
                return;
            }

            bgwValue2 bgwV2 = e.UserState as bgwValue2;

            if (bgwV2 != null)
            {
                if (bgwV2.Value >= progressBar2.Minimum && bgwV2.Value <= progressBar2.Maximum)
                {
                    progressBar2.Value = bgwV2.Value;
                }
                UpdateStatusText2();
                return;
            }

            bgwSetRange2 bgwSR2 = e.UserState as bgwSetRange2;

            if (bgwSR2 != null)
            {
                progressBar2.Minimum = 0;
                progressBar2.Maximum = bgwSR2.MaxVal >= 0 ? bgwSR2.MaxVal : 0;
                progressBar2.Value   = 0;
                UpdateStatusText2();
                return;
            }
            bgwRange2Visible bgwR2V = e.UserState as bgwRange2Visible;

            if (bgwR2V != null)
            {
                label2.Visible       = bgwR2V.Visible;
                progressBar2.Visible = bgwR2V.Visible;
                lbl2Prog.Visible     = bgwR2V.Visible;
                return;
            }


            bgwText3 bgwT3 = e.UserState as bgwText3;

            if (bgwT3 != null)
            {
                label3.Text = bgwT3.Text;
                return;
            }

            bgwShowCorrupt bgwSC = e.UserState as bgwShowCorrupt;

            if (bgwSC != null)
            {
                if (!_errorOpen)
                {
                    _errorOpen      = true;
                    ClientSize      = new Size(511, 292);
                    MinimumSize     = new Size(511, 292);
                    FormBorderStyle = FormBorderStyle.SizableToolWindow;
                }

                ErrorGrid.Rows.Add();
                int row = ErrorGrid.Rows.Count - 1;

                ErrorGrid.Rows[row].Cells["CError"].Value           = bgwSC.zr;
                ErrorGrid.Rows[row].Cells["CError"].Style.ForeColor = Color.FromArgb(255, 0, 0);

                ErrorGrid.Rows[row].Cells["CErrorFile"].Value           = bgwSC.filename;
                ErrorGrid.Rows[row].Cells["CErrorFile"].Style.ForeColor = Color.FromArgb(255, 0, 0);

                if (row >= 0)
                {
                    ErrorGrid.FirstDisplayedScrollingRowIndex = row;
                }
            }



            bgwShowError bgwSDE = e.UserState as bgwShowError;

            if (bgwSDE != null)
            {
                if (!_errorOpen)
                {
                    _errorOpen      = true;
                    ClientSize      = new Size(511, 292);
                    MinimumSize     = new Size(511, 292);
                    FormBorderStyle = FormBorderStyle.SizableToolWindow;
                }

                ErrorGrid.Rows.Add();
                int row = ErrorGrid.Rows.Count - 1;

                ErrorGrid.Rows[row].Cells["CError"].Value           = bgwSDE.error;
                ErrorGrid.Rows[row].Cells["CError"].Style.ForeColor = Color.FromArgb(255, 0, 0);

                ErrorGrid.Rows[row].Cells["CErrorFile"].Value           = bgwSDE.filename;
                ErrorGrid.Rows[row].Cells["CErrorFile"].Style.ForeColor = Color.FromArgb(255, 0, 0);

                if (row >= 0)
                {
                    ErrorGrid.FirstDisplayedScrollingRowIndex = row;
                }
            }
        }