private async void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { ComboBox langComboBox = sender as ComboBox; if (langComboBox != null && langComboBox.SelectedIndex > -1) { if (textTransDataGrid.SelectedItem != null) { int indexOfItemInTextTranslationList = TextTranslationList.IndexOf(textTransDataGrid.SelectedItem as TextTranslation); if (TextTranslationList[indexOfItemInTextTranslationList].IsEnabled) { string selectedLanguageCode = langComboBox.SelectedItem.ToString(); DataRow languageDetail = await dbCon.GetDataRow("LanguageReference", new DataRow("LanguageCode", selectedLanguageCode)); if (languageDetail.HasData && languageDetail.Error == ERROR.NoError) { string selectedLanguageName = languageDetail.Get("LanguageName").ToString(); TextDisplayWindow textDisplayWindow = new TextDisplayWindow(selectedLanguageCode, selectedLanguageName); textDisplayWindow.ShowDialog(); if (textDisplayWindow.DialogResult.HasValue && textDisplayWindow.DialogResult.Value) { string textTemplate = textDisplayWindow.DisplayText; TextTranslationList[indexOfItemInTextTranslationList].LanguageName = selectedLanguageName; TextTranslationList[indexOfItemInTextTranslationList].IsEnabled = false; TextTranslationList[indexOfItemInTextTranslationList].TextTemplate = textTemplate; textTransDataGrid.CurrentCell = new DataGridCellInfo(textTransDataGrid.SelectedItem, textTransDataGrid.Columns[0]); textTransDataGrid.CommitEdit(); TextTranslation tt = new TextTranslation(); List <string> excepts = new List <string>(); foreach (TextTranslation ttData in TextTranslationList) { if (!string.IsNullOrWhiteSpace(ttData.LanguageCode)) { excepts.Add(ttData.LanguageCode); } } tt.LanguageList = await LoadLanguageList(excepts.ToArray()); if (tt.LanguageList.Count > 0) { TextTranslationList.Add(tt); } } else { textTransDataGrid.BeginEdit(); textTransDataGrid.CancelEdit(); } } textTransDataGrid.SelectedIndex = -1; } } } }
private void EditDisplayText() { int indexOfSelectedItem = textTransDataGrid.SelectedIndex; if (indexOfSelectedItem > -1 && !string.IsNullOrWhiteSpace((textTransDataGrid.SelectedItem as TextTranslation).LanguageCode)) { TextTranslation tt = TextTranslationList[indexOfSelectedItem]; TextDisplayWindow textDisplayWindow = new TextDisplayWindow(tt.LanguageCode, tt.LanguageName, tt.TextTemplate); textDisplayWindow.ShowDialog(); if (textDisplayWindow.DialogResult.HasValue && textDisplayWindow.DialogResult.Value) { string textTemplate = textDisplayWindow.DisplayText; TextTranslationList[indexOfSelectedItem].TextTemplate = textTemplate; } else { textTransDataGrid.SelectedIndex = -1; } } }