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


C# Rectangle.Count方法代码示例

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


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

示例1: FourByFourRectangleHasSixteenPoints

        public void FourByFourRectangleHasSixteenPoints()
        {
            Rectangle rect = new Rectangle (4, 4);

            Assert.That (rect.Count (), Is.EqualTo (16));
        }
开发者ID:manicolosi,项目名称:questar,代码行数:6,代码来源:RectangleFixture.cs

示例2: GenerateCardImages

    public void GenerateCardImages()
    {
        int s = 10;
        int h = 100;
        int w = 300;
        foreach (var card in Card.GetCards())
        {
            var img = new Bitmap(w, w);
            var graphics = Graphics.FromImage(img);
            graphics.Clear(Color.White);

            Brush brush;
            if (card.Fill == Card.Fills.Solid.ToString())
            {
                brush = new SolidBrush(card.Color);
            }
            else if (card.Fill == Card.Fills.Striped.ToString())
            {
                brush = new HatchBrush(HatchStyle.WideUpwardDiagonal, Color.White, card.Color);
            }
            else
            {
                brush = new SolidBrush(Color.White);
            }

            // shape
            Rectangle[] rectangles = new Rectangle[card.Number];
            for (int i = 0; i < card.Number; i++)
            {
                int x = s;
                int width = w - (s * 2);
                int y = (i * h) + s;
                int height = h - (s * 2);
                var rectangle = new Rectangle(x, y, width, height);
                if (card.Shape == Card.Shapes.Rectangle.ToString())
                {
                    rectangles[i] = rectangle;

                    if (card.Fill == Card.Fills.Empty.ToString())
                    {
                        if (rectangles.Count() > 0)
                        {
                            graphics.DrawRectangle(new Pen(card.Color), rectangle);
                        }
                    }
                    else
                    {
                        graphics.FillRectangle(brush, rectangle);
                    }
                }
                else if (card.Shape == Card.Shapes.Oval.ToString())
                {
                    if (card.Fill == Card.Fills.Empty.ToString())
                    {
                        graphics.DrawEllipse(new Pen(card.Color), rectangle);
                    }
                    else
                    {
                        graphics.FillEllipse(brush, rectangle);
                    }
                }
                else if (card.Shape == Card.Shapes.Diamond.ToString())
                {
                    var sp = i == 0 ? s : s * 2;
                    var x1 = width;
                    var y1 = (height / 2) + (h * i);
                    var x2 = (width / 2);
                    var y2 = i * height;
                    var x3 = s / 2;
                    var y3 = (height / 2) + (h * i);
                    var x4 = width / 2;
                    // var y4 =(height * (i+1));
                    var y4 = y1 + (height / 2);
                    var points = new Point[]{
                           new Point(x1 + s, y1  - (s*i)+ sp - s),
                           new Point(x2 + s, y2+ (s* (i+1))+ sp-s),
                           new Point(x3, y3  - (s*i)+ sp-s ),
                           new Point(x4 + s, y4 - (s*i)+ sp-s)
                        };

                    if (card.Fill == Card.Fills.Empty.ToString())
                    {
                        graphics.DrawPolygon(new Pen(card.Color), points);
                    }
                    else
                    {
                        graphics.FillPolygon(brush, points);
                    }
                }
            }

            var path = string.Format("~/Images/Cards/SetImage-{0}.png", card.CardID);
            img.RotateFlip(RotateFlipType.Rotate90FlipNone);
            img.Save(HttpContext.Current.Server.MapPath(path), ImageFormat.Png);
        }
    }
开发者ID:rivdiv,项目名称:play-set,代码行数:96,代码来源:CardGenerator.cs

示例3: OneByOneRectangleHasOnePoint

        public void OneByOneRectangleHasOnePoint()
        {
            Rectangle rect = new Rectangle (1, 1);

            Assert.That (rect.Count (), Is.EqualTo (1));
        }
开发者ID:manicolosi,项目名称:questar,代码行数:6,代码来源:RectangleFixture.cs


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