ChangeLog: Updated ChangeLog.
[mono.git] / mcs / class / System.Drawing / Test / System.Drawing / graphicsUi.cs
1 //
2 // Test application for some graphics.cs functions implementation
3 //
4 // Author:
5 //   Jordi Mas i Hernàndez, jordi@ximian.com
6 //
7
8 using System;
9 using System.Drawing.Imaging;
10 using System.Drawing;
11 using System.Drawing.Drawing2D;
12
13 //
14 public class graphicsUI
15 {       
16         
17     public static void Main( ) 
18         {
19
20         Bitmap bmp = new Bitmap(500, 250);
21         Graphics dc = Graphics.FromImage(bmp);
22         
23                 Pen BluePen = new Pen(Color.Blue, 3);
24                 Pen GreenPen = new Pen(Color.Green, 3);
25                 Pen RedPen = new Pen(Color.Red, 3);
26                 SolidBrush redBrush = new SolidBrush(Color.Red);
27                 SolidBrush blueBrush = new SolidBrush(Color.Blue);
28                 
29                 int x=0;
30                 int y=0;
31                 
32                 
33                 /* First Row*/
34                 dc.DrawRectangle(BluePen, x,y,50,50);
35                 x+=50;          
36                 dc.DrawEllipse(RedPen, x, y, 70, 50);                                   
37                 dc.DrawArc (BluePen, x, y, 50, 40, (float)0, (float)120);
38                 x+=70;          
39                                 
40                 dc.DrawBezier (GreenPen, new Point(x, y+5), new Point(x+50, y+5), 
41                         new Point(x+20, y+20), new Point(x+50, y+50));                          
42                         
43                 x+=50;
44         
45                 PointF point1 = new PointF(10.0F+x,  10.0F);
46                 PointF point2 = new PointF(10.0F+x,  5.0F);
47                 PointF point3 = new PointF(40.0F+x,   5.0F);
48                 PointF point4 = new PointF(50.0F+x,  10.0F);
49                 PointF point5 = new PointF(60.0F+x, 20.0F);
50                 PointF point6 = new PointF(70.0F+x, 40.0F);
51                 PointF point7 = new PointF(50.0F+x, 50.0F);
52                 PointF[] curvePoints ={point1,point2,point3, point4,point5,     point6, point7};                
53                 dc.DrawLines(RedPen, curvePoints);              
54                 float tension = 1.0F;
55                 FillMode aFillMode = FillMode.Alternate;                                
56                 dc.DrawClosedCurve(GreenPen, curvePoints, tension, aFillMode);  
57                 
58                 x+=80;
59                                 
60                 // FillClosedCurve
61                 PointF point10 = new PointF(x, y+15.0F);
62                 PointF point20 = new PointF(x+40.0F,  y+10.0F);
63                 PointF point30 = new PointF(x+50.0F, y+40.0F);
64                 PointF point40 = new PointF(x+10.0F, y+30.0F);
65                 PointF[] points = {point10, point20, point30, point40};         
66                 FillMode newFillMode = FillMode.Winding;                                
67                 dc.FillClosedCurve(redBrush, points, newFillMode, tension);
68                                         
69                 // Fill pie to screen.
70                 dc.FillPie(blueBrush, x, 0, 200.0F, 100.0f, 300.0F, 45.0F);
71                 
72                 /* second row*/
73                 y+=80;
74                 x=0;
75                 
76                 // Clipping and Graphics container test
77                 dc.SetClip(new Rectangle(5+x, 5+y, 75, 75));
78                 
79                 // Begin a graphics container.
80                 GraphicsContainer container = dc.BeginContainer();
81                 
82                 // Set an additional clipping region for the container.
83                 dc.SetClip(new Rectangle(50+x, 25+y, 50, 37));
84                 
85                 // Fill a red rectangle in the container.               
86                 dc.FillRectangle(redBrush, 0, 0, 200, 200);
87                 
88                 dc.EndContainer(container);
89                 SolidBrush blueBrushLight = new  SolidBrush(Color.FromArgb(128, 0, 0, 255));
90                 dc.FillRectangle(blueBrushLight, 0, 0, 200, 200);
91                 
92                 dc.ResetClip();
93                 Pen blackPen = new Pen(Color.FromArgb(255, 0, 0, 0), 2.0f);
94                 dc.DrawRectangle(blackPen, 5+x, 5+y, 75, 75);
95                 dc.DrawRectangle(blackPen, 50+x, 25+y, 50, 37);
96                 
97                 x=100;
98                 y+=10;          
99                 
100
101                 Point[] ptstrans = {new Point(x, y),    new Point(50+x, 25+y)};         
102                 dc.DrawLine(BluePen,    ptstrans[0],    ptstrans[1]);           
103                 dc.TranslateTransform(40.0F, 30.0F);            
104                 dc.TransformPoints(CoordinateSpace.Page,CoordinateSpace.World,ptstrans);                
105                 dc.ResetTransform();            
106                 dc.DrawLine(RedPen,     ptstrans[0], ptstrans[1]);
107
108         bmp.Save("graphicsui.bmp", ImageFormat.Bmp);            
109                 
110         }
111         
112
113 }
114
115