| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- 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
- {
- /// <summary>
- /// ManualSettingControl.xaml 的交互逻辑
- /// </summary>
- 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<object> LeftButtonCommand
- {
- get => (DelegateCommand<object>)GetValue(LeftButtonCommandProperty);
- set => SetValue(LeftButtonCommandProperty, value);
- }
- public static readonly DependencyProperty LeftButtonCommandProperty =
- DependencyProperty.Register(nameof(LeftButtonCommand), typeof(DelegateCommand<object>), typeof(ManualSettingControl),
- new UIPropertyMetadata(null, (obj, args) =>
- {
- var control = obj as ManualSettingControl;
- var path = control?.btn_left;
- path.Command = args.NewValue as DelegateCommand<object>;
- }));
- #endregion
- #region RightButton Command
- public DelegateCommand<object> RightButtonCommand
- {
- get => (DelegateCommand<object>)GetValue(RightButtonCommandProperty);
- set => SetValue(RightButtonCommandProperty, value);
- }
- public static readonly DependencyProperty RightButtonCommandProperty =
- DependencyProperty.Register(nameof(RightButtonCommand), typeof(DelegateCommand<object>), typeof(ManualSettingControl),
- new UIPropertyMetadata(null, (obj, args) =>
- {
- var control = obj as ManualSettingControl;
- var path = control?.btn_right;
- path.Command = args.NewValue as DelegateCommand<object>;
- }));
- #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
- }
- }
|