using NEIntelligentControl2.Models.PV;
using NEIntelligentControl2.Windows;
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.Infos
{

    /// <summary>
    /// 光伏详情数据点控件
    /// </summary>
    public partial class InverterPoint : UserControl
    {
        //  --------------依赖属性--------------
        public static readonly DependencyProperty PointValueProperty = DependencyProperty.Register("PointValue", typeof(double), typeof(InverterPoint));
        /// <summary>
        /// 数据点值
        /// </summary>
        public double PointValue { get { return (double)GetValue(PointValueProperty); } set { SetValue(PointValueProperty, Math.Round(value, 2)); } }
        private PVTagInfo tagInfo;
        /// <summary>
        /// 光伏信息
        /// </summary>
        public PVTagInfo TagInfo { get => tagInfo; set { tagInfo = value; tagInfo.ValueChanged = ValueChanged; } }
        /// <summary>
        /// 光伏ID
        /// </summary>
        public string PVId { get; internal set; }

        public InverterPoint()
        {
            InitializeComponent();
        }
        private void ValueChanged(double obj)
        {
            this.PointValue = obj;
        }

        private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ClickCount < 2) return;
            HistoryDataWindow.ShowWindow(TagInfo.Name, TagInfo.Code, "windturbine", PVId, 1, 24);
        }
    }
}
