ManualSettingControl.xaml.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. using Panuon.UI.Silver;
  2. using Prism.Commands;
  3. using System;
  4. using System.Windows;
  5. using System.Windows.Controls;
  6. using System.Windows.Data;
  7. namespace SHJX.Service.Library.Views.ManualControl
  8. {
  9. /// <summary>
  10. /// ManualSettingControl.xaml 的交互逻辑
  11. /// </summary>
  12. public partial class ManualSettingControl : UserControl
  13. {
  14. public ManualSettingControl()
  15. {
  16. InitializeComponent();
  17. }
  18. #region Property
  19. public string HeaderValue
  20. {
  21. set => gb.Header = value;
  22. }
  23. #endregion
  24. #region DependencyProperty
  25. #region LeftButton Content
  26. public string LeftButtonContent
  27. {
  28. get => (string)GetValue(LeftButtonContentProperty);
  29. set => SetValue(LeftButtonContentProperty, value);
  30. }
  31. public static readonly DependencyProperty LeftButtonContentProperty =
  32. DependencyProperty.Register(
  33. nameof(LeftButtonContent), typeof(string),
  34. typeof(ManualSettingControl), new UIPropertyMetadata(string.Empty, (obj, args) =>
  35. {
  36. var control = obj as ManualSettingControl;
  37. var path = control?.btn_left;
  38. path.Content = args.NewValue.ToString();
  39. }));
  40. #endregion
  41. #region RightButton Content
  42. public string RightButtonContent
  43. {
  44. get => (string)GetValue(RightButtonContentProperty);
  45. set => SetValue(RightButtonContentProperty, value);
  46. }
  47. public static readonly DependencyProperty RightButtonContentProperty =
  48. DependencyProperty.Register(
  49. nameof(RightButtonContent), typeof(string),
  50. typeof(ManualSettingControl), new UIPropertyMetadata(string.Empty, (obj, args) =>
  51. {
  52. var control = obj as ManualSettingControl;
  53. var path = control?.btn_right;
  54. path.Content = args.NewValue.ToString();
  55. }));
  56. #endregion
  57. #region LeftButtonWait
  58. public bool LeftButtonWait
  59. {
  60. get => (bool)GetValue(LeftButtonWaitProperty);
  61. set => SetValue(LeftButtonWaitProperty, value);
  62. }
  63. public static readonly DependencyProperty LeftButtonWaitProperty =
  64. DependencyProperty.Register(
  65. nameof(LeftButtonWait), typeof(bool),
  66. typeof(ManualSettingControl), new UIPropertyMetadata(false, (obj, args) =>
  67. {
  68. ManualSettingControl control = obj as ManualSettingControl;
  69. Button path = control?.btn_left;
  70. Binding binding = new()
  71. {
  72. Source = Convert.ToBoolean(args.NewValue)
  73. };
  74. BindingOperations.SetBinding(path, ButtonHelper.IsWaitingProperty, binding);
  75. }));
  76. #endregion
  77. #region RightButtonWait
  78. public bool RightButtonWait
  79. {
  80. get => (bool)GetValue(RightButtonWaitProperty);
  81. set => SetValue(RightButtonWaitProperty, value);
  82. }
  83. public static readonly DependencyProperty RightButtonWaitProperty =
  84. DependencyProperty.Register(
  85. nameof(RightButtonWait), typeof(bool),
  86. typeof(ManualSettingControl), new UIPropertyMetadata(false, (obj, args) =>
  87. {
  88. ManualSettingControl control = obj as ManualSettingControl;
  89. Button path = control?.btn_right;
  90. Binding binding = new()
  91. {
  92. Source = Convert.ToBoolean(args.NewValue)
  93. };
  94. BindingOperations.SetBinding(path, ButtonHelper.IsWaitingProperty, binding);
  95. }));
  96. #endregion
  97. #region LeftButton Visibility
  98. public Visibility LeftButtonVisibility
  99. {
  100. get => (Visibility)GetValue(LeftButtonVisibilityProperty);
  101. set => SetValue(LeftButtonVisibilityProperty, value);
  102. }
  103. public static readonly DependencyProperty LeftButtonVisibilityProperty =
  104. DependencyProperty.Register(nameof(LeftButtonVisibility), typeof(Visibility),
  105. typeof(ManualSettingControl), new UIPropertyMetadata(Visibility.Visible, (obj, args) =>
  106. {
  107. var control = obj as ManualSettingControl;
  108. var path = control?.btn_left;
  109. path.Visibility = (Visibility)args.NewValue;
  110. }));
  111. #endregion
  112. #region RightButton Visibility
  113. public Visibility RightButtonVisibility
  114. {
  115. get => (Visibility)GetValue(RightButtonVisibilityProperty);
  116. set => SetValue(RightButtonVisibilityProperty, value);
  117. }
  118. public static readonly DependencyProperty RightButtonVisibilityProperty =
  119. DependencyProperty.Register(nameof(RightButtonVisibility), typeof(Visibility),
  120. typeof(ManualSettingControl), new UIPropertyMetadata(Visibility.Visible, (obj, args) =>
  121. {
  122. var control = obj as ManualSettingControl;
  123. var path = control?.btn_right;
  124. path.Visibility = (Visibility)args.NewValue;
  125. }));
  126. #endregion
  127. #region LeftButton Command
  128. public DelegateCommand<object> LeftButtonCommand
  129. {
  130. get => (DelegateCommand<object>)GetValue(LeftButtonCommandProperty);
  131. set => SetValue(LeftButtonCommandProperty, value);
  132. }
  133. public static readonly DependencyProperty LeftButtonCommandProperty =
  134. DependencyProperty.Register(nameof(LeftButtonCommand), typeof(DelegateCommand<object>), typeof(ManualSettingControl),
  135. new UIPropertyMetadata(null, (obj, args) =>
  136. {
  137. var control = obj as ManualSettingControl;
  138. var path = control?.btn_left;
  139. path.Command = args.NewValue as DelegateCommand<object>;
  140. }));
  141. #endregion
  142. #region RightButton Command
  143. public DelegateCommand<object> RightButtonCommand
  144. {
  145. get => (DelegateCommand<object>)GetValue(RightButtonCommandProperty);
  146. set => SetValue(RightButtonCommandProperty, value);
  147. }
  148. public static readonly DependencyProperty RightButtonCommandProperty =
  149. DependencyProperty.Register(nameof(RightButtonCommand), typeof(DelegateCommand<object>), typeof(ManualSettingControl),
  150. new UIPropertyMetadata(null, (obj, args) =>
  151. {
  152. var control = obj as ManualSettingControl;
  153. var path = control?.btn_right;
  154. path.Command = args.NewValue as DelegateCommand<object>;
  155. }));
  156. #endregion
  157. #region Text
  158. public string TextValue
  159. {
  160. get => (string)GetValue(TextValueProperty);
  161. set => SetValue(TextValueProperty, value);
  162. }
  163. public static readonly DependencyProperty TextValueProperty =
  164. DependencyProperty.Register(
  165. nameof(TextValue), typeof(string),
  166. typeof(ManualSettingControl), new UIPropertyMetadata(string.Empty, TextValueCallback)
  167. );
  168. private static void TextValueCallback(DependencyObject obj, DependencyPropertyChangedEventArgs args)
  169. {
  170. var control = obj as ManualSettingControl;
  171. var path = control?.txt_setting;
  172. path.Text = args.NewValue.ToString();
  173. }
  174. #endregion
  175. #endregion
  176. }
  177. }