private void btn_Click(object sender, EventArgs e) { Button btn = sender as Button; if (btn == btnOtherColor) // 其他颜色 { this.Deactivate -= new EventHandler(ColorPicker_Deactivate); // 取消因失去焦点而消失 ColorDialog colorDialog = new ColorDialog(); if (colorDialog.ShowDialog() == DialogResult.OK) { selectedColor = colorDialog.Color; } colorDialog.Dispose(); SelectedColorChanged(selectedColor, EventArgs.Empty); } else if (btn == btnScreenColor) // 屏幕取色 { this.Deactivate -= new EventHandler(ColorPicker_Deactivate); // 取消因失去焦点而消失 GetScreenColorForm gscf = new GetScreenColorForm(); if (gscf.ShowDialog() == DialogResult.OK) { selectedColor = gscf.SelectColor; } gscf.Dispose(); SelectedColorChanged(selectedColor, EventArgs.Empty); } else if (btn != null)// 色块 { selectedColor = btn.BackColor; SelectedColorChanged(selectedColor, EventArgs.Empty); } }
private void btn_Click(object sender, EventArgs e) { Button btn = sender as Button; if (btn == btnOtherColor)// 其他颜色 { this.Deactivate -= new EventHandler(ColorPicker_Deactivate);// 取消因失去焦点而消失 ColorDialog colorDialog = new ColorDialog(); if (colorDialog.ShowDialog() == DialogResult.OK) { selectedColor = colorDialog.Color; } colorDialog.Dispose(); SelectedColorChanged(selectedColor, EventArgs.Empty); } else if (btn == btnScreenColor)// 屏幕取色 { this.Deactivate -= new EventHandler(ColorPicker_Deactivate);// 取消因失去焦点而消失 GetScreenColorForm gscf = new GetScreenColorForm(); if (gscf.ShowDialog() == DialogResult.OK) { selectedColor = gscf.SelectColor; } gscf.Dispose(); SelectedColorChanged(selectedColor, EventArgs.Empty); } else if (btn != null)// 色块 { selectedColor = btn.BackColor; SelectedColorChanged(selectedColor, EventArgs.Empty); } }