AGCTag.xaml.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using NEIntelligentControl2.Models.AGC;
  2. using NEIntelligentControl2.Windows;
  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.AGC
  18. {
  19. /// <summary>
  20. /// AGC标签
  21. /// </summary>
  22. public partial class AGCTag : UserControl
  23. {
  24. // --------依赖属性---------
  25. public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(string), typeof(AGCTag));
  26. private TagInfo info;
  27. /// <summary>
  28. /// 信息
  29. /// </summary>
  30. public TagInfo Info { get => info; set { info = value; info.ValueChanged = ValueChanged; } }
  31. /// <summary>
  32. /// 值
  33. /// </summary>
  34. public string Value { get => (string)GetValue(ValueProperty); set => SetValue(ValueProperty, value); }
  35. /// <summary>
  36. /// 是否是DI点
  37. /// </summary>
  38. public bool IsDiPoint { get; set; }
  39. public AGCTag()
  40. {
  41. InitializeComponent();
  42. }
  43. private void ValueChanged(double d)
  44. {
  45. this.Value = d.ToString("0.00");
  46. }
  47. private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  48. {
  49. if (e.ClickCount < 2 || IsDiPoint) return;
  50. HistoryDataWindow.ShowWindow(Info.Name, Info.Tag, Info.Multiplier);
  51. }
  52. }
  53. }