private void doButtonWork(Guna.UI2.WinForms.Guna2Button button, Guna.UI2.WinForms.Guna2CirclePictureBox statusMarker, Artifact a) { updateStatus(button, statusMarker, 2); if (button.Checked) { Task.Factory.StartNew(() => { a.create(); updateStatus(button, statusMarker, 1); }); } else { Task.Factory.StartNew(() => { a.remove(); updateStatus(button, statusMarker, 3); }); } }
private void updateStatus(Guna.UI2.WinForms.Guna2Button button, Guna.UI2.WinForms.Guna2CirclePictureBox statusMarker, int status) { switch (status) { case 1: statusMarker.BeginInvoke(new Action(() => statusMarker.FillColor = Color.Green)); button.BeginInvoke(new Action(() => { button.Text = "Disable"; button.Enabled = true; })); break; case 2: statusMarker.BeginInvoke(new Action(() => statusMarker.FillColor = Color.Yellow)); button.BeginInvoke(new Action(() => { button.Text = "Loading"; button.Enabled = false; })); break; case 3: statusMarker.BeginInvoke(new Action(() => statusMarker.FillColor = Color.Red)); button.BeginInvoke(new Action(() => { button.Text = "Enable"; button.Enabled = true; })); break; default: break; } }
private void Choice_Click(object sender, EventArgs e) { Guna.UI2.WinForms.Guna2CirclePictureBox ImageClicked = (Guna.UI2.WinForms.Guna2CirclePictureBox)sender; playerChoice = (Choice)Enum.Parse(typeof(Choice), ImageClicked.Name.Substring(5)); // delete pbox_ in the name of the button pbox_answer.Location = new Point((ImageClicked.Location.X + (ImageClicked.Width / 2) - (pbox_answer.Width / 2)), pbox_answer.Location.Y); }