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


C# List.All方法代码示例

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


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

示例1: RenderPicture

        private void RenderPicture(Graphics g)
        {
            var angleOffset = -Math.PI / 2;
            var anglePerStudent = Math.PI * 2 / _students.Count;
            var center = new Point(_width / 2, _height / 2);
            var maxRadius = Math.Min(center.X, center.Y) * _ratio / 100.0f;

            Func<int, float, float, Point> getPoint = (id, delta, lRadius) =>
            {
                var radius = maxRadius * lRadius / 100.0f;
                var angle = angleOffset + anglePerStudent * (id + delta / 100.0f);
                return center + new Size((int)(radius * Math.Cos(angle)), (int)(radius * Math.Sin(angle)));
            };

            Func<float, Rectangle> getRectangle = lRadius =>
            {
                var delta = maxRadius*lRadius/100.0f;
                return new Rectangle((int)(center.X - delta), (int)(center.Y - delta), (int) (2*delta), (int) (2*delta));
            };

            Func<double, float> toDeg = rad => (float) (rad / Math.PI * 180);

            // Пороговые линии
            for (var j = 0; j < _grades.Count; ++j)
            {
                g.DrawPie(new Pen(Color.Black, j == (_grades.Count - 1) ? 4 : 2) {DashPattern = new[] {3.0f, 5.0f}},
                    getRectangle(_grades[j]), 0.0f, 360.0f);
            }

            // Основные и дополнительные зависимости
            for (var i = 0; i < _students.Count; ++i)
            {
                var grades = _students[i].Grades;

                var mainGrades = (_mode == Mode.Pie || _mode == Mode.Pie)
                        ? new[]{0.0f}.Concat(grades[0]).ToList()
                        : Enumerable.Range(0, grades[0].Length + 1).Select(a => a * 100.0f / grades[0].Length).ToList();

                // Основная зависимость
                for (var j = mainGrades.Count - 1; j >= 1; --j)
                {
                    if (Math.Abs(mainGrades[j]) > Parameters.Tolerance)
                    {
                        var brush = GetBrush(j, grades);

                        g.FillPie(brush, getRectangle(mainGrades[j]),
                            toDeg(angleOffset + anglePerStudent * i), toDeg(anglePerStudent));
                        g.DrawPie(new Pen(Color.Black, 2), getRectangle(mainGrades[j]),
                            toDeg(angleOffset + anglePerStudent * i), toDeg(anglePerStudent));
                    }
                }

                // Дополнительные зависимости
                for (var k = 1; k < grades.Length; ++k)
                {
                    var addGrades = new List<float> {0.0f};
                    addGrades.AddRange(grades[k]);

                    if (addGrades.All(a => a < Parameters.Tolerance))
                        continue;

                    for (var j = 0; j < addGrades.Count - 1; ++j)
                        g.DrawLine(_additionalData[(k - 1) % _additionalData.Count],
                            getPoint(i, addGrades[j], mainGrades[j]),
                            getPoint(i, addGrades[j + 1], mainGrades[j + 1]));
                }
            }

            // Разделительные линии между секторами
            for (var i = 0; i < _students.Count; ++i)
            {
                g.DrawLine(new Pen(Color.Black, 2), center, getPoint(i, 0, 110));
            }

            // Разделители между секторами
            for (var j = 0; j < _part.Count; ++j)
            {
                g.DrawLine(new Pen(Color.Black, 6), center, getPoint(_part[j], 0, 110));
            }

            var half = (int)Math.Ceiling(_students.Count / 2.0);

            // Имена студентов
            for (var i = 0; i < _students.Count; ++i)
            {
                var posRight = i < half;
                var point = getPoint(i, 50, 0.6f * maxRadius);
                var message = string.Format("{0} ({1})", _students[i].Name, _students[i].Info);
                g.DrawString(message, _font, Brushes.Black, point, posRight ? _rightFormat : _leftFormat);
            }

            var lOffset = new Point(470, 30);
            var lOffset2 = center + new Size(lOffset.X, lOffset.Y);
            const int lSize = 30;

            if (_mode == Mode.BlackRound || _mode == Mode.ColorRound)
            {
                lOffset = new Point(530, 30);
                lOffset2 = center + new Size(lOffset.X, lOffset.Y);

//.........这里部分代码省略.........
开发者ID:zZLOiz,项目名称:cogn-proto,代码行数:101,代码来源:Render.cs


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