/// <summary> /// Opens recognition view /// </summary> private void OnStartRecognition() { if (!this.FinalizationComplete) { DialogManager.ShowErrorDialog("There is no validated template to work with!"); return; } // find opened results tab and select it TabViewModel resultsTab = this.TabViewModels.FirstOrDefault(x => x is ResultsViewModel); if (resultsTab != null) { this.SelectedTab = resultsTab; return; } string tabName = "Recognition"; // find template and get needed info TemplateViewModel template = (TemplateViewModel)this.TabViewModels.First(x => x is TemplateViewModel); string templateId = template.TemplateId; bool isGenerated = template.IsGeneratedTemplate; ResultsViewModel resultsVm = new ResultsViewModel(tabName, templateId, isGenerated); this.AddTab(resultsVm); }
/// <summary> /// Adds new tab and selects it. Subscribe to events if any /// </summary> /// <param name="tab">Tab to add and select</param> private void AddTab(TabViewModel tab) { this.TabViewModels.Add(tab); this.SelectedTab = tab; if (tab is TemplateViewModel) { TemplateViewModel templateViewModel = tab as TemplateViewModel; // subscriptions for template view model events templateViewModel.FinalizationApproved += this.OnStartRecognition; templateViewModel.ValidationSuccessful += this.ValidationSuccessful; } }