public ProfileViewModel(GithubService githubService) { _githubService = githubService; Organizations = new ObservableCollection<Organization>(); LoadView(githubService); }
public AboutViewModel(GithubService githubService, INavigationService navigationService) { Michelsalib = githubService.Load(new UserRequest("michelsalib"), u => Michelsalib = u); AlbertoMonteiro = githubService.Load(new UserRequest("albertomonteiro"), u => AlbertoMonteiro = u); Gi7 = githubService.Load(new RepositoryRequest("michelsalib", "Gi7"), r => Gi7 = r); RepoSelectedCommand = new RelayCommand<Repository>(r => { if (r != null) navigationService.NavigateTo(String.Format(ViewModelLocator.REPOSITORY_URL, r.Owner.Login, r.Name)); }); UserSelectedCommand = new RelayCommand<User>(user => { if (user != null) navigationService.NavigateTo(string.Format(ViewModelLocator.USER_URL, user.Login)); }); ShareCommand = new RelayCommand(() => { new ShareLinkTask { LinkUri = new Uri("http://www.windowsphone.com/en-US/apps/2bdbe5da-a20a-42f5-8b08-cda2fbf9046f"), Title = "Check this Github app for Windows Phone 7", Message = "I found this app that you might like. Check it ou on the Marketplace, it is free!", }.Show(); }); }
public HomeViewModel(GithubService githubService, INavigationService navigationService) { _githubService = githubService; Organizations = new ObservableCollection<Organization>(); // commands RepoSelectedCommand = new RelayCommand<Repository>(r => OnRepoSelected(navigationService, r)); SearchedRepoSelectedCommand = new RelayCommand<SearchedRepository>(r => OnSearchedRepoSelected(navigationService, r)); EventSelectedCommand = new RelayCommand<Event>(e => OnEventSelected(navigationService, e)); UserSelectedCommand = new RelayCommand<User>(user => OnUserSelected(navigationService, user)); PanoramaChangedCommand = new RelayCommand<SelectionChangedEventArgs>(OnPanoramaChanged); ProfileCommand = new RelayCommand(() => OnProfile(navigationService), () => IsLoggedIn); AboutCommand = new RelayCommand(() => OnAbout(navigationService)); LogoutCommand = new RelayCommand(githubService.Logout, () => IsLoggedIn); // init if (_githubService.IsAuthenticated) { Login(); } else { Logout(); } // listenning to the github service githubService.IsAuthenticatedChanged += (s, e) => OnIsAuthenticatedChanged(e); // listenning to the search box PropertyChanged += (s, e) => OnPropertyChanged(githubService, e); Repos = new ObservableCollection<Repository>(); }
static ViewModelLocator() { if (!ViewModelBase.IsInDesignModeStatic) { NavigationService = new NavigationService(); GithubService = new GithubService(); GithubService.IsAuthenticatedChanged += (s, e) => { if (e.IsAuthenticated == false && !NavigationService.CurrentUri().Contains(HomeUrl)) NavigationService.NavigateTo(HomeUrl); }; GithubService.Loading += (s, e) => { GlobalLoading.Instance.IsLoading = e.IsLoading; }; GithubService.ConnectionError += (s, e) => { MessageBox.Show("Server unreachable.", "Gi7", MessageBoxButton.OK); }; GithubService.Unauthorized += (s, e) => { MessageBox.Show("Wrong credentials.", "Gi7", MessageBoxButton.OK); }; GithubService.Init(); } }
public IssueViewModel(GithubService githubService, INavigationService navigationService, string username, string repo, string number) { RepoName = String.Format("{0}/{1}", username, repo); IssueName = "Issue #" + number; Issue = githubService.Load(new IssueRequest(username, repo, number), i => Issue = i); CommentsRequest = new IssueCommentsRequest(username, repo, number); ShareCommand = new RelayCommand(() => { new ShareLinkTask { LinkUri = new Uri(Issue.HtmlUrl), Title = "Issue on" + RepoName + " is on Github: " + Issue.Title, Message = "I found this issue on Github, you might want to see it: " + Issue.Body, }.Show(); }, () => Issue != null); RepoSelectedCommand = new RelayCommand(() => { navigationService.NavigateTo(String.Format(ViewModelLocator.REPOSITORY_URL, username, repo)); }); CommentCommand = new RelayCommand(() => { githubService.Load(new IssueCommentRequest(username, repo, number, Comment), r => { Comment = null; CommentsRequest = new IssueCommentsRequest(username, repo, number); }); }, () => githubService.IsAuthenticated && Comment != null && Comment.Trim().Length > 0); }
public CommitViewModel(GithubService githubService, INavigationService navigationService, string username, string repo, string sha) { CanComment = false; MinimizeAppBar = true; GithubService = githubService; RepoName = String.Format("{0}/{1}", username, repo); Files = new ObservableCollection<CommitFile>(); Commit = githubService.Load(new CommitRequest(username, repo, sha), p => { Commit = p; foreach (var file in p.Files) { var lines = new ObservableCollection<CommitLine>(); if (file.Patch != null) foreach (var line in file.Patch.Split('\n')) { var color = Colors.White; switch (line.FirstOrDefault()) { case '+': color = Color.FromArgb(255, 49, 154, 49); break; case '-': color = Color.FromArgb(255, 230, 20, 0); break; case '@': color = Color.FromArgb(255, 25, 162, 222); break; } lines.Add(new CommitLine { Line = line, Color = new SolidColorBrush(color) }); } else lines.Add(new CommitLine { Line = "Binary file not shown", Color = new SolidColorBrush(Colors.Gray) }); Files.Add(new CommitFile { Lines = lines, File = file, }); } }); ShareCommand = new RelayCommand(() => new ShareLinkTask { LinkUri = new Uri("https://github.com" + RepoName + "/commit/" + sha), Title = "Commit on" + RepoName + " is on Github.", Message = "I found this commit on Github, you might want to see it.", }.Show()); CommentCommand = new RelayCommand(() => githubService.Load(new CommentCommitRequest(username, repo, sha, Comment), r => OnComment(username, repo, sha)), UserCanComment); PivotChangedCommand = new RelayCommand<SelectionChangedEventArgs>(args => OnPivotChangedCommand(username, repo, sha, args)); RepoSelectedCommand = new RelayCommand(() => navigationService.NavigateTo(String.Format(ViewModelLocator.REPOSITORY_URL, username, repo))); }
public PullRequestViewModel(GithubService githubService, INavigationService navigationService, string username, string repo, string number) { CanComment = false; MinimizeAppBar = true; RepoName = String.Format("{0}/{1}", username, repo); PullRequestName = "Pull Request #" + number; PullRequest = githubService.Load(new PullRequestRequest.Get(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 PullRequestRequest.Comment(username, repo, number, Comment), r => { Comment = null; CommentsRequest = new PullRequestRequest.ListComments(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 PullRequestRequest.ListComments(username, repo, number); break; default: // main pivot CanComment = false; break; } }); RepoSelectedCommand = new RelayCommand(() => { navigationService.NavigateTo(String.Format(ViewModelLocator.RepositoryUrl, username, repo)); }); }
public BlobViewModel(GithubService githubService, INavigationService navigationService, string username, string repo, string sha, string path) { Path = path; RepoName = String.Format("{0}/{1}", username, repo); githubService.Load(new Blob(username, repo, sha), b => { byte[] encodedDataAsBytes = Convert.FromBase64String(b.Content); String content = Encoding.UTF8.GetString(encodedDataAsBytes, 0, encodedDataAsBytes.Length); TextFile = content.Split('\n'); HeaderSignature type = new ContentGuesser().GuessType(path, encodedDataAsBytes); if (type != null) Console.Out.WriteLine(type.SignatureName); }); }
public TreeViewModel(GithubService githubService, INavigationService navigationService, string username, string repo, string sha, string path) { RepoName = String.Format("{0}/{1}", username, repo); Path = path; Tree = githubService.Load(new TreeRequest(username, repo, sha), t => Tree = t); ObjectSelectedCommand = new RelayCommand<GitHubFile>(o => { if (o.Type == "blob") navigationService.NavigateTo(String.Format(ViewModelLocator.BLOB_URL, username, repo, o.Sha, o.Path)); else //tree navigationService.NavigateTo(String.Format(ViewModelLocator.TREE_URL, username, repo, o.Sha, o.Path)); }); }
public void LoadView(GithubService githubService) { if (User == null) { User = _githubService.Load(new UserRequest(_githubService.Username), u => { User = u; _githubService.Load(new UserOrganizationRequest(_githubService.Username), organizations => { foreach (var organization in organizations) { Organizations.Add(organization); } }); }); } }
public UserViewModel(GithubService githubService, INavigationService navigationService, string user) { Username = user; EventsRequest = new UserEventsRequests(Username); ShowAppBar = false; ShareCommand = new RelayCommand(() => new ShareLinkTask { LinkUri = new Uri(User.HtmlUrl), Title = User.Name + " is on Github.", Message = "I found his profile on Github, you might want to see it.", }.Show(), () => User != null); FollowCommand = new RelayCommand(() => githubService.Load(new FollowUserRequest(Username, FollowUserRequest.Type.FOLLOW), r => { IsFollowing = true; }), () => IsFollowing.HasValue && !IsFollowing.Value); UnFollowCommand = new RelayCommand(() => githubService.Load(new FollowUserRequest(Username, FollowUserRequest.Type.UNFOLLOW), r => { IsFollowing = false; }), () => IsFollowing.HasValue && IsFollowing.Value); RepoSelectedCommand = new RelayCommand<Repository>(r => OnRepoSelected(navigationService, r)); UserSelectedCommand = new RelayCommand<User>(u => OnUserSelected(navigationService, user, u)); PivotChangedCommand = new RelayCommand<SelectionChangedEventArgs>(args => OnPivotChanged(githubService, args)); }
public ViewModelLocator() { ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); if (ViewModelBase.IsInDesignModeStatic) { } else { NavigationService = new NavigationService(); GithubService = new GithubService(); GithubService.IsAuthenticatedChanged += (s, e) => { if (e.IsAuthenticated == false && !NavigationService.CurrentUri().Contains(HOME_URL)) NavigationService.NavigateTo(HOME_URL); }; GithubService.Loading += (s, e) => { GlobalLoading.Instance.IsLoading = e.IsLoading; }; GithubService.ConnectionError += (s, e) => MessageBox.Show("Server unreachable.", "Gi7", MessageBoxButton.OK); GithubService.Unauthorized += (s, e) => MessageBox.Show("Wrong credentials.", "Gi7", MessageBoxButton.OK); GithubService.Init(); } }
public LoginPanelViewModel(GithubService githubService) { _githubService = githubService; LoginCommand = new RelayCommand(LogIn); }
public RepositoryViewModel(GithubService githubService, INavigationService navigationService, string user, string repo) { this.githubService = githubService; this.navigationService = navigationService; Load(user, repo); }
public LoginPanelViewModel(GithubService githubService) { LoginCommand = new RelayCommand(() => { githubService.AuthenticateUser(Email, Password); }); }
public CreateIssueViewModel(GithubService githubService, INavigationService navigationService, string user, string repo) { RepoName = String.Format("{0}/{1}", user, repo); CreateIssueCommand = new RelayCommand(() => { githubService.Load(new CreateIssueRequest(user, repo, Title, Body), issue => { navigationService.GoBack(); }); }, () => !String.IsNullOrWhiteSpace(Title) && !String.IsNullOrWhiteSpace(Body)); }
public RepositoryViewModel(GithubService githubService, INavigationService navigationService, String user, String repo) { ShowAppBar = true; Repository = githubService.Load(new RepositoryRequest.Get(user, repo), r => Repository = r); if (githubService.IsAuthenticated) { IsWatching = githubService.Load(new Watch(user, repo), r => { IsWatching = r; }); } Branches = githubService.Load(new RepositoryRequest.ListBranches(user, repo), b => { Branches = b; Branch = b.FirstOrDefault(br => br.Name == "master"); }); PropertyChanged += (s, e) => { if (e.PropertyName == "Branch") { CommitsRequest = null; Tree = githubService.Load(new TreeRequest.Get(user, repo, Branch.Commit.Sha), t => Tree = t); } }; ObjectSelectedCommand = new RelayCommand<Client.Model.GitHubFile>(o => { if (o.Type == "blob") { navigationService.NavigateTo(String.Format(ViewModelLocator.BlobUrl, user, repo, o.Sha, o.Path)); } else { //tree navigationService.NavigateTo(String.Format(ViewModelLocator.TreeUrl, user, repo, o.Sha, o.Path)); } }); DownloadCommand = new RelayCommand(() => { new WebBrowserTask() { Uri = new Uri(Repository.HtmlUrl + "/zipball/" + Branch.Name), }.Show(); }, () => Repository != null && Branch != null); ShareDownloadCommand = new RelayCommand(() => { new ShareLinkTask() { LinkUri = new Uri(Repository.HtmlUrl + "/zipball/" + Branch.Name), Title = Repository.Fullname + " sources are on Github.", Message = "I found this sources on Github, you might want to get it.", }.Show(); }, () => Repository != null && Branch != null); ShareCommand = new RelayCommand(() => { new ShareLinkTask() { LinkUri = new Uri(Repository.HtmlUrl), Title = Repository.Fullname + " is on Github.", Message = "I found this repository on Github, you might want to see it.", }.Show(); }, () => Repository != null); OwnerCommand = new RelayCommand(() => navigationService.NavigateTo(String.Format(ViewModelLocator.UserUrl, Repository.Owner.Login))); WatchCommand = new RelayCommand(() => { githubService.Load(new Watch(user, repo, Watch.Type.WATCH), r => { IsWatching = true; }); }, () => IsWatching.HasValue && !IsWatching.Value); UnWatchCommand = new RelayCommand(() => { githubService.Load(new Watch(user, repo, Watch.Type.UNWATCH), r => { IsWatching = false; }); }, () => IsWatching.HasValue && IsWatching.Value); PivotChangedCommand = new RelayCommand<SelectionChangedEventArgs>(args => { var header = ((PivotItem)args.AddedItems[0]).Header as String; ShowAppBar = false; switch (header) { case "Commits": if (CommitsRequest == null) CommitsRequest = new CommitRequest.List(user, repo, Branch ? Branch.Name : "master"); break; case "Pull requests": if (PullRequestsRequest == null) PullRequestsRequest = new PullRequestRequest.List(user, repo); break; case "Issues": if (IssuesRequest == null) IssuesRequest = new IssueRequest.List(user, repo); break; case "Collaborators": if (CollaboratorRequest == null) CollaboratorRequest = new RepositoryRequest.ListCollaborators(user, repo); break; case "Watchers": if (WatchersRequest == null) WatchersRequest = new RepositoryRequest.ListWatchers(user, repo); break; case "Details": ShowAppBar = true; break; } }); CommitSelectedCommand = new RelayCommand<Push>(push => { if (push) navigationService.NavigateTo(String.Format(ViewModelLocator.CommitUrl, Repository.Owner.Login, Repository.Name, push.Sha)); }); PullRequestSelectedCommand = new RelayCommand<PullRequest>(pullRequest => { if (pullRequest) navigationService.NavigateTo(String.Format(ViewModelLocator.PullRequestUrl, Repository.Owner.Login, Repository.Name, pullRequest.Number)); }); IssueSelectedCommand = new RelayCommand<Issue>(issue => { if (issue) { string destination = issue.PullRequest.HtmlUrl == null ? ViewModelLocator.IssueUrl : ViewModelLocator.PullRequestUrl; navigationService.NavigateTo(String.Format(destination, Repository.Owner.Login, Repository.Name, issue.Number)); } }); UserCommand = new RelayCommand<User>(collaborator => navigationService.NavigateTo(String.Format(ViewModelLocator.UserUrl, collaborator.Login))); }
private void OnPropertyChanged(GithubService githubService, PropertyChangedEventArgs e) { if (e.PropertyName == "Search") SearchResult = githubService.Load(new SearchRequest(Search), r => SearchResult = r); }
private void OnPivotChanged(GithubService githubService, SelectionChangedEventArgs args) { var header = ((PivotItem)args.AddedItems[0]).Header as String; ShowAppBar = false; switch (header) { case "feed": if (EventsRequest == null) EventsRequest = new UserEventsRequests(Username); break; case "owned repos": if (RepositoriesRequest == null) RepositoriesRequest = new RepositoriesRequest(Username); break; case "watched reps": if (RepositoriesWatchedRequest == null) RepositoriesWatchedRequest = new RepositoriesWatchedRequest(Username); break; case "follower": if (FollowersRequest == null) FollowersRequest = new UserFollowersRequest(Username); break; case "following": if (FollowingsRequest == null) FollowingsRequest = new UserFollowingRequest(Username); break; case "profile": case "details": if (User == null) { User = githubService.Load(new UserRequest(Username), u => User = u); if (githubService.IsAuthenticated) IsFollowing = githubService.Load(new FollowUserRequest(Username), r => { IsFollowing = r; }); } ShowAppBar = true; break; } }
public void SeedData(EmployerEmployeeHuntDbContext context) { IGithubService githubService = new GithubService(); var developersProfiles = new string[] { "https://github.com/TsvetanMilanov", "https://github.com/IvanMomchilov", "https://github.com/ivaylokenov", "https://github.com/NikolayIT" }; var adminRole = context.Roles.FirstOrDefault(r => r.Name == GlobalConstants.AdministratorRoleName); var headhunterRole = context.Roles.FirstOrDefault(r => r.Name == GlobalConstants.HeadhunterRoleName); var users = context.Users.Where(u => !u.Roles.Any(r => r.RoleId == adminRole.Id || r.RoleId == headhunterRole.Id)).ToList(); for (int i = 0; i < developersProfiles.Length; i++) { var currentProfile = developersProfiles[i]; string userId = string.Empty; if (i < users.Count) { var currentUser = users[i]; userId = currentUser.Id; } else { var userStore = new UserStore<User>(context); var userManager = new UserManager<User>(userStore); var newUser = new User { UserName = string.Format("developer_{0}", i), Email = string.Format("developer_{0}@somemail.com", i) }; userManager.Create(newUser, newUser.Email); userManager.AddToRole(newUser.Id, GlobalConstants.UserRoleName); userId = newUser.Id; } string userName = this.GetUserNameFromGithubProfileLink(currentProfile); Dictionary<string, long> skills = githubService.GetAllLanguagesFromGithubReposForUser(userName); var skillsNames = new List<string>(); foreach (var skill in skills) { if (skill.Value >= MinLinesOfCodeForSkill) { skillsNames.Add(skill.Key); } } var allDbSkills = context.Skills.ToList(); Dictionary<string, Skill> allDbSkillsWithNames = new Dictionary<string, Skill>(); foreach (var skill in allDbSkills) { allDbSkillsWithNames.Add(skill.Name, skill); } var userSkills = new List<Skill>(); foreach (var skill in skillsNames) { if (allDbSkillsWithNames.ContainsKey(skill)) { userSkills.Add(allDbSkillsWithNames[skill]); } else { userSkills.Add(new Skill() { Name = skill }); } } DeveloperProfile developerProfile = new DeveloperProfile { GithubProfile = currentProfile, IsAvailableForHire = true, Skills = userSkills, Id = userId }; context.DeveloperProfiles.Add(developerProfile); context.SaveChanges(); } }
public UserViewModel(GithubService githubService, INavigationService navigationService, string user) { Username = user; EventsRequest = new ListForUser(Username); ShowAppBar = false; ShareCommand = new RelayCommand(() => { new ShareLinkTask() { LinkUri = new Uri(User.HtmlUrl), Title = User.Name + " is on Github.", Message = "I found his profile on Github, you might want to see it.", }.Show(); }, () => User != null); FollowCommand = new RelayCommand(() => { githubService.Load(new Follow(Username, Follow.Type.FOLLOW), r => { IsFollowing = true; }); }, () => IsFollowing.HasValue && !IsFollowing.Value); UnFollowCommand = new RelayCommand(() => { githubService.Load(new Follow(Username, Follow.Type.UNFOLLOW), r => { IsFollowing = false; }); }, () => IsFollowing.HasValue && IsFollowing.Value); RepoSelectedCommand = new RelayCommand<Repository>(r => { if (r != null) navigationService.NavigateTo(String.Format(ViewModelLocator.RepositoryUrl, r.Owner.Login, r.Name)); }); UserSelectedCommand = new RelayCommand<User>(u => { if (user != null) navigationService.NavigateTo(string.Format(ViewModelLocator.UserUrl, u.Login)); }); PivotChangedCommand = new RelayCommand<SelectionChangedEventArgs>(args => { var header = ((PivotItem)args.AddedItems[0]).Header as String; ShowAppBar = false; switch (header) { case "Feed": if (EventsRequest == null) EventsRequest = new ListForUser(Username); break; case "Repos": if (Repos == null) { Repos = githubService.Load(new ListWatched(Username)); Repos.CollectionChanged += (sender, e) => { RaisePropertyChanged("WatchedRepos"); RaisePropertyChanged("OwnedRepos"); }; } break; case "Follower": if (FollowersRequest == null) FollowersRequest = new ListFollowers(Username); break; case "Following": if (FollowingsRequest == null) FollowingsRequest = new ListFollowings(Username); break; case "Profile": case "Details": if (User == null) { User = githubService.Load(new UserRequest.Get(Username), u => User = u); if (githubService.IsAuthenticated) { IsFollowing = githubService.Load(new Follow(Username), r => { IsFollowing = r; }); } } ShowAppBar = true; break; } }); }
public HomeViewModel(GithubService githubService, INavigationService navigationService) { _githubService = githubService; // commands FeaturedRepoSelectedCommand = new RelayCommand<FeaturedRepo>(r => { if (r != null) navigationService.NavigateTo(String.Format(ViewModelLocator.RepositoryUrl, r.User, r.Repo)); }); RepoSelectedCommand = new RelayCommand<Repository>(r => { if (r != null) navigationService.NavigateTo(String.Format(ViewModelLocator.RepositoryUrl, r.Owner.Login, r.Name)); }); EventSelectedCommand = new RelayCommand<Event>(e => { if (e != null) navigationService.NavigateTo(new EventManager().GetDestination(e)); }); UserSelectedCommand = new RelayCommand<User>(user => { if (user != null) navigationService.NavigateTo(string.Format(ViewModelLocator.UserUrl, user.Login)); }); ResultSelectedCommand = new RelayCommand<SearchResult>(r => { if (r.Type == "user") { navigationService.NavigateTo(string.Format(ViewModelLocator.UserUrl, r.Name)); } else // repo { var repoData = r.Name.Split('/'); navigationService.NavigateTo(string.Format(ViewModelLocator.RepositoryUrl, repoData[0].Trim(), repoData[1].Trim())); } }); PanoramaChangedCommand = new RelayCommand<SelectionChangedEventArgs>(args => { _loadPanel((args.AddedItems[0] as PanoramaItem).Header as String); }); AboutCommand = new RelayCommand(() => navigationService.NavigateTo(ViewModelLocator.AboutUrl)); LogoutCommand = new RelayCommand(() => githubService.Logout(), () => IsLoggedIn); // init if (_githubService.IsAuthenticated) _login(); else _logout(); // listenning to the github service githubService.IsAuthenticatedChanged += (s, e) => { if (e.IsAuthenticated) _login(); else _logout(); }; // listenning to the search box PropertyChanged += (s, e) => { if (e.PropertyName == "Search") { SearchResults = githubService.Load(new Search(Search), r => SearchResults = r); } }; }
public CommitViewModel(GithubService githubService, INavigationService navigationService, string username, string repo, string sha) { CanComment = false; MinimizeAppBar = true; GithubService = githubService; RepoName = String.Format("{0}/{1}", username, repo); Commit = githubService.Load(new CommitRequest.Get(username, repo, sha), p => { Commit = p; var files = new ObservableCollection<CommitFile>(); foreach (var file in p.Files) { var lines = new ObservableCollection<CommitLine>(); if (file.Patch != null) { foreach (var line in file.Patch.Split('\n')) { Color color = Colors.White; switch (line.FirstOrDefault()) { case '+': color = Color.FromArgb(255, 49, 154, 49); break; case '-': color = Color.FromArgb(255, 230, 20, 0); break; case '@': color = Color.FromArgb(255, 25, 162, 222); break; } lines.Add(new CommitLine { Line = line, Color = new SolidColorBrush(color), }); } } else { lines.Add(new CommitLine { Line = "Binary file not shown", Color = new SolidColorBrush(Colors.Gray), }); } files.Add(new CommitFile { Lines = lines, File = file, }); } Files = files; }); ShareCommand = new RelayCommand(() => { new ShareLinkTask() { LinkUri = new Uri("https://github.com" + RepoName + "/commit/" + sha), Title = "Commit on" + RepoName + " is on Github.", Message = "I found this commit on Github, you might want to see it.", }.Show(); }); CommentCommand = new RelayCommand(() => { githubService.Load(new CommitRequest.Comment(username, repo, sha, Comment), r => { Comment = null; CommentsRequest = new CommitRequest.ListComments(username, repo, sha); }); }, () => 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 CommitRequest.ListComments(username, repo, sha); break; case "Commit": CanComment = false; break; } }); RepoSelectedCommand = new RelayCommand(() => { navigationService.NavigateTo(String.Format(ViewModelLocator.RepositoryUrl, username, repo)); }); }