using NEIntelligentControl2.Models.Datas;
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
{
///
/// 测点标签
///
public partial class PointTag : UserControl
{
private UniformCodeInfo _UniformCodeInfo;
private string _WindturbineId;
public PointTag(UniformCodeInfo uci, string windturbineId)
{
InitializeComponent();
_UniformCodeInfo = uci;
_WindturbineId = windturbineId;
Init();
}
private void Init()
{
_TBName.Text = _UniformCodeInfo.Name;
_TBUnit.Text = _UniformCodeInfo.Unit;
}
internal void UpdateData(Dictionary vs)
{
if (!vs.ContainsKey(_UniformCodeInfo.UniformCode)) return;
double v = vs[_UniformCodeInfo.UniformCode].Value;
if (_UniformCodeInfo.UniformCode.StartsWith("DI"))
{
_TBValue.Text = v == 1 ? "是" : "否";
}
else
{
v *= _UniformCodeInfo.Ratio;
_TBValue.Text = Math.Round(v, 2).ToString();
}
}
private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.ClickCount < 2) return;
Windows.HistoryDataWindow.ShowWindow(this._UniformCodeInfo.Name, this._UniformCodeInfo.UniformCode, "windturbine", this._WindturbineId, this._UniformCodeInfo.Ratio);
}
}
}