在C#winform中,在一张图片上 根据数据库里面的 X值和Y值 在图片上面画点并且连成直线, 有20个点左右
解决方案 »
- 查询一个字段内多个值
- 一个程序启动的问题
- C# winfrom datagridview 的两个简单问题
- 算法问题 求教 计算某个文件夹内所有文件中包含某个关键词个数效率问题
- 如何在Winform程序里建数据库中的临时表?
- visual studio安装部署中文件的拷贝与权限配置
- C#操作word的问题,求救了,送80分,祝助我的兄弟们新年大发!
- 获取图片的问题
- 如何在TextBox中的光标指定位置插入一段文字?
- ComboBox一个简单问题
- WPF richtextbox中如何修改追加文字的字体颜色
- C#将Dataset中的数据导出到excel保存时出异常:HRESULT:0x800A03EC
gr.DrawXXX
g.DrawLine(new Pen(颜色值), 第一个点X, 第一个点Y, 第二个点X, 第二个点Y);
……
画点,你可以画一个直径很小的圆圆心是这个点的位置.
画直线.就是graphics.drawline啊..
经常这样画..
{
int height = 400, width = 600;
System.Drawing.Bitmap image = new System.Drawing.Bitmap(height, width);
Graphics g = Graphics.FromImage(image);//创建一个对象 Font font = new System.Drawing.Font("Arial", 9, FontStyle.Regular);
g.Clear(Color.White); System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, image.Width, image.Height), Color.Blue, Color.Blue, 1.2f, true);
g.FillRectangle(Brushes.WhiteSmoke, 0, 0, width, height); Brush brush1 = new SolidBrush(Color.Blue);
g.DrawRectangle(new Pen(Color.Blue), 0, 0, image.Width - 4, image.Height - 4);
Pen mypen = new Pen(brush, 1); int x = 100;
for (int i = 0; i < 11; i++)
{
g.DrawLine(mypen, x, 80, x, 340);
x = x + 40;
}
Pen mypen1 = new Pen(Color.Blue, 2);
g.DrawLine(mypen1, x - 480, 80, x - 480, 340);
int y = 106;
for (int i = 0; i < 9; i++)
{
g.DrawLine(mypen, 60, y, 540, y);
y = y + 26;
}
g.DrawLine(mypen1, 60, y, 540, y); //x
String[] month = {" 一月", " 二月", " 三月", " 四月", " 五月", " 六月", " 七月",
" 八月", " 九月", " 十月", "十一月", "十二月"};
x = 62;
for (int i = 0; i < 12; i++)
{
g.DrawString(month[i].ToString(), font, Brushes.Green, x, 348);
x = x + 40;
} //y
String[] m = {"100%", " 90%", " 80%", " 70%", " 60%", " 50%", " 40%", " 30%",
" 20%", " 10%", " 0%"};
y = 85;
for (int i = 0; i < 11; i++)
{
g.DrawString(m[i].ToString(), font, Brushes.Green, 25, y);
y = y + 26;
} //实际的数据可以从数据库读取出来保存在一个数组里面即可。
int[] Count = new int[12]; Count[0] = 50;
Count[1] = 100;
Count[2] = 200;
Count[3] = 120;
Count[4] = 90;
Count[5] = 400;
Count[6] = 160;
Count[7] = 420;
Count[8] = 300;
Count[9] = 280;
Count[10] = 350;
Count[11] = 15; x = 70;
for (int i = 0; i < 12; i++)
{
SolidBrush mybrush = new SolidBrush(Color.Red);
g.FillRectangle(mybrush, x, 339 - Count[i] * 5 / 10, 20, Count[i] * 5 / 10);
x = x + 40;
} //将图片设置为Panel的背景颜色,然后呈现出来。
this.panel1.BackgroundImage = image;
}
g.drawLine(new pen(color.black,2),point1,point2)。这样重复N次把要连接的点依次画出来就可以了。不过如果你想要的结果是
将这些点连接成为封闭的图形的画。还可以用这个画图函数:g.drawlines()、它会将你传入的点的数组按点顺序画成封闭的图形。具体细节就点击g右键 goto defination,看它们的具体用法吧!或者F1查找Graphic
此消息通过 【CSDN论坛 Winform正式版】 回复!有关此工具