123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- using System;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using Aitex.Core.Common.DeviceData;
- namespace Aitex.Core.UI.DeviceControl
- {
- /// <summary>
- /// AITPump.xaml 的交互逻辑
- /// </summary>
- public partial class AITPump : UserControl
- {
- public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
- "DeviceData", typeof(AITPumpData), typeof(AITPump),
- new FrameworkPropertyMetadata(new AITPumpData(), FrameworkPropertyMetadataOptions.AffectsRender));
- public AITPumpData DeviceData
- {
- get
- {
- return (AITPumpData)this.GetValue(DeviceDataProperty);
- }
- set
- {
- this.SetValue(DeviceDataProperty, value);
- }
- }
- public static readonly DependencyProperty IsShowSensorProperty = DependencyProperty.Register(
- "IsShowSensor", typeof(bool), typeof(AITPump),
- new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));
- public bool IsShowSensor
- {
- get
- {
- return (bool)this.GetValue(IsShowSensorProperty);
- }
- set
- {
- this.SetValue(IsShowSensorProperty, value);
- }
- }
- public static readonly DependencyProperty WaterFlowStatusColorProperty = DependencyProperty.Register(
- "WaterFlowStatusColor", typeof(SolidColorBrush), typeof(AITPump),
- new FrameworkPropertyMetadata(Brushes.DarkGray, FrameworkPropertyMetadataOptions.AffectsRender));
- public SolidColorBrush WaterFlowStatusColor
- {
- get
- {
- return (SolidColorBrush)this.GetValue(WaterFlowStatusColorProperty);
- }
- set
- {
- this.SetValue(WaterFlowStatusColorProperty, value);
- }
- }
- public static readonly DependencyProperty N2PressureStatusColorProperty = DependencyProperty.Register(
- "N2PressureStatusColor", typeof(SolidColorBrush), typeof(AITPump),
- new FrameworkPropertyMetadata(Brushes.DarkGray, FrameworkPropertyMetadataOptions.AffectsRender));
- public SolidColorBrush N2PressureStatusColor
- {
- get
- {
- return (SolidColorBrush)this.GetValue(N2PressureStatusColorProperty);
- }
- set
- {
- this.SetValue(N2PressureStatusColorProperty, value);
- }
- }
- public AITPump()
- {
- InitializeComponent();
- }
- protected override void OnRender(DrawingContext drawingContext)
- {
- base.OnRender(drawingContext);
- if (DeviceData == null)
- return;
- if (DeviceData.IsError)
- imagePicture.Source = new BitmapImage(new Uri("pack://application:,,,/Core;component/Resources/Pump/pump_error.png"));
- else if (DeviceData.IsWarning)
- imagePicture.Source = new BitmapImage(new Uri("pack://application:,,,/Core;component/Resources/Pump/pump_warning.png"));
- else if (DeviceData.IsOn)
- imagePicture.Source = new BitmapImage(new Uri("pack://application:,,,/Core;component/Resources/Pump/pump_on.png"));
- else
- imagePicture.Source = new BitmapImage(new Uri("pack://application:,,,/Core;component/Resources/Pump/pump_off.png"));
- StackPanelN2Pressure.Visibility = (DeviceData.IsN2PressureEnable && IsShowSensor) ? Visibility.Visible : Visibility.Hidden;
- StackPanelWaterFlow.Visibility = (DeviceData.IsWaterFlowEnable && IsShowSensor) ? Visibility.Visible : Visibility.Hidden;
- StackPanelDryPump.Visibility = (DeviceData.IsDryPumpEnable && IsShowSensor) ? Visibility.Visible : Visibility.Hidden;
- WaterFlowStatusColor = DeviceData.WaterFlowAlarm
- ? Brushes.Red
- : (DeviceData.WaterFlowWarning ? Brushes.Yellow : Brushes.Lime);
- N2PressureStatusColor = DeviceData.N2PressureAlarm
- ? Brushes.Red
- : (DeviceData.N2PressureWarning ? Brushes.Yellow : Brushes.Lime);
- }
- private void Grid_MouseEnter(object sender, MouseEventArgs e)
- {
- if (DeviceData != null)
- {
- string tooltipValue =
- string.Format(Application.Current.Resources["GlobalLableFlowMeterToolTip"].ToString(),
- "",
- DeviceData.DisplayName,
- DeviceData.DeviceSchematicId,
- DeviceData.WaterFlow.ToString("F1"),
- "");
- ToolTip = tooltipValue;
- }
- }
- }
- }
|