コード例 #1
0
 private void WorkspaceInfoModelsOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs)
 {
     if (WorkspaceInfoModels.Any())
     {
         if (SelectedWorkspaceInfoModel == null || !WorkspaceInfoModels.Contains(SelectedWorkspaceInfoModel))
         {
             SelectedWorkspaceInfoModel = WorkspaceInfoModels.First();
         }
     }
     else
     {
         SelectedWorkspaceInfoModel = null;
     }
 }
コード例 #2
0
        private void PopulateBackgroundWorkerOnDoWork(object sender, DoWorkEventArgs doWorkEventArgs)
        {
            try
            {
                var domainUri = (string)doWorkEventArgs.Argument;

                this.Logger().Trace("Begin Populate");

                var tpcAddress = new Uri(domainUri);
                TfsTeamProjectCollection collection;

                if (!teamPilgrimServiceModelProvider.TryGetCollection(out collection, tpcAddress))
                {
                    return;
                }

                Application.Current.Dispatcher.Invoke(() => ProjectCollectionModels.Clear(), DispatcherPriority.Normal);
                if (collection == null)
                {
                    return;
                }

                var projectCollectionServiceModel = new ProjectCollectionServiceModel(teamPilgrimServiceModelProvider,
                                                                                      teamPilgrimVsService, this,
                                                                                      collection);
                Application.Current.Dispatcher.Invoke(() => ProjectCollectionModels.Add(projectCollectionServiceModel));

                WorkspaceInfo[] workspaceInfos;
                if (teamPilgrimServiceModelProvider.TryGetLocalWorkspaceInfos(out workspaceInfos, collection.InstanceId))
                {
                    Application.Current.Dispatcher.Invoke(() => WorkspaceInfoModels.Clear(), DispatcherPriority.Normal);

                    if (_populateBackgroundWorker.CancellationPending)
                    {
                        doWorkEventArgs.Cancel = true;
                        return;
                    }

                    var activeWorkspace = teamPilgrimVsService.ActiveWorkspace;

                    WorkspaceInfoModel selectedWorkspaceInfoModel = null;

                    foreach (var workspaceInfo in workspaceInfos)
                    {
                        var workspaceInfoModel = new WorkspaceInfoModel(workspaceInfo);
                        Application.Current.Dispatcher.Invoke(() => WorkspaceInfoModels.Add(workspaceInfoModel),
                                                              DispatcherPriority.Normal);

                        if (activeWorkspace != null && activeWorkspace.QualifiedName == workspaceInfo.QualifiedName)
                        {
                            selectedWorkspaceInfoModel = workspaceInfoModel;
                        }

                        if (_populateBackgroundWorker.CancellationPending)
                        {
                            doWorkEventArgs.Cancel = true;
                            return;
                        }
                    }

                    if (selectedWorkspaceInfoModel != null)
                    {
                        Application.Current.Dispatcher.Invoke(
                            () => SelectedWorkspaceInfoModel = selectedWorkspaceInfoModel, DispatcherPriority.Normal);
                    }
                }

                this.Logger().Trace("End Populate");
            }
            finally
            {
                _populateResetEvent.Set();
            }
        }