需求:TEECHART 控件每 100ms 繪製雷達目標新位置(紅色),歷史位置保留並轉其他顏色,形成移動軌跡。
private void timer_Tick(object sender, EventArgs e) {
// 1. 從網路接收緩衝區取最新目標座標
// 2. 更新各目標的當前點 Series[0]
// 3. 將舊當前點加入歷史 Series[1]
// 4. 修剪歷史點數(如保留最近 200 點)
// 5. chart.Invalidate() 觸發重繪
}
歷史點按時間漸變:最新歷史點亮色,最舊暗色,視覺化速度/方向感。
for (int i = 0; i < history.Count; i++) {
float ratio = (float)i / history.Count;
Color c = Color.FromArgb(255, (int)(255*ratio), 0, (int)(255*(1-ratio)));
historySeries.Points[i].Color = c;
}
網路接收在背景執行緒,將解析後的目標座標放入 `ConcurrentQueue
總結:思路正確,**關鍵在「系列分離、雙緩衝防閃、背景執行緒解耦接收」**,TEECHART 足以勝任百點級即時軌跡顯示。