123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- using NEIntelligentControl2.Models;
- using NEIntelligentControl2.Models.Matrix;
- using NEIntelligentControl2.Models.PV;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace NEIntelligentControl2.Views.Matrix
- {
- /// <summary>
- /// 光伏卡片
- /// </summary>
- public partial class PVBlock : UserControl
- {
- // ----------依赖属性----------
- public static readonly DependencyProperty PVNameProperty = DependencyProperty.Register("PVName", typeof(string), typeof(PVBlock));
- public static readonly DependencyProperty CurrentProperty = DependencyProperty.Register("Current", typeof(string), typeof(PVBlock));
- public static readonly DependencyProperty VoltageProperty = DependencyProperty.Register("Voltage", typeof(string), typeof(PVBlock));
- public static readonly DependencyProperty PowerProperty = DependencyProperty.Register("Power", typeof(string), typeof(PVBlock));
- public static readonly DependencyProperty StatusProperty = DependencyProperty.Register("Status", typeof(PVState), typeof(PVBlock));
- public static readonly DependencyProperty StateStringProperty = DependencyProperty.Register("StateString", typeof(string), typeof(PVBlock));
- public static DependencyProperty ToolTipValueProperty = DependencyProperty.Register("ToolTipValue", typeof(string), typeof(PVBlock));
- /// <summary>
- /// 名称
- /// </summary>
- public string PVName { get { return GetValue(PVNameProperty) as string; } set { SetValue(PVNameProperty, value); } }
- /// <summary>
- /// 电流
- /// </summary>
- public string Current { get { return GetValue(CurrentProperty) as string; } set { SetValue(CurrentProperty, value); } }
- /// <summary>
- /// 电压
- /// </summary>
- public string Voltage { get { return GetValue(VoltageProperty) as string; } set { SetValue(VoltageProperty, value); } }
- /// <summary>
- /// 功率
- /// </summary>
- public string Power { get { return GetValue(PowerProperty) as string; } set { SetValue(PowerProperty, value); } }
- /// <summary>
- /// 状态
- /// </summary>
- public PVState Status { get { return (PVState)GetValue(StatusProperty); } set { SetValue(StatusProperty, value); } }
- /// <summary>
- /// 状态字符串
- /// </summary>
- public string StateString { get { return GetValue(StateStringProperty) as string; } set { SetValue(StateStringProperty, value); } }
- /// <summary>
- /// 提示消息
- /// </summary>
- public string ToolTipValue { get => GetValue(ToolTipValueProperty) as string; set => SetValue(ToolTipValueProperty, value); }
- public string Id { get; set; }
- public PVInfo Info;
- /// <summary>
- /// 小卡片模式
- /// </summary>
- public bool IsSmallModel { get; set; } = false;
- public PVBlock()
- {
- InitializeComponent();
- }
- public void Update(object obj)
- {
- PVInfo pi= obj as PVInfo;
- if (pi == null) return;
- Info = pi;
- Status = pi.State;
- PVName = pi.Code;
- Current = $"{pi.I.ToString("f2")} A";
- Voltage = $"{pi.U.ToString("f2")} V";
- Power = $"{pi.P.ToString("f2")} kW";
- string time = pi.Ts.GetTimeString();
- string timespan = pi.Ts.GetTimeSpanString();
- ToolTipValue = $"开始时间:{time} 时长:{timespan}分钟";
- }
- private void UserControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
- {
- if (e.ClickCount < 1) return;
- Windows.PV.InverterInfoWindow.Show(this);
- }
- }
- }
|