当前位置: 首页>>代码示例>>C#>>正文


C# ItemCollection.MoveCurrentToLast方法代码示例

本文整理汇总了C#中System.Windows.Controls.ItemCollection.MoveCurrentToLast方法的典型用法代码示例。如果您正苦于以下问题:C# ItemCollection.MoveCurrentToLast方法的具体用法?C# ItemCollection.MoveCurrentToLast怎么用?C# ItemCollection.MoveCurrentToLast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.ItemCollection的用法示例。


在下文中一共展示了ItemCollection.MoveCurrentToLast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

        /// <summary>
        /// This methods draws the graph for the changeset history grid.
        /// </summary>
        public void Draw(ItemCollection commitList)
        {
            if (graph == null)
                return;

            Console.WriteLine("Drawing graph.");

            var repo = new LibGit2Sharp.Repository(repositoryViewModel.RepositoryFullPath);
            commitDotPositions.Clear();
            SetBranchColors(repo.Branches);

            // Loop through all commits and draw the graph, in reverse order.
            commitList.MoveCurrentToLast();

            // Clear the existing graph.
            graph.Children.Clear();

            TotalHeight = 0;

            while (true)
            {
                Commit commit = commitList.CurrentItem as Commit;
                int rowNumber = commitList.CurrentPosition;

                if (commit == null)
                    break;

                // Get a list of branches around this commit.
                List<Branch> branchesAroundCommit = commit.BranchesAround;

                // Sort the lists alphabetically.
                branchesAroundCommit.OrderBy(o => o.Name.ToString());

                // Retrieve the index of this commit's branch on the list. This index determines the horizontal positions of dots (commit dots).
                int indexOfCurrentBranch;
                if (commit.Branches.Count > 0)
                    indexOfCurrentBranch = branchesAroundCommit.IndexOf(commit.Branches.ElementAt(0));
                else
                    indexOfCurrentBranch = 0;

                int horizontalIndex = indexOfCurrentBranch + commit.VisualPosition;
                for (var i = indexOfCurrentBranch - 1; i >= 0; i--)
                    horizontalIndex += ((Branch) branchesAroundCommit.ElementAt(i)).RightMostVisualPosition;

                // Draw the dot/ellipse based on the index of the current branch.
                byte dotSize = 10;
                byte horizontalDotSpacing = 12;

                int dotX = horizontalDotSpacing + dotSize * horizontalIndex + horizontalDotSpacing * horizontalIndex;
                int dotY = cellHeight * rowNumber + cellHeight / 2 - dotSize / 2;

                if (TotalHeight == 0)
                    TotalHeight = cellHeight * (rowNumber + 1);

                // Store the dot position on the dictionary.
                commitDotPositions.Add(commit.Hash, new int[2] { dotX, dotY });

                Ellipse dot = new Ellipse
                {
                    Fill = Brushes.Black,
                    StrokeThickness = 0,
                    Width = dotSize + 2,
                    Height = dotSize + 2
                };

                Canvas.SetLeft(dot, dotX - 1);
                Canvas.SetTop(dot, dotY - 1);
                Canvas.SetZIndex(dot, 1);

                graph.Children.Add(dot);

                // ToolTip for commits.
                var commitTooltip = new TextBlock
                {
                    MaxWidth = 320,
                    TextWrapping = TextWrapping.Wrap
                };

                // ToolTip for paths.
                var pathTooltip = new TextBlock
                {
                    MaxWidth = 320,
                    TextWrapping = TextWrapping.Wrap
                };

                if (commit.Branches.Count == 1)
                {
                    pathTooltip.Text = commit.Branches.ElementAt(0).Name;
                }
                else
                {
                    int i = 0, count = commit.Branches.Count;

                    commit.Branches.ForEach(b =>
                    {
                        i++;
                        pathTooltip.Inlines.AddRange(new Inline[]
//.........这里部分代码省略.........
开发者ID:jez9999,项目名称:Git-GUI,代码行数:101,代码来源:ChangesetGraph.cs


注:本文中的System.Windows.Controls.ItemCollection.MoveCurrentToLast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。