コード例 #1
0
        void OnWorkspaceRequestClose(object sender, EventArgs e)
        {
            var senderType = sender.GetType();
            WorkspaceViewModel workspace = (WorkspaceViewModel)sender;

            this.Workspaces.Remove(workspace);
            if (senderType == typeof(AuthenticationViewModel))
            {
                HandleAuthorisationClose();
            }
            else if (senderType == typeof(CreateNewUserViewModel))
            {
                HandleCreateNewUserClose((CreateNewUserViewModel)workspace);
            }
            else if (senderType == typeof(CloudDirectoryViewModel))
            {
                ((CloudDirectoryViewModel)sender).OnSave -= CloudVmSaved;
            }
            if (Workspaces.Any())
            {
                ICollectionView collectionView = CollectionViewSource.GetDefaultView(this.Workspaces);

                DisplayName = ((ViewModelBase)collectionView.CurrentItem).DisplayName;
            }
            else
            {
                DisplayName = Strings.MainWindowViewModel_WorkspaceName;
            }
        }
コード例 #2
0
        public void AddWorkspace(Workspace workspace)
        {
            if (Workspaces.Any(w => w.Name == workspace.Name))
            {
                throw new InvalidOperationException("Workspace name must be unique");
            }

            Workspaces.Add(workspace);
        }
コード例 #3
0
 public void BuildContextMenu()
 {
     SelectWorkspaceMenu =
         Workspaces.Select(workspace => new DelegateCommand <object>(workspace.Name, o => SelectedWorkspace = workspace))
         .Concat(GetGitRepositoriesCommands())
         .Concat(StaticCommands.Merge(Workspaces != null && Workspaces.Any() ? StaticCommands.Seperator : null,
                                      SelectDirectoryCommand,
                                      StaticCommands.Seperator,
                                      TfsContext.IsTfsConnected
                         ? StaticCommands.ManageWorkspacesCommand
                         : StaticCommands.ConnectToSourceControlCommand))
         .ToContextMenu();
 }
コード例 #4
0
        private Task LoadWorkspacesAsync(CancellationToken cancellationToken)
        {
            SelectWorkspaceMenu = null;
            if (Workspaces != null && Workspaces.Any())
            {
                Workspaces.Clear();
            }
            var tfsContext = TfsContext;

            if (IsConnected && tfsContext != null)
            {
                bool   invertRegex = Settings.Get(SettingsKeys.WorkspaceFilterRegexBehavoirKey, WorkspaceFilterRegexBehavoir.Disabled) == WorkspaceFilterRegexBehavoir.Inverted;
                string regex       = Settings.Get(SettingsKeys.WorkspaceFilterRegexBehavoirKey, WorkspaceFilterRegexBehavoir.Disabled) == WorkspaceFilterRegexBehavoir.Disabled ? string.Empty : Settings.Get(SettingsKeys.WorkspaceFilterRegexKey, "^((?!SQL).)*$");

                return(Task.Run(() => tfsContext.GetWorkspaces().Where(w => string.IsNullOrEmpty(regex) || (new Regex(regex).IsMatch(w.Name) != invertRegex)), cancellationToken).IgnoreCancellation(cancellationToken).ContinueWith(task => Workspaces = new ObservableCollection <Workspace>(task.Result), taskSchedulerContext).IgnoreCancellation(cancellationToken));
            }

            return(Task.Delay(0, cancellationToken));
        }