Beispiel #1
0
 /// <summary>
 /// ctor
 /// </summary>
 /// <param name="bridge">active bridge.</param>
 public Form_SceneCreator(Bridge bridge)
 {
     InitializeComponent();
     scv         = new SceneCreatorView(HueObjectHelper.GetBridgeLights(bridge), bridge);
     DataContext = scv;
     _br         = bridge;
 }
Beispiel #2
0
        void bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            SetPreviewBtn(false);
            ObservableCollection <HueObject> li = (ObservableCollection <HueObject>)e.Argument;
            ObservableCollection <HueObject> liOriginalState = new ObservableCollection <HueObject>();

            foreach (HueObject obj in li)
            {
                HueObject newlight = HueObjectHelper.GetBridgeLight(_bridge, obj.Id);
                ((Light)newlight).state.alert = null;
                liOriginalState.Add(newlight);
            }

            foreach (HueObject obj in li)
            {
                _bridge.SetLightState(obj.Id, ((Light)obj).state);
            }

            Thread.Sleep(5000);

            foreach (HueObject obj in liOriginalState)
            {
                _bridge.SetLightState(obj.Id, ((Light)obj).state);
            }

            Thread.Sleep(2000);
            SetPreviewBtn(true);
        }
 public Form_RulesCreator2(Bridge bridge)
 {
     InitializeComponent();
     _br         = bridge;
     rcv         = new RuleCreatorView(HueObjectHelper.GetBridgeDataStore(bridge));
     DataContext = rcv;
 }
Beispiel #4
0
 /// <summary>
 /// ctor
 /// </summary>
 /// <param name="bridge">Actual Bridge.</param>
 public Form_GroupCreator(Bridge bridge)
 {
     InitializeComponent();
     _bridge     = bridge;
     gcv         = new GroupCreatorView(HueObjectHelper.GetBridgeLights(_bridge));
     DataContext = gcv;
 }
Beispiel #5
0
        void bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            SetPreviewBtn(false);
            ObservableCollection <HueObject> li = (ObservableCollection <HueObject>)e.Argument;
            ObservableCollection <HueObject> liOriginalState = new ObservableCollection <HueObject>();

            foreach (HueObject obj in li)
            {
                HelperResult hr = HueObjectHelper.GetObject <Light>(BridgeStore.SelectedBridge, obj.Id);
                if (hr.Success)
                {
                    HueObject newlight = (HueObject)hr.Hrobject;
                    ((Light)newlight).state.alert = null;
                    liOriginalState.Add(newlight);
                }
            }

            foreach (HueObject obj in li)
            {
                BridgeStore.SelectedBridge.SetState <Light>(((Light)obj).state, obj.Id);
            }

            Thread.Sleep(5000);

            foreach (HueObject obj in liOriginalState)
            {
                BridgeStore.SelectedBridge.SetState <Light>(((Light)obj).state, obj.Id);
            }

            Thread.Sleep(2000);
            SetPreviewBtn(true);
        }
Beispiel #6
0
 public Form_SceneCreator(Bridge bridge, HueObject obj)
 {
     InitializeComponent();
     _id         = ((Scene)obj).Id;
     scv         = new SceneCreatorView(HueObjectHelper.GetBridgeLights(bridge), obj, bridge);
     DataContext = scv;
     _br         = bridge;
 }
Beispiel #7
0
        /// <summary>
        /// ctor
        /// </summary>
        /// <param name="bridge">active bridge.</param>
        public Form_SceneCreator(Bridge bridge)
        {
            InitializeComponent();
            HelperResult hr = HueObjectHelper.GetObjectsList <Light>(bridge);

            scv         = hr.Success ? new SceneCreatorView((List <HueObject>)hr.Hrobject) : new SceneCreatorView(new List <HueObject>());
            DataContext = scv;
            _br         = bridge;
        }
        public BridgeSettingsView(Bridge selectedbridge)
        {
            _br            = selectedbridge;
            _brs           = _br.GetBridgeSettings();
            _listtimezones = _br.GetTimeZones();
            _listusers     = new ObservableCollection <Whitelist>(HueObjectHelper.GetBridgeUsers(_br));
            int winhue = _listusers.FindIndex(x => x.id == selectedbridge.ApiKey);

            _listusers.RemoveAt(winhue);
        }
Beispiel #9
0
 public Form_GroupCreator(Bridge bridge, HueObject selectedGroup)
 {
     InitializeComponent();
     _bridge                = bridge;
     gcv                    = new GroupCreatorView(HueObjectHelper.GetBridgeLights(_bridge), (Group)selectedGroup);
     DataContext            = gcv;
     Title                  = string.Format(GUI.GroupCreatorForm_ModifyingGroup_Title, ((Group)selectedGroup).name);
     btnCreateGroup.Content = GUI.GroupCreatorForm_ModifyGroupButton;
     DataContext            = gcv;
 }
 public Form_RulesCreator2(Bridge bridge, HueObject rule)
 {
     InitializeComponent();
     _br                   = bridge;
     rcv                   = new RuleCreatorView(HueObjectHelper.GetBridgeDataStore(bridge), rule);
     DataContext           = rcv;
     editedRule            = (Rule)rule;
     Title                 = $"Editing rule {((Rule)rule).name}...";
     btnCreateRule.Content = "Update";
 }
        /// <summary>
        /// ctor
        /// </summary>
        /// <param name="bridge">Actual Bridge.</param>
        public Form_GroupCreator(Bridge bridge)
        {
            InitializeComponent();
            _bridge = bridge;
            HelperResult hr = HueObjectHelper.GetBridgeLights(_bridge);

            if (hr.Success)
            {
                gcv         = new GroupCreatorView((List <HueObject>)hr.Hrobject);
                DataContext = gcv;
            }
        }
