Esempio n. 1
0
        public MergedPetDetailsControl(MergedPetDetailsViewModel mergedPetDetailsViewModel, DatasetListWindowViewModel datasetViewModel)
        {
            this.ViewModel        = mergedPetDetailsViewModel;
            this.DatasetViewModel = datasetViewModel;
            InitializeComponent();

            /*
             * WPF doesn't have an event that triggers when a Control is removed permanently from the tree, and Load/Unload can be
             * called multiple times if an object is hidden/reshown (i.e. if the user switches tabs)--  so, to properly make sure
             * we clean up our VisualizerExitedEvent handler, we need to do it on Unload, and re-register on Load (and check for
             * any that we might've missed while offscreen).
             */
            Loaded += (sender, args) =>
            {
                ViewModel.RegisterForVisualizerExitedEvents();
                ViewModel.UpdateVisualizerSessionStatus();
            };

            Unloaded += (sender, args) =>
            {
                ViewModel.UnregisterForVisualizerExitedEvents();
            };
        }
Esempio n. 2
0
        public DatasetListWindow(JobStore jobStore, SingleInstanceManager instanceManager, string initialWorkingDirectory)
        {
            try
            {
                this.initialWorkingDirectory = initialWorkingDirectory;

                this.ViewModel = new DatasetListWindowViewModel(jobStore);

                if (instanceManager == null)
                {
                    this.instanceManager = new SingleInstanceManager();
                    var uiContext = TaskScheduler.FromCurrentSynchronizationContext();
                    this.instanceManager.OnCreateForWorkingDirectory += (sender, args) =>
                    {
                        Task.Factory.StartNew(() =>
                        {
                            // Try and locate a window that already contains this working directory; raise it if one exists,
                            // rather than creating a new one.
                            foreach (var window in Application.Current.Windows)
                            {
                                var datasetWindow = window as DatasetListWindow;
                                if (datasetWindow != null && datasetWindow.Visibility == Visibility.Visible)
                                {
                                    try
                                    {
                                        var windowFullPath =
                                            System.IO.Path.GetFullPath(datasetWindow.ViewModel.Store.DataDirectory);
                                        var newDirectoryFullPath = System.IO.Path.GetFullPath(args.WorkingDirectory);

                                        if (windowFullPath == newDirectoryFullPath) // TODO: better way to check for path equality?
                                        {
                                            datasetWindow.Refresh();
                                            datasetWindow.Activate();
                                            return;
                                        }
                                    }
                                    catch (Exception)
                                    {
                                        //quietly fail; if GetFullPath fails on either path, we don't really care (just move on to the next window)
                                    }
                                }
                            }

                            var newDatasetListWindow = new DatasetListWindow(ViewModel.JobStore, this.instanceManager, args.WorkingDirectory);
                            newDatasetListWindow.Show();
                            newDatasetListWindow.Activate();
                        }, new CancellationToken(), TaskCreationOptions.None, uiContext);
                    };
                }
                else
                {
                    this.instanceManager = instanceManager;
                }

                InitializeComponent();
                this.ViewModel.TrackedJobsChanged += (sender, args) =>
                {
                    TabControl.SelectedItem = JobsTab;
                };
                Console.WriteLine("Results browser window opened");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Trace.TraceError("Error occurred while creating window:");
                Trace.TraceError(e.ToString());
                throw e;
            }
        }
Esempio n. 3
0
 public PetDetailsControl(PetDetailsViewModel petDetailsViewModel, DatasetListWindowViewModel datasetViewModel)
 {
     this.ViewModel        = petDetailsViewModel;
     this.DatasetViewModel = datasetViewModel;
     InitializeComponent();
 }