Esempio n. 1
0
        private async void EngineButton_Click(object sender, RoutedEventArgs e)
        {
            vm = DataContext as MicrophoneViewModel;
            var engine = vm.Engine;

            if (engine.DeviceInName == string.Empty)
            {
                var dialogError = new DialogMessage
                {
                    Message = { Text = "Nenhum microfone detectado." }
                };
                await DialogHost.Show(dialogError);

                return;
            }

            switch (engine.State)
            {
            case LarynxEngineState.Stopped:
                if (engine.StartEngine())
                {
                    EngineButtonIcon.Kind = MaterialDesignThemes.Wpf.PackIconKind.Stop;     //! Use MVVM to do this
                }
                else
                {
                    var dialogError = new DialogMessage
                    {
                        Message = { Text = "Falha ao iniciar módulos!\nRecomendado que reinicie o aplicativo\ne consulte os logs." }
                    };
                    await DialogHost.Show(dialogError);
                }
                break;

            case LarynxEngineState.Running:
                if (engine.StopEngine())
                {
                    EngineButtonIcon.Kind = MaterialDesignThemes.Wpf.PackIconKind.Play;     //! Use MVVM to do this
                }
                else
                {
                    var dialogError = new DialogMessage
                    {
                        Message = { Text = "Falha ao iniciar módulos!\nRecomendado que reinicie o aplicativo\ne consulte os logs." }
                    };
                    await DialogHost.Show(dialogError);
                }
                break;

            case LarynxEngineState.Paused:     // Future use - Resume and Pause
                if (engine.ResumeEngine())
                {
                    EngineButtonIcon.Kind = MaterialDesignThemes.Wpf.PackIconKind.Pause;     //! Use MVVM to do this
                }
                else
                {
                    var dialogError = new DialogMessage
                    {
                        Message = { Text = "Falha ao iniciar módulos!\nRecomendado que reinicie o aplicativo\ne consulte os logs." }
                    };
                    await DialogHost.Show(dialogError);
                }
                break;

            case LarynxEngineState.Starting:     // Future case
            default:
                break;
            }
        }
 public MicSelectorView()
 {
     InitializeComponent();
     _viewModel = this.DataContext as MicrophoneViewModel;
     log.Info("Mic speaker selector view constructed.");
 }