Example #1
0
 public void UpdateColor()
 {
     if (!_updatingColor)
     {
         _updatingColor = true;
         Color          = ColorUtilities.ColorFromAhsb(0xff, Hue, Saturation, Brightness);
         _updatingColor = false;
     }
 }
Example #2
0
        /// <summary>
        /// When overridden in a derived class, participates in rendering operations that are directed by the layout system. The rendering instructions for this element are not used directly when this method is invoked, and are instead preserved for later asynchronous use by layout and drawing.
        /// </summary>
        /// <param name="drawingContext">The drawing instructions for a specific element. This context is provided to the layout system.</param>
        protected override void OnRender(DrawingContext drawingContext)
        {
            Pen blackPen = new Pen(Brushes.Black, 1), whitePen = new Pen(Brushes.White, 3);

            // Draw the color as two overlapping gradients.
            LinearGradientBrush brush = new LinearGradientBrush
            {
                StartPoint    = new Point(0.0, 0.0),
                EndPoint      = new Point(1.0, 0.0),
                GradientStops =
                {
                    new GradientStop(Colors.White,                      0.0),
                    new GradientStop(ColorUtilities.ColorFromAhsb(0xff, Hue, 1, 1), 1.0)
                }
            };

            drawingContext.DrawRectangle(brush, null, new Rect(0.0, 0.0, ActualWidth, ActualHeight));

            brush = new LinearGradientBrush
            {
                StartPoint    = new Point(0.0, 0.0),
                EndPoint      = new Point(0.0, 1.0),
                GradientStops =
                {
                    new GradientStop(Colors.Black,        1.0),
                    new GradientStop(Color.FromArgb(0x80,    0, 0, 0), 0.5),
                    new GradientStop(Color.FromArgb(0,       0, 0, 0), 0.0)
                }
            };
            drawingContext.DrawRectangle(brush, blackPen, new Rect(0.0, 0.0, ActualWidth, ActualHeight));

            // Draw the current position
            drawingContext.PushClip(new RectangleGeometry(new Rect(0, 0, ActualWidth, ActualHeight)));

            Point markerCenter        = CalculateMarkerPosition();

            drawingContext.DrawEllipse(null, whitePen, markerCenter, 4, 4);
            drawingContext.DrawEllipse(null, blackPen, markerCenter, 4, 4);

            drawingContext.Pop();
        }
Example #3
0
 private void UpdateColor()
 {
     Color      = ColorUtilities.ColorFromAhsb(0xff, Hue, 1.0, 1.0);
     ColorBrush = new SolidColorBrush(Color);
     InvalidateVisual();
 }