Esempio n. 1
0
        public PullRequestViewModel(GithubService githubService, INavigationService navigationService, string username, string repo, string number)
        {
            if (!IsInDesignMode)
            {
                CanComment      = false;
                MinimizeAppBar  = true;
                RepoName        = String.Format("{0}/{1}", username, repo);
                PullRequestName = "Pull Request #" + number;
            }

            PullRequest = githubService.Load(new PullRequestRequest(username, repo, number), pr => PullRequest = pr);

            ShareCommand = new RelayCommand(() => new ShareLinkTask
            {
                LinkUri = new Uri(PullRequest.HtmlUrl),
                Title   = "Pull Request on" + RepoName + " is on Github: " + PullRequest.Title,
                Message = "I found this pull request on Github, you might want to see it: " + PullRequest.Body,
            }.Show(), () => PullRequest != null);

            CommentCommand = new RelayCommand(() => githubService.Load(new CreatePullRequestCommentsRequest(username, repo, number, Comment), r =>
            {
                Comment         = null;
                CommentsRequest = new PullRequestCommentsRequest(username, repo, number);
            }), () => githubService.IsAuthenticated && _canComment && Comment != null && Comment.Trim().Length > 0);

            PivotChangedCommand = new RelayCommand <SelectionChangedEventArgs>(args =>
            {
                MinimizeAppBar = true;
                CanComment     = false;
                var header     = (args.AddedItems[0] as PivotItem).Header as String;
                switch (header)
                {
                case "Comments":
                    MinimizeAppBar = false;
                    CanComment     = true;
                    if (CommentsRequest == null)
                    {
                        CommentsRequest = new PullRequestCommentsRequest(username, repo, number);
                    }
                    break;

                default: // main pivot
                    CanComment = false;
                    break;
                }
            });

            RepoSelectedCommand = new RelayCommand(() => navigationService.NavigateTo(String.Format(ViewModelLocator.REPOSITORY_URL, username, repo)));
        }
Esempio n. 2
0
        public PullRequestViewModel(GithubService githubService, INavigationService navigationService, string username, string repo, string number)
        {
            if (!IsInDesignMode)
            {
                CanComment = false;
                MinimizeAppBar = true;
                RepoName = String.Format("{0}/{1}", username, repo);
                PullRequestName = "Pull Request #" + number;
            }

            PullRequest = githubService.Load(new PullRequestRequest(username, repo, number), pr => PullRequest = pr);

            ShareCommand = new RelayCommand(() => new ShareLinkTask
            {
                LinkUri = new Uri(PullRequest.HtmlUrl),
                Title = "Pull Request on" + RepoName + " is on Github: " + PullRequest.Title,
                Message = "I found this pull request on Github, you might want to see it: " + PullRequest.Body,
            }.Show(), () => PullRequest != null);

            CommentCommand = new RelayCommand(() => githubService.Load(new CreatePullRequestCommentsRequest(username, repo, number, Comment), r =>
            {
                Comment = null;
                CommentsRequest = new PullRequestCommentsRequest(username, repo, number);
            }), () => githubService.IsAuthenticated && _canComment && Comment != null && Comment.Trim().Length > 0);

            PivotChangedCommand = new RelayCommand<SelectionChangedEventArgs>(args =>
            {
                MinimizeAppBar = true;
                CanComment = false;
                var header = (args.AddedItems[0] as PivotItem).Header as String;
                switch (header)
                {
                case "Comments":
                    MinimizeAppBar = false;
                    CanComment = true;
                    if (CommentsRequest == null)
                        CommentsRequest = new PullRequestCommentsRequest(username, repo, number);
                    break;
                default: // main pivot
                    CanComment = false;
                    break;
                }
            });

            RepoSelectedCommand = new RelayCommand(() => navigationService.NavigateTo(String.Format(ViewModelLocator.REPOSITORY_URL, username, repo)));
        }