终端一体化运控平台
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

122 wiersze
4.4 KiB

  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.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. using Microsoft.Windows;
  16. namespace BPASmartClient.CustomResource.UserControls
  17. {
  18. /// <summary>
  19. /// WatermarkText.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class WatermarkText : UserControl
  22. {
  23. public WatermarkText()
  24. {
  25. InitializeComponent();
  26. Maintb.TextChanged += Maintb_TextChanged;
  27. }
  28. private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  29. {
  30. (d as WatermarkText)?.Refresh();
  31. }
  32. private void Refresh()
  33. {
  34. //this.Maintb.Text = Text;
  35. //this.Subtb.Text = SubText;
  36. //this.Maintb.Background = WTBackground;
  37. }
  38. public string Text
  39. {
  40. get { return (string)GetValue(TextProperty); }
  41. set { SetValue(TextProperty, value); }
  42. }
  43. public static readonly DependencyProperty TextProperty =
  44. DependencyProperty.Register("Text", typeof(string), typeof(WatermarkText),
  45. new PropertyMetadata(string.Empty, new PropertyChangedCallback(OnPropertyChanged)));
  46. public string SubText
  47. {
  48. get { return (string)GetValue(SubTextProperty); }
  49. set { SetValue(SubTextProperty, value); }
  50. }
  51. public static readonly DependencyProperty SubTextProperty =
  52. DependencyProperty.Register("SubText", typeof(string), typeof(WatermarkText),
  53. new PropertyMetadata(string.Empty, new PropertyChangedCallback(OnPropertyChanged)));
  54. public Brush WTBackground
  55. {
  56. get { return (Brush)GetValue(WTBackgroundProperty); }
  57. set { SetValue(WTBackgroundProperty, value); }
  58. }
  59. public static readonly DependencyProperty WTBackgroundProperty =
  60. DependencyProperty.Register("WTBackground", typeof(Brush), typeof(WatermarkText),
  61. new PropertyMetadata(default(Brush), new PropertyChangedCallback(OnPropertyChanged)));
  62. public int StrokeThickness
  63. {
  64. get { return (int)GetValue(StrokeThicknessProperty); }
  65. set { SetValue(StrokeThicknessProperty, value); }
  66. }
  67. public static readonly DependencyProperty StrokeThicknessProperty =
  68. DependencyProperty.Register("StrokeThickness", typeof(int), typeof(WatermarkText),
  69. new PropertyMetadata(0, new PropertyChangedCallback(OnPropertyChanged)));
  70. public Brush Stroke
  71. {
  72. get { return (Brush)GetValue(StrokeProperty); }
  73. set { SetValue(StrokeProperty, value); }
  74. }
  75. public static readonly DependencyProperty StrokeProperty =
  76. DependencyProperty.Register("Stroke", typeof(Brush), typeof(WatermarkText),
  77. new PropertyMetadata(default(Brush), new PropertyChangedCallback(OnPropertyChanged)));
  78. public CornerRadius WTCornerRadius
  79. {
  80. get { return (CornerRadius)GetValue(WTCornerRadiusProperty); }
  81. set { SetValue(WTCornerRadiusProperty, value); }
  82. }
  83. public static readonly DependencyProperty WTCornerRadiusProperty =
  84. DependencyProperty.Register("WTCornerRadius", typeof(CornerRadius), typeof(WatermarkText),
  85. new PropertyMetadata(new CornerRadius(0), new PropertyChangedCallback(OnPropertyChanged)));
  86. public Brush SubForeground
  87. {
  88. get { return (Brush)GetValue(SubForegroundProperty); }
  89. set { SetValue(SubForegroundProperty, value); }
  90. }
  91. public static readonly DependencyProperty SubForegroundProperty =
  92. DependencyProperty.Register("SubForeground", typeof(Brush), typeof(WatermarkText),
  93. new PropertyMetadata(default(Brush), new PropertyChangedCallback(OnPropertyChanged)));
  94. private void Maintb_TextChanged(object sender, TextChangedEventArgs e)
  95. {
  96. if (Maintb.Text.Trim().Length > 0)
  97. Subtb.Visibility = Visibility.Collapsed;
  98. else
  99. Subtb.Visibility = Visibility.Visible;
  100. }
  101. }
  102. }