using NEIntelligentControl2.Models.Datas;
using NEIntelligentControl2.Models.Windturbine;
using NEIntelligentControl2.Models.WinForms;
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 WindturbineDetailsCard : UserControl
    {
        public string CardTitle { get; internal set; }
        public List<UniformCodeInfo> Items { get; internal set; }
        public WindturbineInfo Info { get; internal set; }

        private List<PointTag> _PointTags;

        public WindturbineDetailsCard()
        {
            InitializeComponent();
        }

        internal void RefreshData(Dictionary<string, TsData> vs)
        {
            if (ug.Children.Count <= 0)
            {
                Init();
            }
            foreach (var v in _PointTags)
            {
                v.UpdateData(vs);
            }
        }

        private void Init()
        {
            if (Items == null) return;
            _PointTags = new List<PointTag>();
            foreach (var v in Items)
            {
                if (string.IsNullOrWhiteSpace(v.Name)) continue;
                PointTag pt = new PointTag(v, Info.WindturbineId) { Margin = new Thickness(1) };
                ug.Children.Add(pt);
                _PointTags.Add(pt);
            }
        }
    }
}
