示例#1
0
 void OnProcessExited(object sender, EventArgs e)
 {
     if (RunButton.InvokeRequired)
     {
         RunButton.Invoke(new MethodInvoker(delegate() { RunButton.Enabled = true; }));
     }
     AddToListbox("******Done******");
     AddToListbox("      ");
 }
示例#2
0
        private void Thread_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            Action <int> Method = UpdateMethod;

            if (e.ProgressPercentage < 60)
            {
                LabelPercentage.ForeColor = Color.Black;
            }
            else
            {
                LabelPercentage.ForeColor = Color.White;
            }

            LabelPercentage.Text = e.ProgressPercentage + "%";
            RunButton.Invoke(Method, e.ProgressPercentage);
            StatusText.Text = "Testiranje u toku... (" + e.ProgressPercentage.ToString() + "%)";
            Update();
        }
        private void RefreshData()
        {
            PartsGrid.Invoke(new MethodInvoker(delegate
            {
                PartsGrid.DataSource             = _parts.Parts.ToList();
                PartsGrid.Columns["_id"].Visible = false;

                Parallel.ForEach(PartsGrid.Rows.OfType <DataGridViewRow>(), row =>
                {
                    var _part = _parts.Parts.Find(x => x._id == row.Cells["_id"].Value);
                    if (_part != null)
                    {
                        switch (_part.status)
                        {
                        case PartClass.Status.Completed: row.DefaultCellStyle.BackColor = Color.LightGreen; break;

                        case PartClass.Status.Unknown: row.DefaultCellStyle.BackColor = Color.LightGray; break;

                        case PartClass.Status.Ready: row.DefaultCellStyle.BackColor = Color.LightYellow; break;

                        case PartClass.Status.Resolving: row.DefaultCellStyle.BackColor = Color.LightBlue; break;

                        case PartClass.Status.Target_Partition_Not_Found: row.DefaultCellStyle.BackColor = Color.LightPink; break;

                        case PartClass.Status.Part_Not_Found: row.DefaultCellStyle.BackColor = Color.LightPink; break;
                        }
                    }
                });

                PartsGrid.ClearSelection();
            }));

            RunButton.Invoke(new MethodInvoker(delegate
            {
                if (_parts.Parts.FindAll(x => x.status == PartClass.Status.Ready).Count > 0)
                {
                    RunButton.Enabled = true;
                }
                else
                {
                    RunButton.Enabled = false;
                }
            }));
        }