IconTextBoxBase.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Windows;
  7. using System.Windows.Media;
  8. namespace CustomUI.MyControls.Primitives
  9. {
  10. public class IconTextBoxBase : ZTextBoxBase
  11. {
  12. #region 依赖属性
  13. #region IsShowIcon
  14. /// <summary>
  15. /// 获取或者设置是否显示图标
  16. /// </summary>
  17. [Bindable(true), Description("获取或者设置是否显示图标")]
  18. public bool IsShowIcon
  19. {
  20. get { return (bool)GetValue(IsShowIconProperty); }
  21. set { SetValue(IsShowIconProperty, value); }
  22. }
  23. public static readonly DependencyProperty IsShowIconProperty =
  24. DependencyProperty.Register("IsShowIcon", typeof(bool), typeof(IconTextBoxBase), new PropertyMetadata(true));
  25. #endregion
  26. #region IconBackground
  27. /// <summary>
  28. /// 获取或者设置图标边框背景色
  29. /// </summary>
  30. [Bindable(true), Description("获取或者设置图标边框背景色")]
  31. public Brush IconBackground
  32. {
  33. get { return (Brush)GetValue(IconBackgroundProperty); }
  34. set { SetValue(IconBackgroundProperty, value); }
  35. }
  36. public static readonly DependencyProperty IconBackgroundProperty =
  37. DependencyProperty.Register("IconBackground", typeof(Brush), typeof(IconTextBoxBase));
  38. #endregion
  39. #region IconForeground
  40. /// <summary>
  41. /// 获取或者设置图标的颜色
  42. /// </summary>
  43. [Bindable(true), Description("获取或者设置图标的颜色")]
  44. public Brush IconForeground
  45. {
  46. get { return (Brush)GetValue(IconForegroundProperty); }
  47. set { SetValue(IconForegroundProperty, value); }
  48. }
  49. public static readonly DependencyProperty IconForegroundProperty =
  50. DependencyProperty.Register("IconForeground", typeof(Brush), typeof(IconTextBoxBase));
  51. #endregion
  52. #region IconBorderBrush
  53. /// <summary>
  54. /// 获取或者设置图标边框的颜色
  55. /// </summary>
  56. [Bindable(true), Description("获取或者设置图标边框背景色")]
  57. public Brush IconBorderBrush
  58. {
  59. get { return (Brush)GetValue(IconBorderBrushProperty); }
  60. set { SetValue(IconBorderBrushProperty, value); }
  61. }
  62. public static readonly DependencyProperty IconBorderBrushProperty =
  63. DependencyProperty.Register("IconBorderBrush", typeof(Brush), typeof(IconTextBoxBase));
  64. #endregion
  65. #region IconBorderThickness
  66. /// <summary>
  67. /// 获取或者设置图标边框的粗细与大小
  68. /// </summary>
  69. public Thickness IconBorderThickness
  70. {
  71. get { return (Thickness)GetValue(IconBorderThicknessProperty); }
  72. set { SetValue(IconBorderThicknessProperty, value); }
  73. }
  74. public static readonly DependencyProperty IconBorderThicknessProperty =
  75. DependencyProperty.Register("IconBorderThickness", typeof(Thickness), typeof(IconTextBoxBase));
  76. #endregion
  77. #region IconWidth
  78. /// <summary>
  79. /// 获取或者设置图标的大小
  80. /// </summary>
  81. [Bindable(true), Description("获取或者设置图标的大小")]
  82. public double IconWidth
  83. {
  84. get { return (double)GetValue(IconWidthProperty); }
  85. set { SetValue(IconWidthProperty, value); }
  86. }
  87. public static readonly DependencyProperty IconWidthProperty =
  88. DependencyProperty.Register("IconWidth", typeof(double), typeof(IconTextBoxBase));
  89. #endregion
  90. #region IconPadding
  91. /// <summary>
  92. /// 获取或者设置图标的内边距
  93. /// </summary>
  94. [Bindable(true), Description("获取或者设置图标的内边距")]
  95. public Thickness IconPadding
  96. {
  97. get { return (Thickness)GetValue(IconPaddingProperty); }
  98. set { SetValue(IconPaddingProperty, value); }
  99. }
  100. public static readonly DependencyProperty IconPaddingProperty =
  101. DependencyProperty.Register("IconPadding", typeof(Thickness), typeof(IconTextBoxBase));
  102. #endregion
  103. #region IconCornerRadius
  104. /// <summary>
  105. /// 获取或者设置图标边框的圆角(可以不用手动设置,系统会根据密码框的圆角值自动设置该值)
  106. /// </summary>
  107. [Bindable(true), Description("获取或者设置图标边框的圆角(可以不用手动设置,系统会根据密码框的圆角值自动设置该值)")]
  108. public CornerRadius IconCornerRadius
  109. {
  110. get { return (CornerRadius)GetValue(IconCornerRadiusProperty); }
  111. set { SetValue(IconCornerRadiusProperty, value); }
  112. }
  113. public static readonly DependencyProperty IconCornerRadiusProperty =
  114. DependencyProperty.Register("IconCornerRadius", typeof(CornerRadius), typeof(IconTextBoxBase));
  115. #endregion
  116. #region IconPathData
  117. /// <summary>
  118. /// 获取或者设置密码框图标
  119. /// </summary>
  120. [Bindable(true), Description("获取或者设置密码框图标")]
  121. public PathGeometry IconPathData
  122. {
  123. get { return (PathGeometry)GetValue(IconPathDataProperty); }
  124. set { SetValue(IconPathDataProperty, value); }
  125. }
  126. public static readonly DependencyProperty IconPathDataProperty =
  127. DependencyProperty.Register("IconPathData", typeof(PathGeometry), typeof(IconTextBoxBase));
  128. #endregion
  129. #endregion
  130. public override void OnCornerRadiusChanged(CornerRadius newValue)
  131. {
  132. this.SetValue(IconTextBoxBase.IconCornerRadiusProperty, new CornerRadius(newValue.TopLeft, 0, 0, newValue.BottomLeft));
  133. }
  134. }
  135. }