SpeedControl.xaml.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. using System.Windows;
  2. using System.Windows.Input;
  3. using System.Windows.Controls;
  4. using Prism.Commands;
  5. namespace SHJX.Service.Library.Views.SettingLibrary
  6. {
  7. /// <summary>
  8. /// SpeedControl.xaml 的交互逻辑
  9. /// </summary>
  10. public partial class SpeedControl : UserControl
  11. {
  12. #region Dependency Property
  13. #region Command
  14. public DelegateCommand<string> SettingSpeedCommand
  15. {
  16. get => (DelegateCommand<string>)GetValue(SettingSpeedCommandProperty);
  17. set => SetValue(SettingSpeedCommandProperty, value);
  18. }
  19. public static readonly DependencyProperty SettingSpeedCommandProperty =
  20. DependencyProperty.Register(nameof(SettingSpeedCommand), typeof(DelegateCommand<string>), typeof(SpeedControl),
  21. new UIPropertyMetadata(null, (obj, args) =>
  22. {
  23. var control = obj as SpeedControl;
  24. var path = control?.btn_speedsetting;
  25. path.Command = args.NewValue as DelegateCommand<string>;
  26. }));
  27. #endregion
  28. #region Header
  29. public string HeaderValue
  30. {
  31. get => (string)GetValue(HeaderValueProperty);
  32. set => SetValue(HeaderValueProperty, value);
  33. }
  34. public static readonly DependencyProperty HeaderValueProperty =
  35. DependencyProperty.Register(nameof(HeaderValue), typeof(string), typeof(SpeedControl),
  36. new UIPropertyMetadata(string.Empty, (obj, args) =>
  37. {
  38. var control = obj as SpeedControl;
  39. var path = control?.gb_speed;
  40. path.Header = args.NewValue.ToString();
  41. }));
  42. #endregion
  43. #region Tag
  44. public string TagValue
  45. {
  46. get => (string)GetValue(TagValueProperty);
  47. set => SetValue(TagValueProperty, value);
  48. }
  49. public static readonly DependencyProperty TagValueProperty =
  50. DependencyProperty.Register(nameof(TagValue), typeof(string), typeof(SpeedControl),
  51. new UIPropertyMetadata(string.Empty, (obj, args) =>
  52. {
  53. var control = obj as SpeedControl;
  54. var path = control?.gb_speed;
  55. path.Tag = args.NewValue.ToString();
  56. }));
  57. #endregion
  58. #region 速度
  59. public string Speed
  60. {
  61. get => (string)GetValue(SpeedProperty);
  62. set => SetValue(SpeedProperty, value);
  63. }
  64. public static readonly DependencyProperty SpeedProperty =
  65. DependencyProperty.Register(nameof(Speed), typeof(string), typeof(SpeedControl),
  66. new UIPropertyMetadata(string.Empty, (obj, args) =>
  67. {
  68. var control = obj as SpeedControl;
  69. var path = control?.txt_speed;
  70. path.Text = args.NewValue.ToString();
  71. }));
  72. #endregion
  73. #region 加速度
  74. public string AcSpeed
  75. {
  76. get => (string)GetValue(AcSpeedProperty);
  77. set => SetValue(AcSpeedProperty, value);
  78. }
  79. public static readonly DependencyProperty AcSpeedProperty =
  80. DependencyProperty.Register(nameof(AcSpeed), typeof(string), typeof(SpeedControl),
  81. new UIPropertyMetadata(string.Empty, (obj, args) =>
  82. {
  83. var control = obj as SpeedControl;
  84. var path = control?.txt_acspeed;
  85. path.Text = args.NewValue.ToString();
  86. }));
  87. #endregion
  88. #region 减速度
  89. public string DeSpeed
  90. {
  91. get => (string)GetValue(DeSpeedProperty);
  92. set => SetValue(DeSpeedProperty, value);
  93. }
  94. public static readonly DependencyProperty DeSpeedProperty =
  95. DependencyProperty.Register(nameof(DeSpeed), typeof(string), typeof(SpeedControl),
  96. new UIPropertyMetadata(string.Empty, (obj, args) =>
  97. {
  98. var control = obj as SpeedControl;
  99. var path = control?.txt_despeed;
  100. path.Text = args.NewValue.ToString();
  101. }));
  102. #endregion
  103. #endregion
  104. public SpeedControl()
  105. {
  106. InitializeComponent();
  107. }
  108. }
  109. }