/// <summary> /// 设备数据回调 /// </summary> /// <param name="infos">设备数据</param> private void Instance_OnReadCompleted(DeviceInfo infos) { Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, (Action)(() => { LabTemValue.Content = infos.TemValue; LabHumiValue.Content = infos.HumiValue; LabLightValue.Content = infos.LightValue; CheckBoxFanStatus.IsChecked = infos.IsFanOpen; CheckBoxHeaterStatus.IsChecked = infos.IsHeaterOpen; if (infos.IsFanOpen) { FanAnimation.Start(); } else { FanAnimation.Stop(); } if (infos.IsHeaterOpen) { HeaterAnimation.Start(); } else { HeaterAnimation.Stop(); } })); }
private void Page_Unloaded(object sender, RoutedEventArgs e) { DeviceHelper.Instance.OnReadCompleted -= Instance_OnReadCompleted; FanAnimation.Stop(); HeaterAnimation.Stop(); }