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
{
///
/// 光伏卡片
///
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));
///
/// 名称
///
public string PVName { get { return GetValue(PVNameProperty) as string; } set { SetValue(PVNameProperty, value); } }
///
/// 电流
///
public string Current { get { return GetValue(CurrentProperty) as string; } set { SetValue(CurrentProperty, value); } }
///
/// 电压
///
public string Voltage { get { return GetValue(VoltageProperty) as string; } set { SetValue(VoltageProperty, value); } }
///
/// 功率
///
public string Power { get { return GetValue(PowerProperty) as string; } set { SetValue(PowerProperty, value); } }
///
/// 状态
///
public PVState Status { get { return (PVState)GetValue(StatusProperty); } set { SetValue(StatusProperty, value); } }
///
/// 状态字符串
///
public string StateString { get { return GetValue(StateStringProperty) as string; } set { SetValue(StateStringProperty, value); } }
///
/// 提示消息
///
public string ToolTipValue { get => GetValue(ToolTipValueProperty) as string; set => SetValue(ToolTipValueProperty, value); }
public string Id { get; set; }
public PVInfo Info;
///
/// 小卡片模式
///
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);
}
}
}