| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 | 
							- using System.Windows;
 
- using System.Windows.Controls;
 
- using System.Windows.Media;
 
- namespace PunkHPX8_Themes.UserControls
 
- {
 
-     /// <summary>
 
-     /// GroupTextBoxControlDouble.xaml 的交互逻辑
 
-     /// </summary>
 
-     public partial class GroupTextBoxControlDouble : UserControl
 
-     {
 
-         #region 属性
 
-         public static readonly DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(string), typeof(GroupTextBoxControlDouble),
 
-           new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
 
-         /// <summary>
 
-         /// 标题
 
-         /// </summary>
 
-         public string Title
 
-         {
 
-             get
 
-             {
 
-                 return (string)this.GetValue(TitleProperty);
 
-             }
 
-             set
 
-             {
 
-                 this.SetValue(TitleProperty, value);
 
-             }
 
-         }
 
-         public static readonly DependencyProperty UnitProperty = DependencyProperty.Register("Unit", typeof(string), typeof(GroupTextBoxControlDouble),
 
-          new FrameworkPropertyMetadata("deg", FrameworkPropertyMetadataOptions.AffectsRender));
 
-         /// <summary>
 
-         /// 单位
 
-         /// </summary>
 
-         public string Unit
 
-         {
 
-             get
 
-             {
 
-                 return (string)this.GetValue(UnitProperty);
 
-             }
 
-             set
 
-             {
 
-                 this.SetValue(UnitProperty, value);
 
-             }
 
-         }
 
-         public static readonly DependencyProperty DoubleValueProperty = DependencyProperty.Register("DoubleValue", typeof(double), typeof(GroupTextBoxControlDouble),
 
-         new PropertyMetadata(-1.0, new PropertyChangedCallback(DoubleValueChanged)));
 
-         /// <summary>
 
-         /// 数值
 
-         /// </summary>
 
-         public double DoubleValue
 
-         {
 
-             get
 
-             {
 
-                 return (double)this.GetValue(DoubleValueProperty);
 
-             }
 
-             set
 
-             {
 
-                 this.SetValue(DoubleValueProperty, value);
 
-             }
 
-         }
 
-         public static readonly DependencyProperty MinValueProperty = DependencyProperty.Register("MinValue", typeof(double), typeof(GroupTextBoxControlDouble),
 
-         new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
 
-         /// <summary>
 
-         /// 最小数值
 
-         /// </summary>
 
-         public double MinValue
 
-         {
 
-             get
 
-             {
 
-                 return (double)this.GetValue(MinValueProperty);
 
-             }
 
-             set
 
-             {
 
-                 this.SetValue(MinValueProperty, value);
 
-             }
 
-         }
 
-         public static readonly DependencyProperty MaxValueProperty = DependencyProperty.Register("MaxValue", typeof(double), typeof(GroupTextBoxControlDouble),
 
-         new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
 
-         /// <summary>
 
-         /// 最大数值
 
-         /// </summary>
 
-         public double MaxValue
 
-         {
 
-             get
 
-             {
 
-                 return (double)this.GetValue(MaxValueProperty);
 
-             }
 
-             set
 
-             {
 
-                 this.SetValue(MaxValueProperty, value);
 
-             }
 
-         }
 
-         public static readonly DependencyProperty EnableProperty = DependencyProperty.Register("Enable", typeof(bool), typeof(GroupTextBoxControlDouble),
 
-         new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));
 
-         /// <summary>
 
-         /// 可用性
 
-         /// </summary>
 
-         public bool Enable
 
-         {
 
-             get
 
-             {
 
-                 return (bool)this.GetValue(EnableProperty);
 
-             }
 
-             set
 
-             {
 
-                 this.SetValue(EnableProperty, value);
 
-             }
 
-         }
 
-         public static readonly DependencyProperty ValidResultProperty = DependencyProperty.Register("ValidResult", typeof(bool), typeof(GroupTextBoxControlDouble),
 
-      new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));
 
-         /// <summary>
 
-         /// 合理性
 
-         /// </summary>
 
-         public bool ValidResult
 
-         {
 
-             get
 
-             {
 
-                 return (bool)this.GetValue(ValidResultProperty);
 
-             }
 
-             set
 
-             {
 
-                 this.SetValue(ValidResultProperty, value);
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 数值发生变化事件
 
-         /// </summary>
 
-         /// <param name="d"></param>
 
-         /// <param name="e"></param>
 
-         private static void DoubleValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 
-         {
 
-             if (e.NewValue != null)
 
-             {
 
-                 double newValue = (double)e.NewValue;
 
-                 double minValue = (double)d.GetValue(MinValueProperty);
 
-                 double maxValue = (double)d.GetValue(MaxValueProperty);
 
-                 bool validResult = newValue >= minValue && newValue <= maxValue;
 
-                 d.SetValue(ValidResultProperty, validResult);
 
-             }
 
-         }
 
-         #endregion
 
-         public GroupTextBoxControlDouble()
 
-         {
 
-             InitializeComponent();
 
-         }
 
-         protected override void OnRender(DrawingContext drawingContext)
 
-         {
 
-             base.OnRender(drawingContext);
 
-             ValidResult = DoubleValue >= MinValue && DoubleValue <= MaxValue;
 
-             RectangleSetPoint.Fill = ValidResult ? new SolidColorBrush(Colors.Transparent) : new SolidColorBrush(Colors.Yellow);
 
-             txtValue.Background = ValidResult ? new SolidColorBrush(Colors.Transparent) : new SolidColorBrush(Colors.Yellow);
 
-         }
 
-     }
 
- }
 
 
  |