private void newRecentItemButton_Click(object sender, RoutedEventArgs e) { var newRecentItemButton = e.OriginalSource as Button; if (newRecentItemButton != null) { var mainWindow = Application.Current.MainWindow as MainWindow; if (mainWindow != null && newRecentItemButton.Tag != null) { var analysisJobViewModel = RecentAnalysisJobHelper.GetRecentAnalysisJobItem(newRecentItemButton.Tag.ToString()); var result = BackgroundWorkProcessHelper.Process(new AnalysisJobBackgroundWorkHelper(analysisJobViewModel)); if (result != null) { result = BackgroundWorkProcessHelper.Process(new MtdbProcessorBackgroundWorkHelper(analysisJobViewModel)); if (analysisJobViewModel.Database != null) { mainWindow.NewWorkspacePage(analysisJobViewModel); } } } } }
private void AnalysisJobViewModel_AnalysisJobProcessed(object sender, MtdbResultChangedEventArgs e) { if (e.Result == null) { ShowDialog(); } else { if (e.Result is ObservableCollection <AnalysisJobItem> ) { if (WorkspaceViewModel != null) { foreach (var analysisJobItem in AnalysisJobViewModel.AnalysisJobItems) { WorkspaceViewModel.AnalysisJobViewModel.AnalysisJobItems.Add(analysisJobItem); } WorkspaceViewModel.AnalysisJobViewModel.ProcessAnalysisDatabase(); WorkspaceViewModel.UpdateDataViewModels(); RecentAnalysisJobHelper.AddRecentAnalysisJob(WorkspaceViewModel.AnalysisJobViewModel); Close(); } } else if (e.Result is TargetDatabase) { var mainWindow = Application.Current.MainWindow as MainWindow; if (mainWindow != null) { mainWindow.NewWorkspacePage(AnalysisJobViewModel); RecentAnalysisJobHelper.AddRecentAnalysisJob(AnalysisJobViewModel); } Close(); } } }
private void Page_Loaded(object sender, RoutedEventArgs e) { // Refresh recent opened items from user settings RecentAnalysisJobStackPanel.Children.Clear(); if (Settings.Default.RecentAnalysisJobs.Count > 0) { foreach (var s in Settings.Default.RecentAnalysisJobs) { var itemTextBlock = new TextBlock { Text = RecentAnalysisJobHelper.GetRecentAnalysisJobTitle(s), TextTrimming = TextTrimming.CharacterEllipsis }; var newRecentItemButton = new Button { Style = (Style)FindResource("LeftPanelHyperLinkButtonStyle"), Content = itemTextBlock, Tag = s }; newRecentItemButton.Click += newRecentItemButton_Click; RecentAnalysisJobStackPanel.Children.Add(newRecentItemButton); } } else { var itemTextBlock = new TextBlock { Text = "(No jobs opened recently)", Style = (Style)FindResource("LeftPanelDescriptionStyle") }; RecentAnalysisJobStackPanel.Children.Add(itemTextBlock); } }