/// <summary> /// Loads info about the color into a slider and a rectangle /// </summary> private void LoadColorInformation(FadeColor color) { colorRect.Fill = new SolidColorBrush(Color.FromRgb(color.r, color.g, color.b)); redSlider.Value = color.r; redTbx.Text = color.r.ToString(); greenSlider.Value = color.g; greenTbx.Text = color.g.ToString(); blueSlider.Value = color.b; blueTbx.Text = color.b.ToString(); alphaSlider.Value = color.a; alphaTbx.Text = color.a.ToString(); }
/// <summary> /// Repaints a gradient /// </summary> private void RepaintFade() { TableDrawingManager.color_changed = true; LinearGradientBrush colorBrush = new LinearGradientBrush(); LinearGradientBrush alphaBrush = new LinearGradientBrush(); colorBrush.StartPoint = new Point(0, 0); colorBrush.EndPoint = new Point(1, 0); alphaBrush.StartPoint = new Point(0, 0); alphaBrush.EndPoint = new Point(1, 0); foreach (Ellipse el in fadeMarks) { FadeColor color = (FadeColor)el.DataContext; colorBrush.GradientStops.Add(new GradientStop(Color.FromRgb(color.r, color.g, color.b), color.position)); alphaBrush.GradientStops.Add(new GradientStop(Color.FromRgb(color.a, color.a, color.a), color.position)); } fadeRect.Fill = colorBrush; alphaRect.Fill = alphaBrush; }
/// <summary> /// Inserts a new marker /// </summary> private void addBut_Click(object sender, RoutedEventArgs e) { FadeColor defaultColor = new FadeColor(0, 0, 0, 255, 0.5); Ellipse mark = new Ellipse(); mark.Width = 8; mark.Height = 8; mark.Margin = new Thickness(defaultColor.position * fadeRect.Width, 0, 0, 0); mark.Margin = new Thickness(defaultColor.position * fadeRect.Width, 0, 0, 0); mark.HorizontalAlignment = HorizontalAlignment.Left; mark.VerticalAlignment = VerticalAlignment.Bottom; mark.DataContext = defaultColor; mark.Fill = unselectedBrush; mark.MouseDown += new MouseButtonEventHandler(mark_MouseDown); mark.MouseUp += new MouseButtonEventHandler(mark_MouseUp); mark.MouseMove += new MouseEventHandler(mark_MouseMove); Grid.SetRow(mark, 1); paintGrid.Children.Add(mark); fadeMarks.Add(mark); UnSelectEllipse(); SelectEllipse(mark); RepaintFade(); }