Esempio n. 1
0
        public async Task <bool> ProcessRecognizedVoiceCommandAsync(string command, IReadOnlyDictionary <string, string> tags)
        {
            if (!tags.ContainsKey("Module") || tags["Module"] != "weather")
            {
                return(false);
            }

            if (!tags.ContainsKey("Verb"))
            {
                return(false);
            }

            if (tags["Verb"] == "show")
            {
                await _RegionManager.ActivateRegionViewAsync(ERegionLocation.Center, ViewNames.WeatherForecastsViewName);
            }
            else if (tags["Verb"] == "hide")
            {
                await _RegionManager.DeactivateRegionAsync(ERegionLocation.Center);
            }
            else if (tags["Verb"] == "update")
            {
                await _Service.UpdateAsync();
            }

            return(true);
        }
Esempio n. 2
0
        public void Initialize()
        {
            _Container.RegisterType <IClockSettings, ClockSettings>(new ContainerControlledLifetimeManager());
            _Container.RegisterType <IClockService, ClockService>(new ContainerControlledLifetimeManager());
            _Container.RegisterType <ClockVoiceCommandProcessor>(new ContainerControlledLifetimeManager());

            ViewNames.MainClockViewName = _RegionManager.RegisterRegionView(ERegionLocation.TopRight,
                                                                            _Container.Resolve <MainClockView>());

            _RegionManager.ActivateRegionViewAsync(ERegionLocation.TopRight, ViewNames.MainClockViewName);

            ViewNames.AuxiliaryClocksViewName = _RegionManager.RegisterRegionView(ERegionLocation.Center,
                                                                                  _Container.Resolve <AuxiliaryClocksView>());
        }
Esempio n. 3
0
        public void Initialize()
        {
            _Container.RegisterType <IWeatherSettings, WeatherSettings>(new ContainerControlledLifetimeManager());
            _Container.RegisterType <IWeatherService, WeatherService>(new ContainerControlledLifetimeManager());

            _VoiceCommandProcessor = new WeatherVoiceCommandProcessor(_RegionManager, _Container.Resolve <IWeatherService>());

            ViewNames.WeatherCurrentViewName = _RegionManager.RegisterRegionView(ERegionLocation.TopLeft,
                                                                                 _Container.Resolve <WeatherCurrentView>());

            _RegionManager.ActivateRegionViewAsync(ERegionLocation.TopLeft,
                                                   ViewNames.WeatherCurrentViewName);

            ViewNames.WeatherForecastsViewName = _RegionManager.RegisterRegionView(ERegionLocation.Center,
                                                                                   _Container.Resolve <WeatherForecastsView>());

            _Timer.Change(TimeSpan.Zero, TimeSpan.FromMinutes(30));
        }
        public async Task <bool> ProcessRecognizedVoiceCommandAsync(string command, IReadOnlyDictionary <string, string> tags)
        {
            if (!tags.ContainsKey("Module") || tags["Module"] != "radio")
            {
                return(false);
            }

            if (!tags.ContainsKey("Action"))
            {
                return(false);
            }

            switch (tags["Action"])
            {
            case "play":
            {
                int index = 0;
                if (tags.ContainsKey("Index"))
                {
                    if (int.TryParse(tags["Index"], out index))
                    {
                        index--;
                    }
                }

                if (index >= 0 && index < _RadioService.RadioChannels.Count)
                {
                    _RadioService.SelectedRadioChannel = _RadioService.RadioChannels[index];
                }

                _RadioService.IsPlaying = true;
                await _RegionManager.ActivateRegionViewAsync(ERegionLocation.Center, ViewNames.RadioViewName);
            }
            break;

            case "stop":
                _RadioService.IsPlaying = false;
                break;

            case "resume":
                _RadioService.IsPlaying = true;
                await _RegionManager.ActivateRegionViewAsync(ERegionLocation.Center, ViewNames.RadioViewName);

                break;

            case "setVolume":
            {
                if (tags.ContainsKey("VolumeLevel"))
                {
                    var level = tags["VolumeLevel"];

                    var volume = _RadioService.Volume;

                    if (level == "higher")
                    {
                        volume = Math.Min(1.0, volume + 0.1);
                    }
                    else if (level == "lower")
                    {
                        volume = Math.Max(0.1, volume - 0.1);
                    }
                    else
                    {
                        if (double.TryParse(level, out volume))
                        {
                            volume /= 100;
                        }
                    }

                    _RadioService.Volume = volume;
                }
            }
            break;
            }

            return(true);
        }
Esempio n. 5
0
        public async Task <bool> ProcessRecognizedVoiceCommandAsync(string command, IReadOnlyDictionary <string, string> tags)
        {
            if (!tags.ContainsKey("Module") || tags["Module"] != "video")
            {
                return(false);
            }

            if (!tags.ContainsKey("Action"))
            {
                return(false);
            }

            switch (tags["Action"])
            {
            case "list":
                _VideoService.PlaybackState = VideoPlaybackState.Paused;
                await _RegionManager.ActivateRegionViewAsync(ERegionLocation.Center, ViewNames.VideoViewName);

                break;

            case "play":
            {
                int index = 0;
                if (tags.ContainsKey("Index"))
                {
                    if (int.TryParse(tags["Index"], out index))
                    {
                        index--;
                    }
                }

                if (index >= 0 && index < _VideoService.VideoChannels.Count)
                {
                    _VideoService.SelectedVideoChannel = _VideoService.VideoChannels[index];
                }

                _VideoService.PlaybackState = VideoPlaybackState.Playing;
                await _RegionManager.ActivateRegionViewAsync(ERegionLocation.Center, ViewNames.VideoViewName);
            }
            break;

            case "pause":
                _VideoService.PlaybackState = VideoPlaybackState.Paused;
                break;

            case "stop":
                _VideoService.PlaybackState = VideoPlaybackState.Stopped;
                break;

            case "resume":
                _VideoService.PlaybackState = VideoPlaybackState.Playing;
                await _RegionManager.ActivateRegionViewAsync(ERegionLocation.Center, ViewNames.VideoViewName);

                break;

            case "setVolume":
            {
                if (tags.ContainsKey("VolumeLevel"))
                {
                    var level = tags["VolumeLevel"];

                    var volume = _VideoService.Volume;

                    if (level == "higher")
                    {
                        volume = Math.Min(100, volume + 10);
                    }
                    else if (level == "lower")
                    {
                        volume = Math.Max(0, volume - 10);
                    }
                    else
                    {
                        int.TryParse(level, out volume);
                    }

                    _VideoService.Volume = volume;
                }
            }
            break;

            case "muteUnmute":
            {
                var level = tags["VolumeLevel"];

                if (level == "mute")
                {
                    _VideoService.IsMuted = true;
                }
                else if (level == "unmute")
                {
                    _VideoService.IsMuted = false;
                }
            }
            break;

            default:
                return(false);
            }

            return(true);
        }