void DeployCommitNodes() { var inProgress = Program.GetInstance().StashingManager.ImplicitStashBases; var commitRows = LibGitService.GetInstance().CommitRows(); ZoomAndPanCanvasModel.Commits?.ToList().ForEach(c => UnsubscribeCommitEvents(c)); List <CommitNodeModel> commitModels = new List <CommitNodeModel>(); int x = 0; List <CommitNodeModel> commits = commitRows.Select(pair => { Commit c = pair.Item1; BitmapImage picture = null; if (c.Author.Name != "" && c.Author.Email != "") { Identity i = new Identity(c.Author.Name, c.Author.Email); picture = Program.GetInstance().UserManager.FindUserPictureByIdentity(i); } CommitNodeModel m = new CommitNodeModel(c, picture) { Location = new Point(x, pair.Item2 * 70) }; x += (int)m.MaxWidth + 150; if (inProgress != null && inProgress.Contains(c)) { m.InProgress = true; } return(m); }).ToList(); commits.ForEach(c => commitModels.Add(c)); commitModels.ForEach(c => SubscribeCommitEvents(c)); ZoomAndPanCanvasModel.Commits = commitModels; }
void DeployBranchNodes() { List <BranchLabelModel> branchModels = new List <BranchLabelModel>(); ZoomAndPanCanvasModel.Branches?.ToList().ForEach(b => UnsubscribeEvents(b)); Dictionary <Commit, CommitNodeModel> pairs = ZoomAndPanCanvasModel.Commits.ToDictionary(x => x.Commit); List <IGrouping <Commit, Branch> > branchGroups = LibGitService.GetInstance().Branches.GroupBy(b => b.Tip).ToList(); foreach (var branchGroup in branchGroups) { int y = 1; List <BranchLabelModel> mg = branchGroup.ToList().Select(b => { CommitNodeModel tipNode = pairs[b.Tip]; tipNode.PlusButton = false; Point cl = tipNode.Location; BranchLabelModel m = new BranchLabelModel() { Location = new Point(cl.X, cl.Y - 10 - 32 * (y++)), Branch = b }; branchModels.Add(m); return(m); }).ToList(); mg.First().Arrow = true; mg.Last().PlusButton = true; } branchModels.ForEach(b => SubscribeEvents(b)); ZoomAndPanCanvasModel.Branches = branchModels; }
CommitViewerTabViewModel CreateViewer(CommitNodeModel m) { CommitViewerTabModel c = new CommitViewerTabModel(m); c.CloseRequested += CloseTab; CommitViewerTabViewModel vm = new CommitViewerTabViewModel(c); return(vm); }
public void NewCommitViewer(CommitNodeModel m) { CommitViewerTabViewModel cv; if (CommitViewers.Keys.Contains(m)) { cv = CommitViewers[m]; } else { cv = CreateViewer(m); CommitViewers.Add(m, cv); MainWindowModel.AddTab(cv); } SelectTab(cv); }
void UpdateCheckouted() { Branch head = LibGitService.GetInstance().Head; BranchLabelModel checkoutedBranch = ZoomAndPanCanvasModel.Branches.Find(b => b.Branch.CanonicalName == head.CanonicalName); if (checkoutedBranch != null) { HighlightAsCheckouted(checkoutedBranch); } else { CommitNodeModel checkoutedCommit = ZoomAndPanCanvasModel.Commits.Find(c => c.Sha == head.Reference.TargetIdentifier); if (checkoutedCommit != null) { HighlightAsCheckouted(checkoutedCommit); } } }
void OnShowChanges(CommitNodeModel m) { TabManager.NewCommitViewer(m); }
void HashCopyRequest(CommitNodeModel commitNode) { Clipboard.SetText(commitNode.Sha); }
void SubscribeCommitEvents(CommitNodeModel m) { m.CopyShaRequested += EventHandlerBatch.CopyHash; SubscribeEvents(m); }
public CommitViewerTabModel(CommitNodeModel m) { Commit = m; Refresh(); LibGitService.GetInstance().RepositoryChanged += Refresh; }
public CommitNodeViewModel(CommitNodeModel model, CommitNodeView view) : base(model, view) { SubscribeViewEvents(view); InitializeLocation(); }
Branch CreateBranch(string name, CommitNodeModel n) { return(Repository.CreateBranch(name, n.Commit)); }