private void OnMouseClick(object sender, MouseEventArgs e) { if (TopLeftHit == null) { return; } if (e.Button == MouseButtons.Left) { if (TopLeftHit.IsHit(e.Location)) { LoadColorDialog(TopLeftColor, 0); } if (TopRightHit.IsHit(e.Location)) { LoadColorDialog(TopRightColor, 1); } if (BottomLefttHit.IsHit(e.Location)) { LoadColorDialog(BottomLeftColor, 2); } if (BottomRightHit.IsHit(e.Location)) { LoadColorDialog(BottomRightColor, 3); } if (AllHit.IsHit(e.Location)) { if (dialogActive) { colorDlg.Focus(); return; } dialogActive = true; colorDlg = new STColorDialog(AllColor); colorDlg.Show(); colorDlg.FormClosed += delegate { dialogActive = false; }; colorDlg.ColorChanged += delegate { //Update only once! SuppressChangeEvent = true; TopLeftColor = colorDlg.NewColor; TopRightColor = colorDlg.NewColor; BottomLeftColor = colorDlg.NewColor; BottomRightColor = colorDlg.NewColor; SuppressChangeEvent = false; ColorChanged(); }; } } this.Invalidate(); }
private void imageBGComboBox_MouseClick(object sender, MouseEventArgs e) { if (dialogActive) { colorDlg.Focus(); return; } dialogActive = true; colorDlg = new STColorDialog(((PictureBox)sender).BackColor); colorDlg.AllowTransparency = false; colorDlg.FormClosed += delegate { dialogActive = false; }; colorDlg.ColorChanged += delegate { ((PictureBox)sender).BackColor = colorDlg.ColorRGB; Runtime.CustomPicureBoxBGColor = colorDlg.ColorRGB; UpdateBackgroundImage(); }; colorDlg.Show(); }