用于Windows Mobile平台图形开发包
.Net Framework提供了 System.Drawing ,System.Drawing.Drawing2D 用于二维图形开发,但有相当一部分没有在 Windows Compact Framework 得到支持。如 Pen的 .LineJoin .LineCap 已及 各种二维图形类。如 Arc, Area, Polyline, Polygon, Path.
这里提供一个免费的 用于Windows Mobile平台图形开发包。基本提供了 Desktop 平台 System.Drawing.Drawing2D 功能。
下面是一个简单的实例,用各种几何图形拼出一个Pear.(来源于经典Java示例),其他例子 Colors, Polys, Pahts, LineJoin,LineCap 见附件 Ellipse circle, oval, leaf, stem;
Area circ, ov, leaf1, leaf2, st1, st2;
circle = new Ellipse();
oval = new Ellipse();
leaf = new Ellipse();
stem = new Ellipse();
circ = new Area(circle);
ov = new Area(oval);
leaf1 = new Area(leaf);
leaf2 = new Area(leaf);
st1 = new Area(stem);
st2 = new Area(stem);
graphics2D.Reset();
graphics2D.Clear(Color.White);
int w = screenWidth;
int h = screenHeight;
int ew = w / 2;
int eh = h / 2;
SolidBrush brush = new SolidBrush(Color.Green);
graphics2D.DefaultBrush = brush;
// Creates the first leaf by filling the intersection of two Area
//objects created from an ellipse.
leaf.SetFrame(ew - 16, eh - 29, 15, 15);
leaf1 = new Area(leaf);
leaf.SetFrame(ew - 14, eh - 47, 30, 30);
leaf2 = new Area(leaf);
leaf1.Intersect(leaf2);
graphics2D.Fill(null, leaf1);
// Creates the second leaf.
leaf.SetFrame(ew + 1, eh - 29, 15, 15);
leaf1 = new Area(leaf);
leaf2.Intersect(leaf1);
graphics2D.Fill(null, leaf2);
brush = new SolidBrush(Color.Black);
graphics2D.DefaultBrush = brush;
// Creates the stem by filling the Area resulting from the
//subtraction of two Area objects created from an ellipse.
stem.SetFrame(ew, eh - 42, 40, 40);
st1 = new Area(stem);
stem.SetFrame(ew + 3, eh - 47, 50, 50);
st2 = new Area(stem);
st1.Subtract(st2);
graphics2D.Fill(null, st1);
brush = new SolidBrush(Color.Yellow);
graphics2D.DefaultBrush = brush;
// Creates the pear itself by filling the Area resulting from the
//union of two Area objects created by two different ellipses.
circle.SetFrame(ew - 25, eh, 50, 50);
oval.SetFrame(ew - 19, eh - 20, 40, 70);
circ = new Area(circle);
ov = new Area(oval);
circ.Add(ov);
graphics2D.Fill(null, circ);
Invalidate();
页:
[1]