积极答复者
WInform画图

问题
答案
-
Hi,
这是使用GDI+直接在窗体上画出来的,不是图片,没有办法通过鼠标来直接缩放和移动。
如果你想实现通过鼠标来缩放和移动,我建议你使用chart控件。
或者使用截图,把这块区域截下来,然后使用picturebox进行缩放处理。
Best Regards,
Bob
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
全部回复
-
Hi,
参考:
public partial class 振荡 : Form { public 振荡() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Graphics g = this.CreateGraphics(); g.DrawLines(new Pen(Color.Red), createData(100, 500,5)); g.DrawLines(new Pen(Color.Red), createData(200, 500, 5)); g.DrawLines(new Pen(Color.Red), createData(300, 500, 5)); Application.DoEvents(); } /// <summary> /// 模拟数据 /// </summary> /// <param name="baseValue">基线</param> /// <param name="count">点的数量</param> /// <param name="Oscillationfrequency">振荡频率</param> /// <returns></returns> private Point[] createData(int baseValue, int count,int Oscillationfrequency) { Point[] dataPoints = new Point[count]; Random ran = new Random(); for (int i = 0; i < count; i++) { dataPoints[i] = new Point(i, baseValue + ran.Next(-Oscillationfrequency, Oscillationfrequency)); } return dataPoints; } }
希望有帮助。
Best Regards,
Bob
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com. -
Hi,
这是使用GDI+直接在窗体上画出来的,不是图片,没有办法通过鼠标来直接缩放和移动。
如果你想实现通过鼠标来缩放和移动,我建议你使用chart控件。
或者使用截图,把这块区域截下来,然后使用picturebox进行缩放处理。
Best Regards,
Bob
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com. -
HI,
>> 请问能通过按钮放大和缩小吗?
直接画在Bitmap上,然后再对bitmap进行缩放。
private void drawData(int width, int height) { Bitmap BM = new Bitmap(width,height); Graphics g = Graphics.FromImage(BM); g.DrawImage(BM, BM.Width, BM.Height); g.DrawLines(new Pen(Color.Red), createData(100, 500, 5)); g.DrawLines(new Pen(Color.Red), createData(200, 500, 5)); g.DrawLines(new Pen(Color.Red), createData(300, 500, 5)); pictureBox2.Image = BM; Application.DoEvents(); g.Dispose(); }
>>还有最下面x轴能显示个数字吗?
使用DrawString()画。
Graphics.DrawString(“... ”,new Font("宋体", 8), new SolidBrush(Color.Black), x, y);
Best Regards,
Bob
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com. -
Hi,
参考:
public partial class 振荡 : Form { public 振荡() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Graphics g = this.CreateGraphics(); g.DrawLines(new Pen(Color.Red), createData(100, 500,5)); g.DrawLines(new Pen(Color.Red), createData(200, 500, 5)); g.DrawLines(new Pen(Color.Red), createData(300, 500, 5)); Application.DoEvents(); } /// <summary> /// 模拟数据 /// </summary> /// <param name="baseValue">基线</param> /// <param name="count">点的数量</param> /// <param name="Oscillationfrequency">振荡频率</param> /// <returns></returns> private Point[] createData(int baseValue, int count,int Oscillationfrequency) { Point[] dataPoints = new Point[count]; Random ran = new Random(); for (int i = 0; i < count; i++) { dataPoints[i] = new Point(i, baseValue + ran.Next(-Oscillationfrequency, Oscillationfrequency)); } return dataPoints; } }
希望有帮助。
Best Regards,
Bob
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.请问
g.DrawLines 这个怎么知道一屏幕能画多少那?即
Point[] dataPoints = new Point[count];
x值一屏幕最大是多少那?
please verify my account