OSDN Git Service

61362c2fea6126ae3293e20fc69c765a1db3e920
[d2dbench/d2dbench.git] / D2DBench / Method5.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 Method5 : IBench\r
9     {\r
10         public int fillAreaSize { get { return 0; } }\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 \r
20         public void Init(Control ctrl, bool antialias)\r
21         {\r
22             ClientSize = ctrl.ClientSize;\r
23             gdi = new GDI(ctrl);\r
24             colors = new ColorTableGDI();\r
25             font = ctrl.Font;\r
26             ctrl.Show();\r
27         }\r
28 \r
29         public void Exec()\r
30         {\r
31             Random rnd = new Random();\r
32             gdi.BeginDraw();\r
33             for (int j = 0; j < this.loopCount; j++)\r
34             {\r
35                 Color c = colors[rnd.Next(colors.Count - 1)];\r
36                 gdi.DrawString(font, showStr, c, rnd.Next(ClientSize.Width), rnd.Next(ClientSize.Height));\r
37             }\r
38             gdi.EndDraw();\r
39         }\r
40 \r
41         public void Dispose()\r
42         {\r
43             colors.Clear();\r
44             gdi.Dispose();\r
45         }\r
46     }\r
47 }\r