PointTag.xaml.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using NEIntelligentControl2.Models.Datas;
  2. using NEIntelligentControl2.Models.WinForms;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Navigation;
  16. using System.Windows.Shapes;
  17. namespace NEIntelligentControl2.Views.Infos
  18. {
  19. /// <summary>
  20. /// 测点标签
  21. /// </summary>
  22. public partial class PointTag : UserControl
  23. {
  24. private UniformCodeInfo _UniformCodeInfo;
  25. private string _WindturbineId;
  26. public PointTag(UniformCodeInfo uci, string windturbineId)
  27. {
  28. InitializeComponent();
  29. _UniformCodeInfo = uci;
  30. _WindturbineId = windturbineId;
  31. Init();
  32. }
  33. private void Init()
  34. {
  35. _TBName.Text = _UniformCodeInfo.Name;
  36. _TBUnit.Text = _UniformCodeInfo.Unit;
  37. }
  38. internal void UpdateData(Dictionary<string, TsData> vs)
  39. {
  40. if (!vs.ContainsKey(_UniformCodeInfo.UniformCode)) return;
  41. double v = vs[_UniformCodeInfo.UniformCode].Value;
  42. if (_UniformCodeInfo.UniformCode.StartsWith("DI"))
  43. {
  44. _TBValue.Text = v == 1 ? "是" : "否";
  45. }
  46. else
  47. {
  48. v *= _UniformCodeInfo.Ratio;
  49. _TBValue.Text = Math.Round(v, 2).ToString();
  50. }
  51. }
  52. private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  53. {
  54. if (e.ClickCount < 2) return;
  55. Windows.HistoryDataWindow.ShowWindow(this._UniformCodeInfo.Name, this._UniformCodeInfo.UniformCode, "windturbine", this._WindturbineId, this._UniformCodeInfo.Ratio);
  56. }
  57. }
  58. }