public void AddBulb(DisplayLamp bulb) { DisplayLamp exists = GetLamp(bulb.about.AppId.ToString(), bulb.about.DeviceName); if (exists == null) { lock (bulbLock) { bulbs.Add(bulb); } } else { lock (bulbLock) { if (exists.consumer == null && bulb.consumer != null) { exists.consumer = bulb.consumer; } if (exists.DetailsConsumer == null && bulb.DetailsConsumer != null) { exists.DetailsConsumer = bulb.DetailsConsumer; } } } FireUpdateBulb(bulb.about.AppId.ToString(), bulb.about.DeviceName); }
private async void FoundLight(LampStateConsumer consumer, AllJoynAboutDataView about) { consumer.Signals.LampStateChangedReceived += Signals_LampStateChangedReceived; DisplayLamp dl = new DisplayLamp(consumer, about); BulbManager.Instance.AddBulb(dl); var dispatcher = Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher; await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () => { App.MainMenu.Count = $"({BulbManager.Instance.NumberOfLamps()})";; }); }
private async Task AddNewBulb(string lampId, string lampName) { DisplayLamp lamp = BulbManager.Instance.GetLamp(lampId, lampName); if (lamp == null) { return; } DisplayLampViewModel lampViewModel = new DisplayLampViewModel(lampId, lampName); var dispatcher = Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher; await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () => { this.Bulbs.Add(lampViewModel); }); }
private async void Details_Added(org.allseen.LSF.LampDetails.LampDetailsWatcher sender, AllJoynServiceInfo args) { var session = await LampDetailsConsumer.JoinSessionAsync(args, sender); if (session.Status == AllJoynStatus.Ok) { AllJoynAboutDataView about = await AllJoynAboutDataView.GetDataBySessionPortAsync(args.UniqueName, bus, args.SessionPort); if (about != null) { LampDetailsGetColorResult lres = await session.Consumer.GetColorAsync(); DisplayLamp dl = new DisplayLamp(session.Consumer, about); dl.isColourLamp = lres; BulbManager.Instance.AddBulb(dl); } } }