コード例 #1
0
        /// <summary>
        /// Clone a repository from Google Cloud Source Repository.
        /// </summary>
        /// <param name="projects">A list of GCP <seealso cref="Project"/>.</param>
        /// <returns>
        /// The cloned repo item or null if no repo is cloned.
        /// </returns>
        public static CloneDialogResult PromptUser(IList <Project> projects)
        {
            var dialog = new CsrCloneWindow(projects);

            dialog.ShowModal();
            return(dialog.ViewModel.Result);
        }
コード例 #2
0
        public CsrCloneWindowViewModel(CsrCloneWindow owner, IList <Project> projects)
        {
            _owner   = owner.ThrowIfNull(nameof(owner));
            Projects = projects.ThrowIfNull(nameof(projects));
            if (!Projects.Any())
            {
                throw new ArgumentException($"{nameof(projects)} must not be empty");
            }
            PickFolderCommand = new ProtectedCommand(PickFoloder);
            CloneRepoCommand  = new ProtectedAsyncCommand(() => ExecuteAsync(CloneAsync), canExecuteCommand: false);
            CreateRepoCommand = new ProtectedCommand(OpenCreateRepoDialog, canExecuteCommand: false);
            RepositoriesAsync.PropertyChanged += RepositoriesAsyncPropertyChanged;

            var projectId = CredentialsStore.Default.CurrentProjectId;

            // If projectId is null, choose first project. Otherwise, choose the project.
            SelectedProject = Projects.FirstOrDefault(x => projectId == null || x.ProjectId == projectId);
        }
コード例 #3
0
        private async Task CloneCreateRepoAsync()
        {
            var projects = await GetProjectsAsync();

            if (!projects.Any())
            {
                return;
            }

            var result = CsrCloneWindow.PromptUser(projects);

            if (result == null)
            {
                return;
            }

            var repoItem = result.RepoItem;

            Repositories.Add(repoItem);

            // Created a new repo and cloned locally
            if (result.JustCreatedRepo)
            {
                var msg = String.Format(Resources.CsrCreateRepoNotificationFormat, repoItem.Name, repoItem.LocalPath);
                _teamExplorer.ShowMessage(msg,
                                          command: new ProtectedAsyncCommand(
                                              async() =>
                {
                    SetRepoActive(repoItem);
                    await ShellUtils.Default.LaunchCreateSolutionDialogAsync(repoItem.LocalPath);
                    _teamExplorer.ShowHomeSection();
                }));
            }
            else
            {
                var msg = String.Format(Resources.CsrCloneRepoNotificationFormat, repoItem.Name, repoItem.LocalPath);
                _teamExplorer.ShowMessage(msg,
                                          command: new ProtectedCommand(() =>
                {
                    SetRepoActive(repoItem);
                    _teamExplorer.ShowHomeSection();
                }));
            }
        }