public void show(System.Windows.Forms.DataGridView A) { int i = 1; A.Invoke(new Action(() => A.Rows.Clear())); foreach (IUnit p in Arm) { if (p is ISA) { A.Invoke(new Action(() => A.Rows.Add(i, p.Type(), p.Helth(), p.MaxAttack(), ((ISA)p).Distance()))); } else { A.Invoke(new Action(() => A.Rows.Add(i, p.Type(), p.Helth(), p.MaxAttack(), ""))); } i++; } }
public void Update(string msg) { string[] words = msg.Split(new char[] { ' ' }); int i = Convert.ToInt16(words[1]); if (words[0].Equals("Красные")) { B.Invoke(new Action(() => B.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.DarkRed)); B.Invoke(new Action(() => B.Show())); System.Threading.Thread.Sleep(1000); } else { A.Invoke(new Action(() => A.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.DarkRed)); A.Invoke(new Action(() => A.Show())); System.Threading.Thread.Sleep(1000); } }
public void UpdateResult(DataTable result) { if (_dataGridView.InvokeRequired) { _dataGridView.Invoke( new Action( () => { _dataGridView.DataSource = result; } ) ); } else { _dataGridView.DataSource = result; } }