예제 #1
0
        private void FillVoices()
        {
            var dictionary = _speechSynthesizerService
                             .GetVoices()
                             .Select(voice => voice.VoiceInfo)
                             .ToDictionary(info => $"{info.Name} / {info.Age} / {info.Gender}", info => info.Name);

            voiceComboBox.DataSource    = new BindingSource(dictionary, null);
            voiceComboBox.DisplayMember = "Key";
            voiceComboBox.ValueMember   = "Value";

            voiceComboBox.SelectedItem = dictionary.First(item => item.Value == _speechSynthesizerService.Voice);
        }
예제 #2
0
        public MainForm
        (
            AuthenticationController authenticationController,
            ITwitchService twitchService,
            ISpeechSynthesizerService windowsSpeechSynthesizerService,
            ConfigurationService configurationService
        )
        {
            _authenticationController = authenticationController;
            _twitchService            = twitchService;
            _speechSynthesizerService = windowsSpeechSynthesizerService;
            _configurationService     = configurationService;

            if (_speechSynthesizerService.GetVoices().Count == 0)
            {
                MessageBox.Show(
                    Resources.MainForm_MainForm_No_voice_packs_available__Please_install_Windows_Speech_Pack_and_retry_,
                    Resources.MainForm_MainForm_Error,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );

                Environment.Exit(1);

                return;
            }

            InitializeComponent();

            BindEventHandlers();

            authenticationController.CheckAuthentication();

            FillVoices();
            InitializeTimers();
        }