接着基本代码为:
publicclassProgram : Microsoft.SPOT.Application { |
publicstaticvoid Main() |
{ |
//创建窗体 |
WindowsDrawing win = newWindowsDrawing(); |
win.Height = SystemMetrics.ScreenHeight; |
win.Width = SystemMetrics.ScreenWidth; |
//运行 |
newProgram().Run(win); |
} |
//派生一个类并重载 |
internalsealedclassWindowsDrawing: Window |
{ |
publicoverridevoid OnRender(DrawingContext dc) |
{ |
Color c = ColorUtility.ColorFromRGB(125, 0, 255); |
Brush b = newSolidColorBrush(c); |
Pen p = newPen(c); |
//设背景为矩形 |
dc.DrawRectangle(b, p, 0, 0, Width, Height); |
//画椭圆形 |
p=newPen(Color.Black); |
b = newSolidColorBrush(Color.White); |
dc.DrawEllipse(b, p, 55,25, 55,25); |
//画线 |
p = newPen(ColorUtility.ColorFromRGB(255, 0,0),5); |
dc.DrawLine(p, 55, 25, 100,80); |
//多边行 |
int[] points = { 10, 220, 50, 200, 0, 170, 50, 120, 80, 110, 90, 100, 55, 200, 60, 220 }; |
b = newSolidColorBrush(Color.White); |
p = newPen(ColorUtility.ColorFromRGB(0, 255,0),3); |
dc.DrawPolygon(b,p, points); |
//文字 |
c= ColorUtility.ColorFromRGB(0, 255, 255); |
dc.DrawText("http://..", Resources.GetFont(Resources.FontResources.small), c, 180, 20); |
//位图 (支持bmp,gif,jpg等格式) |
dc.DrawImage(Resources.GetBitmap( Resources.BitmapResources.SMVP),230,130); |
} |
} |
} |