private void ContentPage_Appearing(object sender, EventArgs e) { if (EditingModel == null) { EditingModel = new MappingMonitor.MappingModel(); } BindingContext = this; if (Model != null) { if (Model.Category == null) { PkCategory.SelectedIndex = 0; } else { int enumIdx = (int)Model.Category; if (enumIdx >= 0 && enumIdx < PkCategory.ItemsSource.Count) { PkCategory.SelectedIndex = enumIdx; } else { PkCategory.SelectedIndex = 0; } } EditingModel.OriginalText = Model.OriginalText; EditingModel.MappingText = Model.MappingText; EditingModel.Description = Model.Description; EditingModel.Comment = Model.Comment; } }
private async void BtnMappingProjConfNew_Click(object sender, RoutedEventArgs e) { var list = DgMappingProjConf.ItemsSource as ObservableList <MappingMonitor.MappingModel>; if (list == null) { return; } var newOrig = await mMainWindow.ShowInputAsync(Languages.ProjectGlossary.Str0AddNewMapping, Languages.ProjectGlossary.Str0NewOriginalText, sInputSettings); // show warning about OriginalText is empty (it maybe full of whitespace characters!!) if (string.IsNullOrEmpty(newOrig)) { // user may cancel the Input dialog, so ignore null or empty newOrig directly //await mMainWindow.ShowMessageAsync( Languages.ProjectGlossary.Str0OriginalTextError, // Languages.ProjectGlossary.Str0OriginalTextShallNotEmpty ); return; } if (string.IsNullOrWhiteSpace(newOrig)) { await mMainWindow.ShowMessageAsync(Languages.ProjectGlossary.Str0OriginalTextWarning, Languages.ProjectGlossary.Str0OriginalTextWhitespaceTakeCare); } // show warning about OriginalText is only one word if (newOrig.Length <= 1) { await mMainWindow.ShowMessageAsync(Languages.ProjectGlossary.Str0OriginalTextWarning, Languages.ProjectGlossary.Str0OriginalTextTooShortWarning); } // check orig is existed var first = list.FirstOrDefault(item => item.OriginalText == newOrig); if (first != null) { await mMainWindow.ShowMessageAsync(Languages.Global.Str0DuplicateText, string.Format(Languages.ProjectGlossary.Str1OriginalTextDupicatedWarning, newOrig)); DgMappingProjConf.SelectedItem = first; return; } // add new Mapping entry to collection var model = new MappingMonitor.MappingModel { OriginalText = newOrig, ProjectBasedFileName = mProject.FileName }; model.PropertyChanged += MappingModel_PropertyChanged; mProject?.Project?.MappingTable?.Add(model); list.Add(model); _SetProjChanged(); // scroll to new Mapping entry DgMappingProjConf.SelectedItem = model; DgMappingProjConf.UpdateLayout(); DgMappingProjConf.ScrollIntoView(model); }
public NewMappingPage() { InitializeComponent(); if (EditingModel == null) { EditingModel = new MappingMonitor.MappingModel(); } BindingContext = this; // prepare Picker PkCategory.ItemsSource = Minax.Utils.GetAllTextCategoryL10nStrings().ToList(); }