Beispiel #1
0
        internal override bool UpdateFrom(HueObject hueObject)
        {
            State state = hueObject as State;

            if (state == null)
            {
                return(false);
            }

            bool anyChanged = base.UpdateFrom(hueObject);

            if (_xy[0] != state.XY[0] || _xy[1] != state.XY[1])
            {
                if (IsDeserialized)
                {
                    Log(DebugLevel.Debug, "Update XY to ({0},{1})", state.XY[0], state.XY[1]);
                }

                _xy = state.XY;
                NotifyPropertyChanged("XY");
                anyChanged = true;
            }

            return(anyChanged);
        }
Beispiel #2
0
        internal override bool UpdateFrom(HueObject hueObject)
        {
            Scene scene = hueObject as Scene;

            if (scene == null)
            {
                return(false);
            }

            bool anyChanged = base.UpdateFrom(hueObject);

            if (!Lights.SequenceEqual(scene.Lights))
            {
                if (IsDeserialized)
                {
                    Log(DebugLevel.Debug, "Update Scene.Lights to {0}", string.Join(",", scene.Lights));
                }

                Lights = scene.Lights.ToArray();
                NotifyPropertyChanged("Lights");
                anyChanged = true;
            }

            return(anyChanged);
        }
        internal override bool UpdateFrom(HueObject hueObject)
        {
            BridgeConfiguration bridgeConfiguration = hueObject as BridgeConfiguration;

            if (bridgeConfiguration == null)
            {
                return(false);
            }

            bool anyChanged = base.UpdateFrom(hueObject);

            bool whitelistReplaced = false;

            foreach (var kv in bridgeConfiguration.WhiteList)
            {
                if (!WhiteList.ContainsKey(kv.Key))
                {
                    if (IsDeserialized)
                    {
                        Log(DebugLevel.Debug, "Update WhiteList");
                    }

                    WhiteList         = bridgeConfiguration.WhiteList;
                    anyChanged        = true;
                    whitelistReplaced = true;
                    break;
                }
            }

            if (whitelistReplaced)
            {
                NotifyPropertyChanged("WhiteList");
            }
            else
            {
                foreach (var kv in bridgeConfiguration.WhiteList)
                {
                    WhiteList whitelist;
                    if (WhiteList.TryGetValue(kv.Key, out whitelist))
                    {
                        if (whitelist.UpdateFrom(kv.Value))
                        {
                            anyChanged = true;
                        }
                    }
                }
            }

            return(anyChanged);
        }
Beispiel #4
0
        internal virtual bool UpdateFrom(HueObject hueObject)
        {
            if (_fieldGetterSetterPairs == null)
            {
                _fieldGetterSetterPairs = GetFieldGetterSetterPairs();
            }

            if (hueObject._fieldGetterSetterPairs == null)
            {
                hueObject._fieldGetterSetterPairs = hueObject.GetFieldGetterSetterPairs();
            }

            bool anyChanged = false;

            foreach (var kv in _fieldGetterSetterPairs)
            {
                string propertyName = kv.Key;
                FieldGetterSetterPair getterSetter = kv.Value;

                object fromValue = hueObject._fieldGetterSetterPairs[propertyName].Get();
                if (fromValue is HueObject == false ||
                    getterSetter.Get() == null)
                {
                    if (!Equals(getterSetter.Get(), fromValue))
                    {
                        if (IsDeserialized)
                        {
                            Log(DebugLevel.Debug, "Update " + propertyName + " to " + (fromValue != null ? fromValue.ToString() : "null"));
                        }
                        getterSetter.Set(fromValue);
                        NotifyPropertyChanged(propertyName);
                        anyChanged = true;
                    }
                }
                else
                {
                    if (((HueObject)getterSetter.Get()).UpdateFrom((HueObject)fromValue))
                    {
                        anyChanged = true;
                    }
                }
            }

            return(anyChanged);
        }
Beispiel #5
0
        internal override bool UpdateFrom(HueObject hueObject)
        {
            SoftwareUpdateDeviceTypes swUpdateDeviceTypes = hueObject as SoftwareUpdateDeviceTypes;

            if (swUpdateDeviceTypes == null)
            {
                return(false);
            }

            bool anyChanged = base.UpdateFrom(hueObject);

            if (!Lights.SequenceEqual(swUpdateDeviceTypes.Lights))
            {
                if (IsDeserialized)
                {
                    Log(DebugLevel.Debug, "Update SoftwareUpdateDeviceTypes.Lights to {0}", string.Join(",", swUpdateDeviceTypes.Lights));
                }

                Lights = swUpdateDeviceTypes.Lights;
                NotifyPropertyChanged("Lights");
                anyChanged = true;
            }

            if (!Sensors.SequenceEqual(swUpdateDeviceTypes.Sensors))
            {
                if (IsDeserialized)
                {
                    Log(DebugLevel.Debug, "Update SoftwareUpdateDeviceTypes.Sensors to {0}", string.Join(",", swUpdateDeviceTypes.Sensors));
                }

                Sensors = swUpdateDeviceTypes.Sensors;
                NotifyPropertyChanged("Sensors");
                anyChanged = true;
            }

            return(anyChanged);
        }