我正在尝试创建一个使用水平滚动条作为时间控件的 windows.form。然后将时间值用作 85 个数组的数组索引,每个数组值(不为零)包含一个方位,然后在地图上显示为一条线。我遇到的问题是我对 C# 和事件处理很陌生,所以我找不到将 hScrollBar1_Scroll 的事件(和值)链接到 PaintEventArgs 循环的方法。以下是我尝试过的代码示例:
private void hScrollBar1_Scroll(object sender, ScrollEventArgs e, [PaintEventArgs f])
int t = e.NewValue;
//There's a few lines of code here that convert the value of the scrollbar to time and
//display it in a box.
{
for (int s = 1; s <= 85; s++)
{
if (ldata[s, t, 0] != 0)
{
DrawLinesPoint(s, t, null);
}
}
DrawLinesPoint() 处于循环中的原因是因为有 85 个站点可以同时显示方位。
起初我尝试使用“PaintEventArgs f”作为“ScrolleventArgs e”旁边的参数,但不知道如何处理该事件,因此 DrawlinesPoint() 使用“null”而不是“f”。
public void DrawLinesPoint(int s, int t, PaintEventArgs e)
{
Graphics g = e.Graphics;
int c = rdata[s,0];
Pen pen;
switch (c)
{
...
//These bearings can be three different colours
}
int x1 = rdata[s,1];
int y1 = rdata[s,2];
int x2 = rdata[s,1] + ldata[s,t,0];
int y2 = rdata[s,2] + ldata[s,t,1];
g.DrawLine(pen, x1, y1, x2, y2);
}
数组 rdata[] 是 2 维的,包含站点的参考数据,而 ldata[] 是 3 维的,包含导入的轴承数据。
每次通过滚动条更改时间时,必须清除地图并更改显示的方位。
任何人都可以帮助使用此代码吗?我很有可能完全以错误的方式做这件事,所以任何帮助都将不胜感激。