예제 #1
0
        private void ApplyNetworkSettings()
        {
            BridgeSettings brs = new BridgeSettings();

            if (BridgeDHCPEnable)
            {
                brs.ipaddress    = null;
                brs.gateway      = null;
                brs.proxyport    = null;
                brs.proxyaddress = null;
                brs.netmask      = null;
                brs.dhcp         = true;
            }
            else
            {
                brs.ipaddress    = _brs.ipaddress;
                brs.gateway      = _brs.gateway;
                brs.proxyport    = _brs.proxyport;
                brs.proxyaddress = _brs.proxyaddress;
                brs.netmask      = _brs.netmask;
                brs.dhcp         = false;
            }
            if (_br.SetBridgeSettings(brs).FailureCount <= 0)
            {
                return;
            }
            MessageBoxError.ShowLastErrorMessages(_br);
        }
예제 #2
0
 private void btnCreateGroup_Click(object sender, RoutedEventArgs e)
 {
     if (gcvm.Group.Id == null)
     {
         CommandResult bresult = BridgeStore.SelectedBridge.CreateObject <Group>(gcvm.Group);
         if (bresult.Success)
         {
             DialogResult = true;
             log.Info(bresult.resultobject);
             _id = ((MessageCollection)bresult.resultobject)[0].ToString();
             Close();
         }
         else
         {
             MessageBoxError.ShowLastErrorMessages(BridgeStore.SelectedBridge);
         }
     }
     else
     {
         CommandResult bresult = BridgeStore.SelectedBridge.ModifyObject <Group>(gcvm.Group, gcvm.Group.Id);
         if (bresult.Success)
         {
             DialogResult = true;
             _id          = gcvm.Group.Id;
             Close();
         }
         else
         {
             MessageBoxError.ShowLastErrorMessages(BridgeStore.SelectedBridge);
         }
     }
 }
예제 #3
0
        private void ApplyNetworkSettings()
        {
            BridgeSettings brs = new BridgeSettings();

            if (BridgeDHCPEnable)
            {
                brs.ipaddress    = null;
                brs.gateway      = null;
                brs.proxyport    = null;
                brs.proxyaddress = null;
                brs.netmask      = null;
                brs.dhcp         = true;
            }
            else
            {
                brs.ipaddress    = _brs.ipaddress;
                brs.gateway      = _brs.gateway;
                brs.proxyport    = _brs.proxyport;
                brs.proxyaddress = _brs.proxyaddress;
                brs.netmask      = _brs.netmask;
                brs.dhcp         = false;
            }
            CommandResult comres = BridgeStore.SelectedBridge.SetBridgeSettings(brs);

            if (!comres.Success)
            {
                MessageBoxError.ShowLastErrorMessages(BridgeStore.SelectedBridge);
            }
        }
예제 #4
0
        private void btnCreateGroup_Click(object sender, RoutedEventArgs e)
        {
            Group  grp    = gcv.GetGroup();
            string result = "0";

            if (grp.Id == null)
            {
                string @group = _bridge.CreateGroup(grp);
                if (@group != null)
                {
                    result = @group;
                }
            }
            else
            {
                _bridge.ChangeGroup(grp);
                if (_bridge.lastMessages.SuccessCount >= 1)
                {
                    result = grp.Id;
                }
            }

            if (result != "0")
            {
                DialogResult = true;
                _id          = result;
                Close();
            }
            else
            {
                MessageBoxError.ShowLastErrorMessages(_bridge);
            }
        }
예제 #5
0
        private void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            Sensor        sensor = _scv.GetSensor();
            CommandResult comres;

            if (modifiedsensor == null)
            {
                comres = _br.CreateObject <Sensor>(sensor);
                MessageCollection mc = (MessageCollection)comres.resultobject;
                modifiedsensor = new Sensor()
                {
                    Id = ((Success)mc[0]).id
                };
            }
            else
            {
                comres = _br.ModifyObject(modifiedsensor, modifiedsensor.Id);
            }

            if (comres.Success)
            {
                DialogResult = true;
                Close();
            }
            else
            {
                MessageBoxError.ShowLastErrorMessages(_br);
            }
        }
