コード例 #1
0
        private void RefreshMergedPet(object sender, RoutedEventArgs e)
        {
            //TODO: Refresh multiple selected merged PETs?
            if (PetGrid.SelectedItems.Count == 1)
            {
                try
                {
                    var selectedDataset = (Dataset)PetGrid.SelectedItem;

                    PetMerger.RefreshMergedPet(selectedDataset, ViewModel.Store.DataDirectory);

                    //Trigger an update of the details panel
                    PetGrid_SelectionChanged(this, new SelectionChangedEventArgs(e.RoutedEvent, new Object[0], new Object[0]));
                }
                catch (Exception ex)
                {
                    ShowErrorDialog("Refresh error", "An error occurred while refreshing the merged PET.", ex.Message, ex.ToString());
                }
            }
        }
コード例 #2
0
 private void OnRenamed(object source, RenamedEventArgs e)
 {
     // Specify what is done when a file is renamed.
     Console.WriteLine("File: {0} renamed to {1}", e.OldFullPath, e.FullPath);
     PetMerger.RefreshMergedPet(MergedDataset, DataDirectoryPath);
 }
コード例 #3
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());
            }
        }
コード例 #4
0
 private void OnChanged(object source, FileSystemEventArgs e)
 {
     // Specify what is done when a file is changed, created, or deleted.
     Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType);
     PetMerger.RefreshMergedPet(MergedDataset, DataDirectoryPath);
 }