Example #1
0
 public override bool UpdateValue(object newValue)
 {
     Panel.RGBW rgbw = new Panel.RGBW();
     if (newValue is Color)
     {
         var color = (Color)newValue;
         rgbw = new Panel.RGBW(color.R, color.G, color.B);
     }
     else if (newValue is LumosColor)
     {
         var lumosColor = (LumosColor)newValue;
         rgbw = new Panel.RGBW((byte)(lumosColor.Red * 255), (byte)(lumosColor.Green * 255), (byte)(lumosColor.Blue * 255));
     }
     else if (newValue is Panel.RGBW)
     {
         rgbw = (Panel.RGBW)newValue;
     }
     else
     {
         return(false);
     }
     try
     {
         var Controler = NanoleafPlugin.getClient(SerialNumber);
         return(Controler.SetPanelColor(Panel.ID, rgbw));
     }
     catch (Exception e)
     {
         NanoleafPlugin.Log.Error(string.Empty, e);
     }
     return(false);
 }
Example #2
0
 public CurrentPowerstateSource(string serialNumber) :
     base(getID(serialNumber), getDisplayName(), getCategory(serialNumber))
 {
     Communication.StaticOnStateEvent += ExternalControlEndpoint_StaticOnStateEvent;
     SerialNumber = serialNumber;
     CurrentValue = NanoleafPlugin.getClient(SerialNumber).PowerOn;
 }
 public CurrentEffectSource(string serialNumber) :
     base(getID(serialNumber), getDisplayName(), getCategory(serialNumber))
 {
     Communication.StaticOnEffectEvent += ExternalControlEndpoint_StaticOnEffectEvent;
     SerialNumber = serialNumber;
     CurrentValue = NanoleafPlugin.getClient(SerialNumber).SelectedEffect;
 }
Example #4
0
        public CurrentSaturationSource(string serialNumber) :
            base(getID(serialNumber), getDisplayName(), getCategory(serialNumber))
        {
            Communication.StaticOnStateEvent += ExternalControlEndpoint_StaticOnStateEvent;
            SerialNumber = serialNumber;
            var controller = NanoleafPlugin.getClient(SerialNumber);

            min          = controller.SaturationMin;
            max          = controller.SaturationMax;
            CurrentValue = controller.Saturation;
        }
Example #5
0
        public CurrentNumberOfPanelsSource(string serialNumber) :
            base(getID(serialNumber), getDisplayName(), getCategory(serialNumber))
        {
            Communication.StaticOnLayoutEvent += ExternalControlEndpoint_StaticOnLayoutEvent;
            SerialNumber = serialNumber;
            var numberOfPanels = NanoleafPlugin.getClient(SerialNumber).NumberOfPanels;

            min          = 0;
            max          = int.MaxValue;
            CurrentValue = numberOfPanels;
        }
        private void ExternalControlEndpoint_StaticOnTouchEvent(object sender, TouchEventArgs e)
        {
            if (!NanoleafPlugin.getClient(this.SerialNumber).IP.Equals(e.IP))
            {
                return;
            }

            TouchEvent events = e.TouchEvent;

            if (events == null)
            {
                return;
            }
            CurrentValue = events.TouchedPanelsNumber;
        }
        private void ExternalControlEndpoint_StaticOnEffectEvent(object sender, EffectEventArgs e)
        {
            if (!NanoleafPlugin.getClient(this.SerialNumber).IP.Equals(e.IP))
            {
                return;
            }

            EffectEvents events = e.EffectEvents;

            if (events == null)
            {
                return;
            }

            this.CurrentValue = events.Events.First().Value;
        }
Example #8
0
        private void ExternalControlEndpoint_StaticOnStateEvent(object sender, StateEventArgs e)
        {
            if (!NanoleafPlugin.getClient(this.SerialNumber).IP.Equals(e.IP))
            {
                return;
            }
            StateEvents events = e.StateEvents;

            if (events == null)
            {
                return;
            }

            var value = events.Events.FirstOrDefault(v => v.Attribute == StateEvent.EAttribute.Saturation);

            if (value != null)
            {
                this.CurrentValue = value.Value;
            }
        }
        private void ExternalControlEndpoint_StaticOnGestureEvent(object sender, GestureEventArgs e)
        {
            if (!NanoleafPlugin.getClient(this.SerialNumber).IP.Equals(e.IP))
            {
                return;
            }

            GestureEvents events = e.GestureEvents;

            if (events == null)
            {
                return;
            }
            var val = events.Events.FirstOrDefault(g => g.Gesture == GestureType);

            if (val != null)
            {
                beatValue++;
                CurrentValue = beatValue;
            }
        }
Example #10
0
        private void ExternalControlEndpoint_StaticOnLayoutEvent(object sender, LayoutEventArgs e)
        {
            if (!NanoleafPlugin.getClient(this.SerialNumber).IP.Equals(e.IP))
            {
                return;
            }

            LayoutEvent events = e.LayoutEvent;

            if (events == null)
            {
                return;
            }

            var value = events.Layout?.NumberOfPanels;

            if (value.HasValue)
            {
                this.CurrentValue = value.Value;
            }
        }
        private CanvasPositionSource(string serialNumber, int panelID, EPositionPart part) :
            base(getID(serialNumber, panelID, part), getDisplayName(part), getCategory(serialNumber, panelID))
        {
            Communication.StaticOnLayoutEvent += ExternalControlEndpoint_StaticOnLayoutEvent;
            SerialNumber = serialNumber;
            PanelID      = panelID;
            Part         = part;
            var position = NanoleafPlugin.getClient(SerialNumber).Panels.First(p => p.ID.Equals(panelID));

            switch (part)
            {
            case EPositionPart.X:
                CurrentValue = position.X;
                break;

            case EPositionPart.Y:
                CurrentValue = position.Y;
                break;

            case EPositionPart.Orientation:
                CurrentValue = position.Orientation;
                break;
            }
        }