예제 #6
0
        private void btnSet_Click(object sender, RoutedEventArgs e)
        {
            CommandResult bresult = br.ChangeSensorConfig(id, daylightView.GetSensor().config);

            if (bresult.Success)
            {
                this.Close();
            }
            else
            {
                MessageBoxError.ShowLastErrorMessages(br);
            }
        }
예제 #7
0
        private void ApplyGeneralSettings()
        {
            BridgeSettings brs = new BridgeSettings()
            {
                name = _brs.name, timezone = _brs.timezone
            };

            WinHueSettings.settings.BridgeInfo[_brs.mac].name = _brs.name;
            WinHueSettings.Save();
            if (_br.SetBridgeSettings(brs).FailureCount <= 0)
            {
                return;
            }
            MessageBoxError.ShowLastErrorMessages(_br);
        }
예제 #8
0
        private void btnRename_Click(object sender, RoutedEventArgs e)
        {
            MethodInfo    mi      = typeof(Bridge).GetMethod("RenameObject");
            MethodInfo    generic = mi.MakeGenericMethod(_obj.GetType());
            CommandResult comres  = (CommandResult)generic.Invoke(_bridge, new object[] { _obj.Id, tbNewName.Text });

            if (comres.Success)
            {
                DialogResult = true;
                Close();
            }
            else
            {
                MessageBoxError.ShowLastErrorMessages(_bridge);
            }
        }
예제 #9
0
        private void ApplyGeneralSettings()
        {
            BridgeSettings brs = new BridgeSettings()
            {
                name = _brs.name, timezone = _brs.timezone
            };

            WinHueSettings.settings.BridgeInfo[_brs.mac].name = _brs.name;
            WinHueSettings.Save();
            CommandResult comres = BridgeStore.SelectedBridge.SetBridgeSettings(brs);

            if (!comres.Success)
            {
                MessageBoxError.ShowLastErrorMessages(BridgeStore.SelectedBridge);
            }
        }
예제 #10
0
        private void CreateUser()
        {
            string result = _br.CreateUser($"{_appname}#{_devicename}");

            if (result == string.Empty)
            {
                MessageBoxError.ShowLastErrorMessages(_br);
            }
            else
            {
                BridgeWhiteListAppName      = string.Empty;
                BridgeWhiteListDevName      = string.Empty;
                BridgeListUsersSelectedUser = null;
                _listusers = new ObservableCollection <Whitelist>(HueObjectHelper.GetBridgeUsers(_br));
                OnPropertyChanged("BridgeListUsers");
            }
        }
예제 #11
0
        public SceneCreatorView(List <HueObject> listlights, string sceneid, Bridge bridge)
        {
            _bridge = bridge;

            CommandResult cr = _bridge.GetObject <Scene>(sceneid);

            if (cr.Success)
            {
                _scene = (Scene)cr.resultobject;
                _listAvailableLights = new ObservableCollection <HueObject>(listlights);
                _listSceneLights     = new ObservableCollection <HueObject>();
                _cansavescene        = true;
                _canpreviewscene     = true;
                OnPropertyChanged("CanSaveSecene");
                OnPropertyChanged("CanPreviewScene");
                foreach (string s in _scene.lights)
                {
                    int index = _listAvailableLights.FindIndex(x => x.Id == s);
                    if (index == -1)
                    {
                        continue;
                    }
                    if (!_scene.lightstates.ContainsKey(s))
                    {
                        continue;
                    }
                    ((Light)_listAvailableLights[index]).state = _scene.lightstates[s];
                    _listSceneLights.Add(_listAvailableLights[index]);
                    _listAvailableLights.RemoveAt(index);
                }

                foreach (HueObject light in _listAvailableLights)
                {
                    ((Light)light).state = new State();
                }
                _newstate = new State {
                    @on = true
                };
            }
            else
            {
                MessageBoxError.ShowLastErrorMessages(_bridge);
            }
        }
