SKTextBox.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Media;
  9. namespace SKMC.UI.CustomControls
  10. {
  11. public class SKTextBox : TextBox
  12. {
  13. static SKTextBox()
  14. {
  15. DefaultStyleKeyProperty.OverrideMetadata(typeof(SKTextBox), new FrameworkPropertyMetadata(typeof(SKTextBox)));
  16. }
  17. public string Label
  18. {
  19. get { return (string)GetValue(LabelProperty); }
  20. set { SetValue(LabelProperty, value); }
  21. }
  22. /// <summary>
  23. /// 单位
  24. /// </summary>
  25. public string Unit
  26. {
  27. get { return (string)GetValue(UnitProperty); }
  28. set { SetValue(UnitProperty, value); }
  29. }
  30. /// <summary>
  31. /// 单位字体大小
  32. /// </summary>
  33. public double UnitSize
  34. {
  35. get { return (double)GetValue(UnitSizeProperty); }
  36. set { SetValue(UnitSizeProperty, value); }
  37. }
  38. /// <summary>
  39. /// 值是否有效
  40. /// </summary>
  41. public bool IsValueValid
  42. {
  43. get { return (bool)GetValue(IsValueValidProperty); }
  44. set { SetValue(IsValueValidProperty, value); }
  45. }
  46. /// <summary>
  47. /// 最大值
  48. /// </summary>
  49. public object MaxValue
  50. {
  51. get { return (object)GetValue(MaxValueProperty); }
  52. set { SetValue(MaxValueProperty, value); }
  53. }
  54. /// <summary>
  55. /// 最小值
  56. /// </summary>
  57. public object MinValue
  58. {
  59. get { return (object)GetValue(MinValueProperty); }
  60. set { SetValue(MinValueProperty, value); }
  61. }
  62. /// <summary>
  63. /// 圆角
  64. /// </summary>
  65. public CornerRadius CornerRadius
  66. {
  67. get { return (CornerRadius)GetValue(CornerRadiusProperty); }
  68. set { SetValue(CornerRadiusProperty, value); }
  69. }
  70. public string ToolTipComment
  71. {
  72. get { return (string)GetValue(ToolTipCommentProperty); }
  73. set { SetValue(ToolTipCommentProperty, value); }
  74. }
  75. /// <summary>
  76. /// 图标
  77. /// </summary>
  78. public Geometry Icon
  79. {
  80. get { return (Geometry)GetValue(IconProperty); }
  81. set { SetValue(IconProperty, value); }
  82. }
  83. public double IconSize
  84. {
  85. get { return (double)GetValue(IconSizeProperty); }
  86. set { SetValue(IconSizeProperty, value); }
  87. }
  88. public static readonly DependencyProperty IconProperty =
  89. DependencyProperty.Register("Icon", typeof(Geometry), typeof(SKTextBox), new PropertyMetadata(null));
  90. public static readonly DependencyProperty ToolTipCommentProperty =
  91. DependencyProperty.Register("ToolTipComment", typeof(string), typeof(SKTextBox), new PropertyMetadata(null));
  92. public static readonly DependencyProperty CornerRadiusProperty =
  93. DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(SKTextBox), new PropertyMetadata(new CornerRadius(0)));
  94. public static readonly DependencyProperty MinValueProperty =
  95. DependencyProperty.Register("MinValue", typeof(object), typeof(SKTextBox), new PropertyMetadata(null));
  96. public static readonly DependencyProperty MaxValueProperty =
  97. DependencyProperty.Register("MaxValue", typeof(object), typeof(SKTextBox), new PropertyMetadata(null));
  98. public static readonly DependencyProperty IsValueValidProperty =
  99. DependencyProperty.Register("IsValueValid", typeof(bool), typeof(SKTextBox), new PropertyMetadata(true));
  100. public static readonly DependencyProperty UnitProperty =
  101. DependencyProperty.Register("Unit", typeof(string), typeof(SKTextBox), new PropertyMetadata(""));
  102. public static readonly DependencyProperty LabelProperty =
  103. DependencyProperty.Register("Label", typeof(string), typeof(SKTextBox), new PropertyMetadata(""));
  104. public static readonly DependencyProperty UnitSizeProperty =
  105. DependencyProperty.Register("UnitSize", typeof(double), typeof(SKTextBox), new PropertyMetadata(10.0));
  106. public static readonly DependencyProperty IconSizeProperty =
  107. DependencyProperty.Register(nameof(IconSize), typeof(double), typeof(SKTextBox), new PropertyMetadata(10.0));
  108. }
  109. }