Beispiel #12
0
        public Form_SceneCreator(Bridge bridge, HueObject obj)
        {
            InitializeComponent();
            _currentscene = ((Scene)obj);
            HelperResult hr = HueObjectHelper.GetObjectsList <Light>(bridge);

            if (hr.Success)
            {
                scv         = new SceneCreatorView((List <HueObject>)hr.Hrobject, obj);
                DataContext = scv;
                _br         = bridge;
            }
        }
        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");
            }
        }
        public Form_RulesCreator2(Bridge bridge)
        {
            InitializeComponent();
            _br = bridge;
            HelperResult     hr = HueObjectHelper.GetBridgeDataStore(bridge);
            List <HueObject> listobj;

            if (hr.Success)
            {
                listobj = (List <HueObject>)hr.Hrobject;
            }
            else
            {
                listobj = new List <HueObject>();
            }
            rcv         = new RuleCreatorView(listobj);
            DataContext = rcv;
        }
        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();
            }
        }
Beispiel #16
0
 private ObservableCollection <Bridge> AssociateApiKey(ObservableCollection <Bridge> bridge)
 {
     foreach (Bridge br in bridge)
     {
         if (!WinHueSettings.settings.BridgeInfo.ContainsKey(br.Mac))
         {
             continue;
         }
         br.ApiKey = WinHueSettings.settings.BridgeInfo[br.Mac].apikey;
         log.Debug($@"Associating ApiKey :{br.ApiKey} with bridge : {br.IpAddress}");
         if (!HueObjectHelper.IsAuthorized(br))
         {
             br.ApiKey = string.Empty;
         }
         br.IsDefault = br.Mac == WinHueSettings.settings.DefaultBridge;
         _defaultset |= br.IsDefault;
         OnPropertyChanged("CanDone");
     }
     return(bridge);
 }
Beispiel #17
0
        public BridgeSettingsView(BridgeSettings brs)
        {
            _brs = brs;
            CommandResult comres2 = BridgeStore.SelectedBridge.GetTimeZones();

            if (!comres2.Success)
            {
                return;
            }
            _listtimezones = (List <string>)comres2.resultobject;
            HelperResult hr = HueObjectHelper.GetBridgeUsers(BridgeStore.SelectedBridge);

            if (!hr.Success)
            {
                return;
            }
            _listusers = new ObservableCollection <Whitelist>((List <Whitelist>)hr.Hrobject);
            int winhue = _listusers.FindIndex(x => x.id == BridgeStore.SelectedBridge.ApiKey);

            _listusers.RemoveAt(winhue);
        }
Beispiel #18
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);
            }
        }
        public Form_RulesCreator2(Bridge bridge, HueObject rule)
        {
            InitializeComponent();
            _br = bridge;
            HelperResult     hr = HueObjectHelper.GetBridgeDataStore(bridge);
            List <HueObject> listobj;

            if (hr.Success)
            {
                listobj = (List <HueObject>)hr.Hrobject;
            }
            else
            {
                listobj = new List <HueObject>();
            }
            rcv                   = new RuleCreatorView(listobj, rule);
            DataContext           = rcv;
            editedRule            = (Rule)rule;
            id                    = editedRule.Id;
            Title                 = $"Editing rule {((Rule)rule).name}...";
            btnCreateRule.Content = "Update";
        }
Beispiel #20
0
        private void FetchHueObject()
        {
            if (_objectypeindex == -1)
            {
                ListHueObject = null;
                return;
            }

            HelperResult hr;

            switch (_objectypeindex)
            {
            case 0:
                hr = HueObjectHelper.GetBridgeLights(BridgeStore.SelectedBridge);
                break;

            case 1:
                hr = HueObjectHelper.GetBridgeGroups(BridgeStore.SelectedBridge);
                break;

            case 2:
                hr = HueObjectHelper.GetBridgeScenes(BridgeStore.SelectedBridge);
                break;

            default:
                hr = new HelperResult()
                {
                    Success = false
                };
                break;
            }

            if (hr.Success)
            {
                ListHueObject = (List <HueObject>)hr.Hrobject;
            }
        }
        private void FetchHueObject()
        {
            switch (_objectypeindex)
            {
            case -1:
                ListHueObject = null;
                break;

            case 0:
                ListHueObject = HueObjectHelper.GetBridgeLights(_bridge);
                break;

            case 1:
                ListHueObject = HueObjectHelper.GetBridgeGroups(_bridge);
                break;

            case 2:
                ListHueObject = HueObjectHelper.GetBridgeScenes(_bridge);
                break;

            default:
                break;
            }
        }