예제 #12
0
        public Form_GroupCreator(Bridge bridge, HueObject selectedGroup)
        {
            InitializeComponent();
            _bridge = bridge;
            HelperResult hr = HueObjectHelper.GetBridgeLights(_bridge);

            if (hr.Success)
            {
                gcv   = new GroupCreatorView((List <HueObject>)hr.Hrobject, (Group)selectedGroup);
                Title = string.Format(GUI.GroupCreatorForm_ModifyingGroup_Title, ((Group)selectedGroup).name);
                btnCreateGroup.Content = GUI.GroupCreatorForm_ModifyGroupButton;
                DataContext            = gcv;
            }
            else
            {
                MessageBoxError.ShowLastErrorMessages(_bridge);
                this.Close();
            }
        }
예제 #13
0
        private void btnSet_Click(object sender, RoutedEventArgs e)
        {
            DaylightSensorConfig config = new DaylightSensorConfig
            {
                @long         = dvm.Daylight.Longitude,
                lat           = dvm.Daylight.Latitude,
                sunriseoffset = Convert.ToSByte(dvm.Daylight.SunriseOffset),
                sunsetoffset  = Convert.ToSByte(dvm.Daylight.SunsetOffset)
            };

            CommandResult bresult = BridgeStore.SelectedBridge.ChangeSensorConfig(id, config);

            if (bresult.Success)
            {
                this.Close();
            }
            else
            {
                MessageBoxError.ShowLastErrorMessages(BridgeStore.SelectedBridge);
            }
        }
예제 #14
0
        private void CreateUser()
        {
            CommandResult comres = BridgeStore.SelectedBridge.CreateUser($"{_appname}#{_devicename}");

            if (comres.Success)
            {
                BridgeWhiteListAppName      = string.Empty;
                BridgeWhiteListDevName      = string.Empty;
                BridgeListUsersSelectedUser = null;
                HelperResult hr = HueObjectHelper.GetBridgeUsers(BridgeStore.SelectedBridge);
                if (hr.Success)
                {
                    _listusers = new ObservableCollection <Whitelist>((List <Whitelist>)hr.Hrobject);
                    OnPropertyChanged("BridgeListUsers");
                }
            }
            else
            {
                MessageBoxError.ShowLastErrorMessages(BridgeStore.SelectedBridge);
            }
        }
예제 #15
0
        private void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            Sensor sensor = _scv.GetSensor();

            if (sensor.Id == null)
            {
                _id = _br.CreateSensor(sensor);
            }
            else
            {
                _br.UpdateSensor(_id, sensor);
            }

            if (_id != "")
            {
                DialogResult = true;
                Close();
            }
            else
            {
                MessageBoxError.ShowLastErrorMessages(_br);
            }
        }
예제 #16
0
        private void btnCreateGroup_Click(object sender, RoutedEventArgs e)
        {
            Group grp = gcv.GetGroup();

            if (grp.Id == null)
            {
                CommandResult bresult = _bridge.CreateObject <Group>(grp);
                if (bresult.Success)
                {
                    DialogResult = true;
                    _id          = ((MessageCollection)bresult.resultobject)[0].ToString();
                    Close();
                }
                else
                {
                    MessageBoxError.ShowLastErrorMessages(_bridge);
                }
            }
            else
            {
                CommandResult bresult = _bridge.ModifyObject <Group>(new Group()
                {
                    name = grp.name, lights = grp.lights, @class = grp.@class
                }, grp.Id);
                if (bresult.Success)
                {
                    DialogResult = true;
                    _id          = grp.Id;
                    Close();
                }
                else
                {
                    MessageBoxError.ShowLastErrorMessages(_bridge);
                }
            }
        }