颜色拾取

 

 

 

 

/// <summary>
/// 颜色拾取
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void color_Click(object sender, RoutedEventArgs e)
{
System.Windows.Forms.ColorDialog colorDialog = new System.Windows.Forms.ColorDialog();
colorDialog.SolidColorOnly = true;
if (colorDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
System.Drawing.SolidBrush sb = new System.Drawing.SolidBrush(colorDialog.Color);
SolidColorBrush solidColorBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(sb.Color.A, sb.Color.R, sb.Color.G, sb.Color.B));
(sender as System.Windows.Controls.Button).Background = solidColorBrush;
}
}

posted @ 2020-12-18 10:43  林新i  阅读(78)  评论(0编辑  收藏  举报