Ejemplo n.º 1
0
        public LightStatus(Light l)
        {
            InitializeComponent();

            Light = l;
            DataContext = Light;

            // Set on/off state
            if (!Light.State.IsReachable)
            {
                UnreachableDot.Visibility = Visibility.Visible;
            }
            else
            {
                if (Light.State.IsOn)
                {
                    var color = Light.State.Color;
                    OnDot.Visibility = Visibility.Visible;
                    OnDot.Fill = new SolidColorBrush(new Color() { A = 255, R = color.R, G = color.G, B = color.B });
                }
                else
                {
                    OffDot.Visibility = Visibility.Visible;
                }
            }
        }
Ejemplo n.º 2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!(value is LightStateBuilder))
            {
                throw new InvalidOperationException();
            }

            var lsb = value as LightStateBuilder;
            var tempLight = new Light();
            tempLight.RefreshState(lsb.GetJson());
            var c = tempLight.State.Color;
            if (tempLight.State.IsOn)
            {
                return new SolidColorBrush(new Color() { A = 255, R = c.R, G = c.G, B = c.B });
            }
            else
            {
                return new SolidColorBrush(Colors.Transparent);
            }
        }