// 更换文字颜色返回事件 private void FrmChild_TextColorChangeBetweenForm(object sender, ColorChangeEventArgs e) { SolidColorBrush brush = new SolidColorBrush(e.Color); texxt.Foreground = brush; texxt.CaretBrush = brush; Writeinfo(); }
// 选中了某个预设颜色 private void Label_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { var b = sender as Label; Color color = (Color)ColorConverter.ConvertFromString(b.Background.ToString()); ColorChangeEventArgs ccea = new ColorChangeEventArgs(color); ColorChangeBetweenForm(this, ccea); this.Close(); }
// 取色返回事件 private void FrmChild_GetColorBetweenForm(object sender, ColorChangeEventArgs e) { tb_a.Text = ConvertString(e.Color.ToString().Substring(1, 2), 16, 10); tb_r.Text = ConvertString(e.Color.ToString().Substring(3, 2), 16, 10); tb_g.Text = ConvertString(e.Color.ToString().Substring(5, 2), 16, 10); tb_b.Text = ConvertString(e.Color.ToString().Substring(7, 2), 16, 10); GetColor.Background = new SolidColorBrush(e.Color); //ColorChangeBetweenForm(this, e); }
private void Grid_MouseMove(object sender, MouseEventArgs e) { POINT point; GetCursorPos(out point); Color color = GetPixelColor(new Point(point.X, point.Y)); ColorChangeEventArgs ccea = new ColorChangeEventArgs(color); ColorChangeBetweenForm(this, ccea); }
// 使用自定义颜色 private void Button_Click(object sender, RoutedEventArgs e) { try { int a = int.Parse(tb_a.Text); int r = int.Parse(tb_r.Text); int g = int.Parse(tb_g.Text); int b = int.Parse(tb_b.Text); if (a <= 0 || a > 255 || r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) { ; } else { string color = "#" + Pres(a) + Pres(r) + Pres(g) + Pres(b); ColorChangeEventArgs ccea = new ColorChangeEventArgs((Color)ColorConverter.ConvertFromString(color)); ColorChangeBetweenForm(this, ccea); this.Close(); } } catch { } }
// 更换背景颜色返回事件 private void FrmChild_BackgroundColorChangeBetweenForm(object sender, ColorChangeEventArgs e) { b_grid.Background = new SolidColorBrush(e.Color); Writeinfo(); }