Exemplo n.º 1
0
        private async void Myo_PoseChanged(object sender, PoseEventArgs e)
        {
            switch (e.Myo.Pose)
            {
            case Pose.DoubleTap:
                if (_lightState)
                {
                    await _dataAccess.On(new Models.Light()
                    {
                        State = true, LightId = 1, Color = new Models.Color()
                        {
                            R = 1, G = 1, B = 1
                        }
                    });
                }
                else
                {
                    await _dataAccess.Off(1);
                }
                _lightState = !_lightState;
                break;

            case Pose.Unknown:
                break;

            default:
                break;
            }
        }
Exemplo n.º 2
0
        public LampViewModel()
        {
            _dataAccess = new DataAccess.Light();
            Message     = "Exemple : Génie allume la lampe";

            OnLight = new RelayCommand <int?>(async(idLight) =>
            {
                bool res = await _dataAccess.On(new Models.Light()
                {
                    State = true, LightId = idLight ?? 1, Color = new Models.Color()
                });
                if (res)
                {
                    Message = "Lampe Allumée";
                }
                else
                {
                    Message = "Erreur durant l'execution";
                }
            });

            OffLight = new RelayCommand <int?>(async(param) =>
            {
                bool res = await _dataAccess.Off(1);
                if (res)
                {
                    Message = "Lampe éteinte";
                }
                else
                {
                    Message = "Erreur durant l'execution";
                }
            });

            ChangeColor = new RelayCommand <string>(async(color) =>
            {
                var light = new Models.Light()
                {
                    State = true, LightId = 1, Color = new Models.Color()
                };
                switch (color)
                {
                case "rouge":
                    light.Color.SetRedColor();
                    break;

                case "vert":
                    light.Color.SetGreenColor();
                    break;

                case "bleu":
                    light.Color.SetBlueColor();
                    break;

                default:
                    break;
                }
                bool res = await _dataAccess.On(light);

                if (res)
                {
                    Message = "La couleur est : " + color;
                }
                else
                {
                    Message = "Erreur durant l'execution";
                }
            });

            StartListeningMyo = new RelayCommand(() =>
            {
                initMyo();
            }, () =>
            {
                return(!_isEnabledMyo);
            });
        }
Exemplo n.º 3
0
        private async Task SendCompletionMessageForAmbiance()
        {
            await ShowProgressScreen("Changement d'ambiance ...");


            var userPrompt = new VoiceCommandUserMessage();

            userPrompt.DisplayMessage    =
                userPrompt.SpokenMessage = "Quelle ambiance voulez vous choisir ?";

            var userReprompt = new VoiceCommandUserMessage();

            userReprompt.DisplayMessage    =
                userReprompt.SpokenMessage = "Quelle ambiance ?";

            var ambianceContentTiles = new List <VoiceCommandContentTile>();

            var ambianceWork = new VoiceCommandContentTile();

            ambianceWork.ContentTileType = VoiceCommandContentTileType.TitleWithText;
            ambianceWork.Title           = "Ambiance de travail";
            ambianceWork.TextLine1       = "Permet de mettre les lampes en vert";
            ambianceWork.AppContext      = "work";

            var ambianceCool = new VoiceCommandContentTile();

            ambianceCool.ContentTileType = VoiceCommandContentTileType.TitleWithText;
            ambianceCool.Title           = "Ambiance de détente";
            ambianceCool.TextLine1       = "Permet de mettre les lampes en bleu";
            ambianceCool.AppContext      = "cool";

            ambianceContentTiles.Add(ambianceWork);
            ambianceContentTiles.Add(ambianceCool);

            var response = VoiceCommandResponse.CreateResponseForPrompt(userPrompt, userReprompt, ambianceContentTiles);

            var voiceCommandDisambiguationResult = await
                                                   _voiceServiceConnection.RequestDisambiguationAsync(response);

            if (voiceCommandDisambiguationResult != null)
            {
                string ambiance = voiceCommandDisambiguationResult.SelectedItem.AppContext as string;
                userPrompt.DisplayMessage   = userPrompt.SpokenMessage = "Activer l'ambiance  " + ambiance;
                userReprompt.DisplayMessage = userReprompt.DisplayMessage = "Voulez vous activer l'ambiance " + ambiance + "?";
                response = VoiceCommandResponse.CreateResponseForPrompt(userPrompt, userReprompt);

                var voiceCommandConfirmation = await _voiceServiceConnection.RequestConfirmationAsync(response);

                // If RequestConfirmationAsync returns null, Cortana's UI has likely been dismissed.
                if (voiceCommandConfirmation != null)
                {
                    if (voiceCommandConfirmation.Confirmed == true)
                    {
                        await ShowProgressScreen("Activation de l'ambiance");

                        var dataAccess = new DataAccess.Light();
                        // Job to Active Ambiance
                        switch (ambiance)
                        {
                        case "work":
                            await dataAccess.On(new Light()
                            {
                                State = true, LightId = 1, Color = new Color()
                                {
                                    B = 1
                                }
                            });

                            break;

                        case "cool":
                            await dataAccess.On(new Light()
                            {
                                State = true, LightId = 1, Color = new Color()
                                {
                                    G = 1
                                }
                            });

                            break;

                        default:
                            break;
                        }

                        var userMessage = new VoiceCommandUserMessage();

                        userMessage.DisplayMessage = userMessage.SpokenMessage = "L'ambiance " + ambiance + " a été activée";
                        response = VoiceCommandResponse.CreateResponse(userMessage);
                        await _voiceServiceConnection.ReportSuccessAsync(response);
                    }
                }
            }
        }