DataTag.xaml.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using NEIntelligentControl2.Models.BoostStation;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. namespace NEIntelligentControl2.Views.BoostStation
  17. {
  18. /// <summary>
  19. /// 标签
  20. /// </summary>
  21. public partial class DataTag : UserControl, IBoostStationPoint
  22. {
  23. public static readonly DependencyProperty IsEditModelProperty = DependencyProperty.Register("IsEditModel", typeof(bool), typeof(DataTag));
  24. public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register("IsSelected", typeof(bool), typeof(DataTag));
  25. public static readonly DependencyProperty InfoProperty = DependencyProperty.Register("Info", typeof(string), typeof(DataTag));
  26. public bool IsSelected { get => (bool)GetValue(IsSelectedProperty); set => SetValue(IsSelectedProperty, value); }
  27. public double Value { get; set; }
  28. public bool IsTemplete { get; set; }
  29. public bool IsEditModel { get => (bool)GetValue(IsEditModelProperty); set => SetValue(IsEditModelProperty, value); }
  30. public int Proportion { get; set; }
  31. public string Info { get => GetValue(InfoProperty) as string; set => SetValue(InfoProperty, value); }
  32. public Action<Control> Clicked { get; set; }
  33. string IBoostStationPoint.DataTag { get; set; }
  34. public bool IsNegate { get; set; }
  35. /// <summary>
  36. /// 原始宽
  37. /// </summary>
  38. private double _Width;
  39. /// <summary>
  40. /// 原始高
  41. /// </summary>
  42. private double _Height;
  43. public DataTag()
  44. {
  45. InitializeComponent();
  46. }
  47. public void Zoom(int times)
  48. {
  49. Proportion += times;
  50. ToZoom();
  51. }
  52. private void ToZoom()
  53. {
  54. this.Width = _Width * (1 + Proportion * 0.1);
  55. this.Height = _Height * (1 + Proportion * 0.1);
  56. }
  57. private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  58. {
  59. IsSelected = !IsSelected && !IsTemplete && IsEditModel;
  60. Clicked?.Invoke(this);
  61. }
  62. private void UserControl_Loaded(object sender, RoutedEventArgs e)
  63. {
  64. _Width = Width;
  65. _Height = Height;
  66. ToZoom();
  67. }
  68. private void TextBox_MouseEnter(object sender, MouseEventArgs e)
  69. {
  70. (sender as TextBox).Focus();
  71. }
  72. }
  73. }