示例#1
0
        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;
        }
示例#2
0
        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;
        }
示例#3
0
        CommitViewerTabViewModel CreateViewer(CommitNodeModel m)
        {
            CommitViewerTabModel c = new CommitViewerTabModel(m);

            c.CloseRequested += CloseTab;
            CommitViewerTabViewModel vm = new CommitViewerTabViewModel(c);

            return(vm);
        }
示例#4
0
        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);
        }
示例#5
0
        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);
                }
            }
        }
示例#6
0
 void OnShowChanges(CommitNodeModel m)
 {
     TabManager.NewCommitViewer(m);
 }
示例#7
0
 void HashCopyRequest(CommitNodeModel commitNode)
 {
     Clipboard.SetText(commitNode.Sha);
 }
示例#8
0
 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();
 }
示例#11
0
 Branch CreateBranch(string name, CommitNodeModel n)
 {
     return(Repository.CreateBranch(name, n.Commit));
 }