using System; using System.Windows; using System.Windows.Controls; namespace PLCDataMonitor { public partial class HomePage : UserControl { // 定义事件用于与主窗口通信 public event EventHandler ConnectButtonClicked; public HomePage() { InitializeComponent(); } // 定义暂停/继续事件 public event EventHandler PauseRequested; public event EventHandler ResumeRequested; private void PauseButton_Click(object sender, RoutedEventArgs e) { PauseRequested?.Invoke(this, EventArgs.Empty); } private void ResumeButton_Click(object sender, RoutedEventArgs e) { ResumeRequested?.Invoke(this, EventArgs.Empty); } public void UpdateAlarms(string alarmMessage) { Dispatcher.Invoke(() => AlarmTextBlock.Text = alarmMessage); } // 更新数据显示 public void UpdateData(string pressure1, string pressure2, string friction1, string friction2, int count1, int count2, string t1, string t2, string Distince) { TbStation1Pressure.Text = pressure1; TbStation2Pressure.Text = pressure2; TbFriction1.Text = friction1; TbFriction2.Text = friction2; txtcount1.Text = count1.ToString(); txtcount2.Text = count2.ToString(); txtT1.Text = t1; txtT2.Text = t2; txtDistince.Text = Distince; } } }