public MainWindow() { //Data initialization: DataContext = this; currentFile = new SoundpackConfiguration(); generateAllLanguages = false; createEmptyLanguagePack(); string pathToGoogleAuthFile = Environment.GetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS"); if (pathToGoogleAuthFile == null || pathToGoogleAuthFile == "") { FirstTimeConfiguration envVarNotSetWindow = new FirstTimeConfiguration(); this.Hide(); if (envVarNotSetWindow.ShowDialog() == true) { this.Show(); } else { this.Close(); return; } } try { client = TextToSpeechClient.Create(); } catch (Exception e) { MessageBox.Show("Google cloud API could not be initialized. Please make sure it is setup correctly and you have an internet connection.\nFull error message: \n\n" + e.Message); Close(); return; } //UI initialization: InitializeComponent(); ComboBox_LanguageCode.ItemsSource = currentFile.LanguagePacks; ComboBox_LanguageCode.SelectedIndex = 0; DataGrid_FileList.ItemsSource = ((LanguagePack)ComboBox_LanguageCode.SelectedItem).SystemVoices; ComboBox_VoiceName.ItemsSource = ListVoices(((LanguagePack)ComboBox_LanguageCode.SelectedItem).LanguageCode); if (ComboBox_VoiceName.SelectedIndex == -1) { ComboBox_VoiceName.SelectedIndex = 0; } GUIRefresh(); }
/******************************************************************************************************************* * Menu item functions: ******************************************************************************************************************/ //File private void MenuItem_New_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show("Do you want to save the current file before creating a new one?", "Save", MessageBoxButton.YesNoCancel, MessageBoxImage.Question); switch (result) { case MessageBoxResult.Yes: save(false); currentFile = new SoundpackConfiguration(); createEmptyLanguagePack(); break; case MessageBoxResult.No: currentFile = new SoundpackConfiguration(); createEmptyLanguagePack(); break; } }