说明:请忽略label标签!
开发功能思路:根据数据库传来的考核数据对每个人的成绩进行单独显示,同时通过比率的方式传给技能框图。
开发步骤:
1.设计五星图,主要外框部分是通过直线绘制,内部是通过射线绘制;
参考代码:
Bitmap bt = new Bitmap(groupBox2.Width, groupBox2.Height); //实例化一个Bitmap对象
g = Graphics.FromImage(bt); //实例化Graphics对象
Pen p1 = new Pen(Color.Red, 1); //设置Pen对象用来绘画X轴
Pen p2 = new Pen(Color.LightSkyBlue, 1); //设置Pen对象用来绘画X轴
g.DrawLine(p2, new Point(groupBox2.Width/2, 50), new Point(groupBox2.Width / 2+100, 125));
g.DrawLine(p2, new Point(groupBox2.Width / 2, 50), new Point(groupBox2.Width / 2 - 100, 125));
g.DrawLine(p2, new Point(groupBox2.Width / 2-100, 125), new Point(groupBox2.Width / 2 -70 , 250));
g.DrawLine(p2, new Point(groupBox2.Width / 2 +100, 125), new Point(groupBox2.Width / 2 +70, 250));
g.DrawLine(p2, new Point(groupBox2.Width / 2 - 70, 250), new Point(groupBox2.Width / 2 + 70, 250));
// 绘制连接线
g.DrawLine(p2, new Point(groupBox2.Width / 2, 155), new Point(groupBox2.Width / 2, 50));
g.DrawLine(p2, new Point(groupBox2.Width / 2 ,155), new Point(groupBox2.Width / 2 + 100, 125));
g.DrawLine(p2, new Point(groupBox2.Width / 2, 155), new Point(groupBox2.Width / 2 - 100, 125));
g.DrawLine(p2, new Point(groupBox2.Width / 2, 155), new Point(groupBox2.Width / 2 - 70, 250));
g.DrawLine(p2, new Point(groupBox2.Width / 2, 155), new Point(groupBox2.Width / 2 + 70, 250));
groupBox2.BackgroundImage = bt;
关于函数内部的数据,请按照标准定义编写;
2.绘制五星实图,通过函数g.FillPolygon( );进行绘制,内部只需要传入参数即可;
参考代码:
Point point1 = new Point(groupBox2.Width / 2, 60);
Point point2 = new Point(groupBox2.Width / 2 - 100, 125);
Point point3 = new Point(groupBox2.Width / 2 + 100, 125);
Point point4 = new Point(groupBox2.Width / 2 - 70, 250);
Point point5 = new Point(groupBox2.Width / 2 + 70, 250);
Point[] pntArr = { point1, point2, point4, point5, point3 };
g.FillPolygon(Brushes.Honeydew, pntArr);
请注意,此步骤需要内部逻辑判断进行测试;
以上!
Copyright [2019/8/13] by [Masir]
知识星球