c# - 使用按钮单击 C# 表单暂停和恢复图表和文本框的更新
问题描述
因此,当我单击按钮时,希望能够暂停和恢复图表和文本框的更新。目前,它只是实时更新。我在下面附上了我的代码,我尝试过 ResumeUpdates() 和 PauseUpdates() 用于图表,但它不适用于我不知道的文本框。我获取的数据存储在 ArrayList 中,最初来自串行端口
编辑:如果我在 mmy 按钮函数中有 initraph() 并从那里调用它,它会调用它一次并更新一次。
第一个按钮单击=图表和文本框实时更新
第二个按钮单击 = 图表和文本框暂停
第三个按钮单击 = 图表和文本框继续更新
private void InitChart()
{
if (!b)
{
speedRecordChart.ChartAreas[0].AxisX.Maximum = 200;
speedRecordChart.ChartAreas[0].AxisX.Minimum = 0;
if (position.lat1 > 90)
{
textBox_analLat.Text = position.latComp1 + position.lat1 / 100;
}
else
{
textBox_analLat.Text = position.latComp1 + position.lat1;
}
if (position.lng1 > 180)
{
textBox_analLong.Text = position.lngComp1 + position.lng1 / 100;
}
else
{
textBox_analLong.Text = position.lngComp1 + position.lng1;
}
speedRecordChart.Series["Speed"].Points.Clear();
for (int i = 0; i < totalSpeedList.Count() - 1; ++i)
{
speedRecordChart.Series["Speed"].Points.AddY(totalSpeedList[i]);
}
Console.WriteLine("speedChart : " + totalSpeedList);
}
return;
}
/*****************************************for button**********/
Boolean b = true;
private void button_Resume_Click(object sender, EventArgs e)
{
if (b == true)
{
button_Resume.Text = "resume";
//speedRecordChart.Series.ResumeUpdates();
// serialPort1.Close();
InitChart();
}
else
{
button_Resume.Text = "pause";
// speedRecordChart.Series.SuspendUpdates();
// serialPort1.Open();
}
b = !b;
}
解决方案
推荐阅读
- r - 错误:R中的意外字符串常量“} else {”
- ios - 如何在 Xcode 中列出一个目标的所有文件
- javascript - websocket over spring4 和 spring security SockJS /info?t=
- oracle - 如何检测 ORACLE 数据库中表列中的数据类型(可能是 blob 或 clob)?
- html - 即使在 Bootstrap Grid Columns 丢失的情况下也可以向右拉
- python - 从被测方法中导入的模块中修补方法
- bytecode - 为什么字节码序列号不连续
- c - C 接受关于传递关系的输入
- javascript - 解析etherscan
- java - 如何在没有触摸 xml 的情况下在休眠中处理延迟初始化异常