紧急:C#中如何画 坐标轴,坐标网格????

zhangjingyi1581101 2011-08-30 01:55:40
请问:
我在C#画曲线时遇到了一些问题,请大家指教: 在WinForm的Panel上
1.如何显示坐标轴?
2.如何显示坐标网格?
是不是坐标轴和坐标网格都用画线段的办法画上去,Graphics本身有比较简捷的办法么?
3.如何实现鼠标点到图像上,动态的显示图像中的坐标?
速求帮助,谢谢!!!
...全文
905 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
chp845 2011-08-30
  • 打赏
  • 举报
回复
使用双缓冲去DrawString,DrawLine就可以了呀!
  • 打赏
  • 举报
回复
http://blog.csdn.net/yunhaic/article/details/4496599
当年我画的,程序没问题,你可以复制了用
zhangjingyi1581101 2011-08-30
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 anchenyanyue 的回复:]
C# code

public void CreatETFPriceFrame(string[] x, int width, int height, Graphics graphics)
{
graphics.Clear(Color.White);
Font font = new Font("Arial", 9, FontS……
[/Quote]

这个方法调用后,是把它画在那里了?只画了网格,但是怎么没有显示呢?
萧炎 2011-08-30
  • 打赏
  • 举报
回复
如果是相对屏幕坐标,可以调用系统API函数获取
[DllImport("User32.dll")]
public static extern bool GetCursorPos (ref Point NewPoint);

如果是相对picturebox坐标,可是使用mousemove事件,然后在事件里调用e.x,e.y就能获取到坐标位置了
bdmh 2011-08-30
  • 打赏
  • 举报
回复
有什么好求的,自己根据长宽和具体值算一个坐标出来,画就是了
暗尘掩月 2011-08-30
  • 打赏
  • 举报
回复
public void CreatETFPriceFrame(string[] x, int width, int height, Graphics graphics)
{
graphics.Clear(Color.White);
Font font = new Font("Arial", 9, FontStyle.Regular);
LinearGradientBrush lgBrush = new LinearGradientBrush(new Rectangle(0, 0, width, height), Color.Blue, Color.Blue, 1.2f, true);
Pen framePen = new Pen(Color.Blue, 1);
Pen buildPen = new Pen(lgBrush, 1);
int leftX = 60; //最左边的纵线距离图像左边的距离
// 画纵线
for (int i = 0; i < 9; i++)
{
graphics.DrawLine(buildPen, leftX, 50, leftX, height - 32);
leftX += (width - 60 - 50) / 8;
}
//graphics.DrawLine(framePen, width - 50, 50, width - 50, height - 100); //最右边的纵线

int topY = 50; //最上边的横线距离图像顶部的距离
// 画横线
for (int i = 0; i < 8; i++)
{
graphics.DrawLine(buildPen, 60, topY, width - 56, topY);
topY += (height - 50 - 30) / 8;
}
graphics.DrawLine(framePen, 60, topY, width - 56, topY); //最底下的横线

leftX = 35; //最左边文字距离图像左边的距离
// 设置X轴文字内容及输出位置
for (int i = 0; i < x.Length; i++)
{
graphics.DrawString(x[i].ToString(), font, Brushes.Red, leftX, height - 24);
leftX += (width - 60 - 50) / 8;
}
}

ken_flash 2011-08-30
  • 打赏
  • 举报
回复
顶楼上,只能自己一点点计算,完了再DrawString,DrawLine等
wxg_sdwl 2011-08-30
  • 打赏
  • 举报
回复
Bitmap img = new Bitmap(740, 480);
Graphics g = Graphics.FromImage(img);
//定义银灰色画笔
Pen Sp = new Pen(Color.Silver);
//定义大点的字体
Font Tfont = new Font("Arial", 9);
//定义黑色过渡型笔刷
LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, img.Width, img.Height), Color.Black, Color.Black, 1.2F, true);
//画线
g.DrawLine(Sp, 40, 40, 40, 380);
//写字
g.DrawString("写字", Tfont, brush, 10, 15);

img.Save(strpath, ImageFormat.Jpeg);
img.Dispose();
g.Dispose();
zhangjingyi1581101 2011-08-30
  • 打赏
  • 举报
回复
求代码!!

111,093

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