コード例 #1
0
        public TextResultsListPage(IMainThread mainThread,
                                   SignalRService signalRService,
                                   HueBridgeSetupPage hueBridgeSetupPage,
                                   TextResultsListViewModel textResultsListViewModel,
                                   PhilipsHueBridgeSettingsService philipsHueBridgeSettingsService) : base(textResultsListViewModel)
        {
            _mainThread         = mainThread;
            _hueBridgeSetupPage = hueBridgeSetupPage;
            _philipsHueBridgeSettingsService = philipsHueBridgeSettingsService;

            BindingContext.ErrorTriggered += HandleErrorTriggered;
            BindingContext.PhilipsHueBridgeConnectionFailed += HandlePhilipsHueBridgeConnectionFailed;
            signalRService.InitializationFailed             += HandleInitializationFailed;

            ToolbarItems.Add(new ToolbarItem {
                Text = "Setup"
            }
                             .Invoke(setupToolbarItem => setupToolbarItem.Clicked += HandleSetupPageToolbarItemClicked));

            Title = PageTitles.TextResultsPage;

            this.SetBinding(BackgroundColorProperty, nameof(BindingContext.BackgroundColor));

            Content = new RefreshView
            {
                RefreshColor = Device.RuntimePlatform is Device.iOS ? ColorConstants.BarTextColor : ColorConstants.BarBackgroundColor,
                Content      = new CollectionView
                {
                    ItemTemplate    = new TextMoodDataTemplateSelector(),
                    BackgroundColor = Color.Transparent
                }.Bind(CollectionView.ItemsSourceProperty, nameof(BindingContext.TextList))
            }.Bind(RefreshView.IsRefreshingProperty, nameof(BindingContext.IsRefreshing))
            .Bind(RefreshView.CommandProperty, nameof(BindingContext.PullToRefreshCommand));
        }
コード例 #2
0
        public PhilipsHueServices(IPhilipsHueApi philipsHueApi, PhilipsHueBridgeSettingsService philipsHueBridgeSettingsService)
        {
            _philipsHueApiClient             = philipsHueApi;
            _philipsHueBridgeSettingsService = philipsHueBridgeSettingsService;

            _philipsHueBridgeSettingsService.IPAddressChanged += HandleIPAddressChanged;
            _philipsHueBridgeApiClient = InitializePhilipsHueBridgeApiClient(philipsHueBridgeSettingsService.IPAddress);
        }
コード例 #3
0
        public HueBridgeSetupViewModel(PhilipsHueServices philipsHueServices,
                                       PhilipsHueBridgeSettingsService philipsHueBridgeSettingsService)
        {
            _philipsHueServices = philipsHueServices;
            _philipsHueBridgeSettingsService = philipsHueBridgeSettingsService;

            SaveButtonCommand       = new AsyncCommand(() => ExecuteSaveButtonCommand(BridgeIPEntryText, BridgeIDEntryText));
            AutoDetectButtonCommand = new AsyncCommand(ExecuteAutoDetectButtonCommand);
        }
コード例 #4
0
        public TextResultsListViewModel(TextResultsService textResultsService,
                                        PhilipsHueServices philipsHueServices,
                                        PhilipsHueBridgeSettingsService philipsHueBridgeSettingsService)
        {
            _textResultsService = textResultsService;
            _philipsHueServices = philipsHueServices;
            _philipsHueBridgeSettingsService = philipsHueBridgeSettingsService;

            PullToRefreshCommand = new AsyncCommand(ExecutePullToRefreshCommand);
        }
コード例 #5
0
        public HueBridgeSetupPage(IMainThread mainThread,
                                  HueBridgeSetupViewModel hueBridgeSetupViewModel,
                                  PhilipsHueBridgeSettingsService philipsHueBridgeSettingsService) : base(hueBridgeSetupViewModel)
        {
            _mainThread = mainThread;
            _philipsHueBridgeSettingsService = philipsHueBridgeSettingsService;

            BindingContext.SaveFailed             += HandleSaveFailed;
            BindingContext.SaveCompleted          += HandleSaveCompleted;
            BindingContext.AutoDiscoveryCompleted += HandleAutoDiscoveryCompleted;

            Title = "Configure Bridge";

            Content = new StackLayout
            {
                Children =
                {
                    new Label         {
                        Text = "Philips Hue Bridge ID"
                    },

                    new Entry         {
                        Placeholder = "Eg: 001788fffe75a1d2"
                    }.Assign(out _bridgeIDEntry)
                    .Bind(Entry.TextProperty, nameof(BindingContext.BridgeIDEntryText))
                    .Bind(IsEnabledProperty, nameof(BindingContext.AreEntriesEnabled)),

                    new Label         {
                        Text = "Philips Hue Bridge IP Address"
                    },

                    new Entry
                    {
                        Placeholder = "0.0.0.0",
                        Keyboard    = Device.RuntimePlatform is Device.iOS ? Keyboard.Numeric : Keyboard.Default,
                    }.Assign(out _bridgeIPEntry)
                    .Bind(Entry.TextProperty, nameof(BindingContext.BridgeIPEntryText))
                    .Bind(IsEnabledProperty, nameof(BindingContext.AreEntriesEnabled)),

                    new StackLayout
                    {
                        Orientation = StackOrientation.Horizontal,
                        Children    =
                        {
                            new Label {
                                Text = "Enable Philips Hue Bridge"
                            }.TextCenter(),
                            new Switch().Assign(out _isBridgeConnectedSwitch)
                            .Bind(Switch.IsToggledProperty, nameof(BindingContext.IsBridgeConnectedSwitchToggled))
                        }
                    }.Center().Margins(0, 10, 0, 0),

                    new Button        {
                        Text = "Auto Detect"
                    }.Margin(0, 10)
                    .Bind(Button.CommandProperty, nameof(BindingContext.AutoDetectButtonCommand))
                    .Bind(IsEnabledProperty, nameof(BindingContext.AreEntriesEnabled)),

                    new Button        {
                        Text = "Save"
                    }
                    .Bind(IsEnabledProperty, nameof(BindingContext.IsSaveButtonEnabled))
                    .Bind(Button.CommandProperty, nameof(BindingContext.SaveButtonCommand)),

                    new Button        {
                        Text = "Cancel"
                    }
                    .Invoke(cancelButton => cancelButton.Clicked += HandleCancelButtonClicked),

                    new ActivityIndicator()
                    .Bind(IsVisibleProperty, nameof(BindingContext.IsActivityIndicatorVisible))
                    .Bind(ActivityIndicator.IsRunningProperty, nameof(BindingContext.IsActivityIndicatorVisible))
                }
            }.Center();
        }