using Panuon.UI.Silver; using Prism.Commands; using System; using System.Windows; using System.Windows.Controls; using System.Windows.Data; namespace SHJX.Service.Library.Views.ManualControl { /// /// ManualSettingControl.xaml 的交互逻辑 /// public partial class ManualSettingControl : UserControl { public ManualSettingControl() { InitializeComponent(); } #region Property public string HeaderValue { set => gb.Header = value; } #endregion #region DependencyProperty #region LeftButton Content public string LeftButtonContent { get => (string)GetValue(LeftButtonContentProperty); set => SetValue(LeftButtonContentProperty, value); } public static readonly DependencyProperty LeftButtonContentProperty = DependencyProperty.Register( nameof(LeftButtonContent), typeof(string), typeof(ManualSettingControl), new UIPropertyMetadata(string.Empty, (obj, args) => { var control = obj as ManualSettingControl; var path = control?.btn_left; path.Content = args.NewValue.ToString(); })); #endregion #region RightButton Content public string RightButtonContent { get => (string)GetValue(RightButtonContentProperty); set => SetValue(RightButtonContentProperty, value); } public static readonly DependencyProperty RightButtonContentProperty = DependencyProperty.Register( nameof(RightButtonContent), typeof(string), typeof(ManualSettingControl), new UIPropertyMetadata(string.Empty, (obj, args) => { var control = obj as ManualSettingControl; var path = control?.btn_right; path.Content = args.NewValue.ToString(); })); #endregion #region LeftButtonWait public bool LeftButtonWait { get => (bool)GetValue(LeftButtonWaitProperty); set => SetValue(LeftButtonWaitProperty, value); } public static readonly DependencyProperty LeftButtonWaitProperty = DependencyProperty.Register( nameof(LeftButtonWait), typeof(bool), typeof(ManualSettingControl), new UIPropertyMetadata(false, (obj, args) => { ManualSettingControl control = obj as ManualSettingControl; Button path = control?.btn_left; Binding binding = new() { Source = Convert.ToBoolean(args.NewValue) }; BindingOperations.SetBinding(path, ButtonHelper.IsWaitingProperty, binding); })); #endregion #region RightButtonWait public bool RightButtonWait { get => (bool)GetValue(RightButtonWaitProperty); set => SetValue(RightButtonWaitProperty, value); } public static readonly DependencyProperty RightButtonWaitProperty = DependencyProperty.Register( nameof(RightButtonWait), typeof(bool), typeof(ManualSettingControl), new UIPropertyMetadata(false, (obj, args) => { ManualSettingControl control = obj as ManualSettingControl; Button path = control?.btn_right; Binding binding = new() { Source = Convert.ToBoolean(args.NewValue) }; BindingOperations.SetBinding(path, ButtonHelper.IsWaitingProperty, binding); })); #endregion #region LeftButton Visibility public Visibility LeftButtonVisibility { get => (Visibility)GetValue(LeftButtonVisibilityProperty); set => SetValue(LeftButtonVisibilityProperty, value); } public static readonly DependencyProperty LeftButtonVisibilityProperty = DependencyProperty.Register(nameof(LeftButtonVisibility), typeof(Visibility), typeof(ManualSettingControl), new UIPropertyMetadata(Visibility.Visible, (obj, args) => { var control = obj as ManualSettingControl; var path = control?.btn_left; path.Visibility = (Visibility)args.NewValue; })); #endregion #region RightButton Visibility public Visibility RightButtonVisibility { get => (Visibility)GetValue(RightButtonVisibilityProperty); set => SetValue(RightButtonVisibilityProperty, value); } public static readonly DependencyProperty RightButtonVisibilityProperty = DependencyProperty.Register(nameof(RightButtonVisibility), typeof(Visibility), typeof(ManualSettingControl), new UIPropertyMetadata(Visibility.Visible, (obj, args) => { var control = obj as ManualSettingControl; var path = control?.btn_right; path.Visibility = (Visibility)args.NewValue; })); #endregion #region LeftButton Command public DelegateCommand LeftButtonCommand { get => (DelegateCommand)GetValue(LeftButtonCommandProperty); set => SetValue(LeftButtonCommandProperty, value); } public static readonly DependencyProperty LeftButtonCommandProperty = DependencyProperty.Register(nameof(LeftButtonCommand), typeof(DelegateCommand), typeof(ManualSettingControl), new UIPropertyMetadata(null, (obj, args) => { var control = obj as ManualSettingControl; var path = control?.btn_left; path.Command = args.NewValue as DelegateCommand; })); #endregion #region RightButton Command public DelegateCommand RightButtonCommand { get => (DelegateCommand)GetValue(RightButtonCommandProperty); set => SetValue(RightButtonCommandProperty, value); } public static readonly DependencyProperty RightButtonCommandProperty = DependencyProperty.Register(nameof(RightButtonCommand), typeof(DelegateCommand), typeof(ManualSettingControl), new UIPropertyMetadata(null, (obj, args) => { var control = obj as ManualSettingControl; var path = control?.btn_right; path.Command = args.NewValue as DelegateCommand; })); #endregion #region Text public string TextValue { get => (string)GetValue(TextValueProperty); set => SetValue(TextValueProperty, value); } public static readonly DependencyProperty TextValueProperty = DependencyProperty.Register( nameof(TextValue), typeof(string), typeof(ManualSettingControl), new UIPropertyMetadata(string.Empty, TextValueCallback) ); private static void TextValueCallback(DependencyObject obj, DependencyPropertyChangedEventArgs args) { var control = obj as ManualSettingControl; var path = control?.txt_setting; path.Text = args.NewValue.ToString(); } #endregion #endregion } }