Пример #1
0
        private void TestBenchGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            TestBenchDetailsPanel.Children.Clear();

            //If we recreate this intermediate panel every time this method's called, we can
            //avoid displaying the wrong results if the user changes focus while data's loading
            var detailsPanel = new DockPanel();

            TestBenchDetailsPanel.Children.Add(detailsPanel);

            var placeholderPanel = new PlaceholderDetailsPanel();

            detailsPanel.Children.Add(placeholderPanel);
            try
            {
                if (TestBenchGrid.SelectedItem != null)
                {
                    var selectedDataset = (Dataset)TestBenchGrid.SelectedItem;

                    if (selectedDataset.Kind == Dataset.DatasetKind.TestBenchResult)
                    {
                        placeholderPanel.IsLoading = true;
                        var datasetPath = System.IO.Path.Combine(ViewModel.Store.DataDirectory, DatasetStore.ResultsDirectory,
                                                                 selectedDataset.Folders[0]);

                        var loadTask = Task <TBManifestViewModel> .Factory.StartNew(() =>
                        {
                            return(new TBManifestViewModel(datasetPath));
                        });

                        loadTask.ContinueWith(task =>
                        {
                            if (!task.IsCanceled)
                            {
                                if (task.Exception != null)
                                {
                                    placeholderPanel.IsLoading   = false;
                                    placeholderPanel.DisplayText =
                                        "An error occurred while inspecting selected object: \n";

                                    foreach (var exception in task.Exception.InnerExceptions)
                                    {
                                        placeholderPanel.DisplayText += "\n" + exception.Message;
                                    }
                                }
                                else
                                {
                                    var detailsControl = new TestBenchDetailsControl(datasetPath, task.Result);

                                    detailsPanel.Children.Clear();
                                    detailsPanel.Children.Add(detailsControl);
                                }
                            }
                        }, TaskScheduler.FromCurrentSynchronizationContext());
                    }
                    else
                    {
                        placeholderPanel.DisplayText = "No inspector available";
                    }
                }
            }
            catch (Exception ex)
            {
                placeholderPanel.IsLoading   = false;
                placeholderPanel.DisplayText = "An error occurred while inspecting selected object.";
                ShowErrorDialog("Error", "An error occurred while loading dataset details.", ex.Message, ex.ToString());
            }
        }
Пример #2
0
        private void PetGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            foreach (var deselectedObject in e.RemovedItems)
            {
                var dataset = (Dataset)deselectedObject;

                dataset.Selected = false;
            }

            foreach (var selectedObject in e.AddedItems)
            {
                var dataset = (Dataset)selectedObject;

                dataset.Selected = true;
            }


            PetDetailsPanel.Children.Clear();

            //If we recreate this intermediate panel every time this method's called, we can
            //avoid displaying the wrong results if the user changes focus while data's loading
            var detailsPanel = new DockPanel();

            PetDetailsPanel.Children.Add(detailsPanel);

            var placeholderPanel = new PlaceholderDetailsPanel();

            detailsPanel.Children.Add(placeholderPanel);
            try
            {
                if (PetGrid.SelectedItem != null)
                {
                    var selectedDataset = (Dataset)PetGrid.SelectedItem;

                    if (selectedDataset.Kind == Dataset.DatasetKind.PetResult)
                    {
                        placeholderPanel.IsLoading = true;
                        var resultsDirectory = System.IO.Path.Combine(ViewModel.Store.DataDirectory,
                                                                      DatasetStore.ResultsDirectory);

                        var loadTask = Task <PetDetailsViewModel> .Factory.StartNew(() =>
                        {
                            return(new PetDetailsViewModel(selectedDataset, resultsDirectory));
                        });

                        loadTask.ContinueWith(task =>
                        {
                            if (!task.IsCanceled)
                            {
                                if (task.Exception != null)
                                {
                                    placeholderPanel.IsLoading   = false;
                                    placeholderPanel.DisplayText =
                                        "An error occurred while inspecting selected object: \n";

                                    foreach (var exception in task.Exception.InnerExceptions)
                                    {
                                        placeholderPanel.DisplayText += "\n" + exception.Message;
                                    }
                                }
                                else
                                {
                                    var detailsControl = new PetDetailsControl(task.Result, ViewModel);

                                    detailsPanel.Children.Clear();
                                    detailsPanel.Children.Add(detailsControl);
                                }
                            }
                        }, TaskScheduler.FromCurrentSynchronizationContext());
                    }
                    else if (selectedDataset.Kind == Dataset.DatasetKind.MergedPet || selectedDataset.Kind == Dataset.DatasetKind.Pet)
                    {
                        placeholderPanel.IsLoading = true;
                        var resultsDirectory = System.IO.Path.Combine(ViewModel.Store.DataDirectory,
                                                                      DatasetStore.MergedDirectory);
                        var dataDirectory = ViewModel.Store.DataDirectory;

                        var loadTask = Task <MergedPetDetailsViewModel> .Factory.StartNew(() =>
                        {
                            //Only auto-refresh autogenerated merged PET datasets (ones generated by the Results Browser
                            //when a PET is run).  Merged PETs are manually refreshed.
                            if (selectedDataset.Kind == Dataset.DatasetKind.Pet)
                            {
                                try
                                {
                                    PetMerger.RefreshMergedPet(selectedDataset, dataDirectory);
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine("An error occurred while refreshing this merged PET: {0}", ex);
                                }
                            }

                            return(new MergedPetDetailsViewModel(selectedDataset, resultsDirectory));
                        });

                        loadTask.ContinueWith(task =>
                        {
                            if (!task.IsCanceled)
                            {
                                if (task.Exception != null)
                                {
                                    placeholderPanel.IsLoading   = false;
                                    placeholderPanel.DisplayText =
                                        "An error occurred while inspecting selected object: \n";

                                    foreach (var exception in task.Exception.InnerExceptions)
                                    {
                                        placeholderPanel.DisplayText += "\n" + exception.Message;
                                    }
                                }
                                else
                                {
                                    var detailsControl = new MergedPetDetailsControl(task.Result, ViewModel);

                                    detailsPanel.Children.Clear();
                                    detailsPanel.Children.Add(detailsControl);
                                }
                            }
                        }, TaskScheduler.FromCurrentSynchronizationContext());
                    }
                    else
                    {
                        placeholderPanel.DisplayText = "No archive inspector";
                    }
                }
            }
            catch (Exception ex)
            {
                placeholderPanel.IsLoading   = false;
                placeholderPanel.DisplayText = "An error occurred while inspecting selected object.";
                ShowErrorDialog("Error", "An error occurred while loading dataset details.", ex.Message, ex.ToString());
            }
        }