Esempio n. 1
0
        /// <summary>
        /// Updates the Color Wheel based on input from color source.
        /// </summary>
        /// <param name="rgb"></param>
        private HSV SetColorWheelLocation(RGB rgb)
        {
            Grid    grid    = this.FindName("ColorWheel") as Grid;
            Ellipse ellipse = this.FindName("ColorWheelCircle") as Ellipse;

            HSV hsv = ColorConverter.RGBtoHSV(rgb);

            double angle  = (Math.PI / 180) * hsv.H;
            double radian = (grid.Width / 2) * hsv.S;
            double x      = radian * Math.Cos(angle);
            double y      = radian * Math.Sin(angle);

            // UI elements to have new color value
            CurrentColor = rgb;

            ellipse.Fill = rgb.CreateSolidColorBrush();

            ellipse.Margin = new Thickness(
                x + grid.Width / 2,
                y + grid.Height / 2,
                0,
                0);

            return(hsv);
        }
Esempio n. 2
0
        /// <summary>
        /// Colors the power button with the provided highlight.
        /// </summary>
        /// <param name=""></param>
        private void ShowHightlightColor(ButtonState powerButtonState)
        {
            // Entity name should match current color for Dark theme only
            if (RequestedTheme == ElementTheme.Dark)
            {
                TextBlock textBlock = FindName("DeviceText") as TextBlock;
                textBlock.Foreground = CurrentColor.CreateSolidColorBrush();
            }

            // Power button should also match but only when enabled and not in a pressed state
            BitmapIcon bitmapIcon = this.FindName("ButtonPower") as BitmapIcon;

            if (powerButtonState == ButtonState.NotPressed)
            {
                if (string.Equals(PanelEntity.State, "on", StringComparison.InvariantCultureIgnoreCase))
                {
                    // On
                    if (RequestedTheme == ElementTheme.Dark)
                    {
                        bitmapIcon.Foreground = CurrentColor.CreateSolidColorBrush();
                    }
                    else
                    {
                        // Button will not be visible while in Light theme so simply use Foreground color here.
                        bitmapIcon.Foreground = this.Foreground;
                    }
                }
                else
                {
                    // Off
                    bitmapIcon.Foreground = new SolidColorBrush(Colors.DarkGray);
                }
            }
            else
            {
                // Pressed
                bitmapIcon.Foreground = new SolidColorBrush(Colors.Gray);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Updates the ColorTemperature slider.
        /// </summary>
        /// <param name="colorTemperature"></param>
        /// <param name="maxColorTemperature"></param>
        /// <param name="minColorTemperature"></param>
        private void UpdateColorTemperatureControl(int colorTemperature)
        {
            Ellipse   ellipse   = this.FindName("ColorTemperatureCircle") as Ellipse;
            Rectangle rectangle = this.FindName("ColorTemperature") as Rectangle;
            Grid      grid      = this.FindName("ColorTemperatureRoot") as Grid;

            colorTemperature = Math.Min(colorTemperature, MaximumColorTemperature);
            colorTemperature = Math.Max(colorTemperature, MinimumColorTemperature);

            double percentage = (double)(colorTemperature - MinimumColorTemperature) / (double)(MaximumColorTemperature - MinimumColorTemperature);
            double offset     = (grid.Width - rectangle.Width) / 2 - (ellipse.Width / 2);

            CurrentColor = RGB.GetBlendedColor(percentage, Colors.Gold, Colors.LightCyan);

            ellipse.Fill   = CurrentColor.CreateSolidColorBrush();
            ellipse.Margin = new Thickness(
                (1.0 - percentage) * rectangle.Width + offset, 0, 0, 0);
        }