| | |
| | | using HMI.Core.Api; |
| | | using HMI.Core.Entity; |
| | | using HMI.Core.Manager; |
| | | using HMI.Core.Util; |
| | | using HMI.Core.Util; |
| | | using HMI.UI.Util; |
| | | using Panuon.WPF.UI; |
| | | using Plugin.TestResult_WPF.Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Collections.ObjectModel; |
| | | using System.Linq; |
| | | using System.Windows; |
| | | using System.Windows.Controls; |
| | | |
| | |
| | | get => _dataSource == null ? new ObservableCollection<Info>() : _dataSource; |
| | | set => Set(ref _dataSource, value); |
| | | } |
| | | private Chart electricChart; |
| | | private Chart vChart; |
| | | public InfoWindow(string title, ObservableCollection<Info> infos, Chart electricChart, Chart vChart, int probeCount) |
| | | private LiveChart waterChart; |
| | | private LiveChart electricChart; |
| | | private LiveChart vChart; |
| | | |
| | | //public InfoWindow(string title, ObservableCollection<Info> infos, Chart waterChart, Chart electricChart, Chart vChart, int probeCount, int probeWarn) |
| | | //{ |
| | | // this.title = title; |
| | | // this.dataSource = infos; |
| | | // DataContext = this; |
| | | // Topmost = false; |
| | | // this.ProbeWarn = probeWarn; |
| | | // InitializeComponent(); |
| | | |
| | | |
| | | // UpdateProbeCount(probeCount,probeWarn); |
| | | |
| | | // if (waterChart != null) |
| | | // { |
| | | // this.waterChart = waterChart; |
| | | // mainGrid.Children.Add(waterChart); |
| | | // Grid.SetRow(waterChart, 1); |
| | | // } |
| | | |
| | | // this.electricChart = electricChart; |
| | | // mainGrid.Children.Add(electricChart); |
| | | // Grid.SetRow(electricChart, 2); |
| | | |
| | | |
| | | // this.vChart = vChart; |
| | | // mainGrid.Children.Add(vChart); |
| | | // Grid.SetRow(vChart, 3); |
| | | //} |
| | | |
| | | public InfoWindow(string title, ObservableCollection<Info> infos, LiveChart[] charts, int probeCount, int probeWarn) |
| | | { |
| | | this.title = title; |
| | | this.dataSource = infos; |
| | | DataContext = this; |
| | | Topmost = false; |
| | | this.ProbeWarn = probeWarn; |
| | | InitializeComponent(); |
| | | |
| | | if (AlarmProbeCount < 0) |
| | | |
| | | UpdateProbeCount(probeCount, probeWarn); |
| | | int row = 1; |
| | | foreach (var chart in charts) |
| | | { |
| | | alarmLabel.Visibility = Visibility.Collapsed; |
| | | alarmValue.Visibility = Visibility.Collapsed; |
| | | } |
| | | UpdateProbeCount(probeCount); |
| | | |
| | | this.electricChart = electricChart; |
| | | mainGrid.Children.Add(electricChart); |
| | | Grid.SetRow(electricChart, 1); |
| | | |
| | | this.vChart = vChart; |
| | | mainGrid.Children.Add(vChart); |
| | | Grid.SetRow(vChart, 2); |
| | | if (chart == null) return; |
| | | mainGrid.Children.Add(chart); |
| | | Grid.SetRow(chart, row++); |
| | | } |
| | | |
| | | private static int AlarmProbeCount; |
| | | static InfoWindow() |
| | | { |
| | | int probeWarn = -1; |
| | | try |
| | | { |
| | | probeWarn = Convert.ToInt32(ParameterManager.GetCommonParameter<List<ParameterData>>() |
| | | .FirstOrDefault(x => x.Name == "ProbeWarn")?.Value); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | probeWarn = -1; |
| | | } |
| | | AlarmProbeCount = probeWarn; |
| | | //if (waterChart != null) |
| | | //{ |
| | | // this.waterChart = waterChart; |
| | | // mainGrid.Children.Add(waterChart); |
| | | // Grid.SetRow(waterChart, 1); |
| | | //} |
| | | |
| | | //this.electricChart = electricChart; |
| | | //mainGrid.Children.Add(electricChart); |
| | | //Grid.SetRow(electricChart, 2); |
| | | |
| | | //this.vChart = vChart; |
| | | //mainGrid.Children.Add(vChart); |
| | | //Grid.SetRow(vChart, 3); |
| | | } |
| | | |
| | | public event EventHandler ClearProbeCountEvent; |
| | |
| | | |
| | | public int ProbeWarn |
| | | { |
| | | get => AlarmProbeCount; |
| | | set { } |
| | | get; |
| | | set; |
| | | } |
| | | public void UpdateProbeCount(int count) |
| | | |
| | | public void UpdateProbeCount(int count, int warn) |
| | | { |
| | | Dispatcher.Invoke(() => |
| | | { |
| | | ProbeCount = count; |
| | | if (AlarmProbeCount >= 0) |
| | | ProbeWarn = warn; |
| | | |
| | | if (ProbeWarn < 0) |
| | | { |
| | | probeCountAlarm.Visibility = (ProbeCount >= AlarmProbeCount) ? Visibility.Visible : Visibility.Collapsed; |
| | | alarmLabel.Visibility = Visibility.Collapsed; |
| | | alarmValue.Visibility = Visibility.Collapsed; |
| | | } |
| | | else |
| | | { |
| | | probeCountAlarm.Visibility = (ProbeCount >= ProbeWarn) ? Visibility.Visible : Visibility.Collapsed; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | public void UpdateSource(ObservableCollection<Info> infos) |
| | | { |
| | |
| | | |
| | | protected override void OnClosed(EventArgs e) |
| | | { |
| | | waterChart = null; |
| | | electricChart = null; |
| | | vChart = null; |
| | | mainGrid.Children.Clear(); |
| | |
| | | |
| | | private void Button_Click(object sender, RoutedEventArgs e) |
| | | { |
| | | if (MsgBoxHelper.WarnMessage(this, "确定要清空探针使用次数吗?") == MessageBoxResult.OK) |
| | | if (MsgBoxHelper.WarnMessage(this, this.lang("Ts.MakeSureToClearProbeCount")) == MessageBoxResult.OK) |
| | | { |
| | | ClearProbeCountEvent?.Invoke(this, null); |
| | | } |