public MainView() { InitializeComponent(); ViewModel = new MainViewModel() { Nav = this.Navigation }; bingSpeechService = new BingSpeechService(new AuthenticationService(ApplicationStore.BingSpeechAPIKey), Device.RuntimePlatform); this .WhenAnyValue(x => x.ViewModel.DoorState) .Subscribe(doorState => { if (doorState == DoorState.Open || doorState == DoorState.GoingUp) { BotBody.TranslateTo(BotBody.X, BotBody.Y, 2000, Easing.SinIn); } else if (doorState == DoorState.Closed || doorState == DoorState.GoingDown) { BotBody.TranslateTo(BotBody.X, BotBody.Y + 100, 2000, Easing.SinIn); } }); this .WhenActivated( disposables => { this.OneWayBind(ViewModel, vm => vm.DoorStateDescription, c => c.DoorStateLabel.Text) .DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.GetDevicesCommand, c => c.RefreshButton) .DisposeWith(disposables); this.OneWayBind(ViewModel, vm => vm.OpenCloseButtonTitle, c => c.OpenCloseButton.Text) .DisposeWith(disposables); this.Bind(ViewModel, vm => vm.IsDoorAvailable, c => c.VoiceButton.IsEnabled) .DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.ToggleDoorCommand, c => c.OpenCloseButton) .DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.SettingsCommand, c => c.SettingsBtn) .DisposeWith(disposables); }); }
private void InitializeBingSpeechService() { bingSpeechService = new BingSpeechService(new AuthenticationService(Constants.BingSpeechAuthenticationURL, Constants.BingSpeechApiKey), Device.RuntimePlatform); }