当前位置:编程学习 > C#/ASP.NET >>

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

请问:
我在C#画曲线时遇到了一些问题,请大家指教: 在WinForm的Panel上
1.如何显示坐标轴?
2.如何显示坐标网格?
是不是坐标轴和坐标网格都用画线段的办法画上去,Graphics本身有比较简捷的办法么?
3.如何实现鼠标点到图像上,动态的显示图像中的坐标?
速求帮助,谢谢!!! --------------------编程问答-------------------- 求代码!! --------------------编程问答-------------------- 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();       --------------------编程问答-------------------- 顶楼上,只能自己一点点计算,完了再DrawString,DrawLine等 --------------------编程问答--------------------
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;
            }
}

--------------------编程问答-------------------- 有什么好求的,自己根据长宽和具体值算一个坐标出来,画就是了 --------------------编程问答-------------------- 如果是相对屏幕坐标,可以调用系统API函数获取
        [DllImport("User32.dll")]
        public static extern bool GetCursorPos (ref  Point  NewPoint);

如果是相对picturebox坐标,可是使用mousemove事件,然后在事件里调用e.x,e.y就能获取到坐标位置了 --------------------编程问答--------------------
引用 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……


这个方法调用后,是把它画在那里了?只画了网格,但是怎么没有显示呢? --------------------编程问答-------------------- http://blog.csdn.net/yunhaic/article/details/4496599
当年我画的,程序没问题,你可以复制了用 --------------------编程问答-------------------- 使用双缓冲去DrawString,DrawLine就可以了呀!
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,