| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using SWRIS.Controls;
- using SWRIS.Extensions;
- using SWRIS.Models;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Windows;
- using System.Windows.Controls;
- namespace SWRIS.Pages.RealTime
- {
- /// <summary>
- /// TwoRopesPage.xaml 的交互逻辑
- /// </summary>
- public partial class TwoRopesControl : UserControl
- {
- public static readonly DependencyProperty EquipmentsProperty =
- DependencyProperty.Register("Equipments", typeof(ObservableCollection<EquipmentDataModel>),
- typeof(TwoRopesControl),
- new PropertyMetadata(null));
- public ObservableCollection<EquipmentDataModel> Equipments
- {
- get { return (ObservableCollection<EquipmentDataModel>)GetValue(EquipmentsProperty); }
- set { SetValue(EquipmentsProperty, value); }
- }
- public TwoRopesControl()
- {
- InitializeComponent();
- DataContext = this;
- }
- private void EquipmentAlarm_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
- {
- if ((sender as TextBlock)?.DataContext is EquipmentDataModel equipmentData)
- {
- DamagesDialog damagesDialog = new DamagesDialog(equipmentData.Alarms);
- damagesDialog.ShowDialog(true);
- }
- }
- private void ParameterSetting_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
- {
- if ((sender as StackPanel)?.DataContext is EquipmentDataModel equipmentData)
- {
- var equipment = App.Config.Equipments.FirstOrDefault(c => c.RopeNumber == equipmentData.RopeNumber);
- if (equipmentData != null && equipment != null)
- {
- ParameterDialog parameterDialog = new ParameterDialog(equipment, equipmentData.ClientSocket, equipmentData.RunningStatus);
- parameterDialog.ShowDialog(true);
- }
- }
- }
- private void OnCardLoaded(object sender, RoutedEventArgs e)
- {
- var border = sender as Border;
- if (!(border?.DataContext is EquipmentDataModel data)) return;
- if (border.FindName("ChartLine") is RealTimeLineChart chart)
- {
- var chartSource = data.Chart?.GetChartSource();
- if (chart != null && chartSource != null)
- {
- chart.AddDataPoints(chartSource);
- }
- data.Chart = chart;
- }
- }
- }
- }
|