OSDN Git Service

レタリング方式の選択方法を変更した
[d2dbench/d2dbench.git] / D2DBench / Method7.cs
1 using System;\r
2 using System.Drawing;\r
3 using System.Diagnostics;\r
4 using System.Windows.Forms;\r
5 \r
6 namespace D2DBench\r
7 {\r
8     class Method7 : IBench\r
9     {\r
10         public int fillAreaSize { get { return bmpSize.Width * bmpSize.Height * this.loopCount; } }\r
11         public string methodName { get { return "GDI塗りつぶし"; } }\r
12         public int loopCount { get; set; }\r
13 \r
14         GDI gdi;\r
15         ColorTableGDI colors;\r
16         Size ClientSize;\r
17         const string showStr = "D2DBenchMark";\r
18         Font font;\r
19         Size bmpSize = D2DBench.Properties.Resources.image.Size;\r
20 \r
21         public void Init(Control ctrl, bool antialias)\r
22         {\r
23             ClientSize = ctrl.ClientSize;\r
24             gdi = new GDI(ctrl);\r
25             colors = new ColorTableGDI();\r
26             font = ctrl.Font;\r
27             ctrl.Show();\r
28         }\r
29 \r
30         public void Exec()\r
31         {\r
32             Random rnd = new Random();\r
33             gdi.BeginDraw();\r
34             for (int j = 0; j < this.loopCount; j++)\r
35             {\r
36                 Color fore = colors[rnd.Next(colors.Count - 1)];\r
37                 Rectangle rect = new Rectangle();\r
38                 rect.X = rnd.Next(ClientSize.Width);\r
39                 rect.Y = rnd.Next(ClientSize.Height);\r
40                 rect.Width = bmpSize.Width;\r
41                 rect.Height = bmpSize.Height;\r
42                 gdi.FillRectangle(rect, fore);\r
43             }\r
44             gdi.EndDraw();\r
45         }\r
46 \r
47         public void Dispose()\r
48         {\r
49             colors.Clear();\r
50             gdi.Dispose();\r
51         }\r
52     }\r
53 }\r