|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- using Microsoft.Windows;
-
- namespace BPASmartClient.CustomResource.UserControls
- {
- /// <summary>
- /// WatermarkText.xaml 的交互逻辑
- /// </summary>
- public partial class WatermarkText : UserControl
- {
- public WatermarkText()
- {
- InitializeComponent();
- Maintb.TextChanged += Maintb_TextChanged;
- }
-
-
- private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- (d as WatermarkText)?.Refresh();
- }
-
- private void Refresh()
- {
- //this.Maintb.Text = Text;
- //this.Subtb.Text = SubText;
- //this.Maintb.Background = WTBackground;
- }
-
- public string Text
- {
- get { return (string)GetValue(TextProperty); }
- set { SetValue(TextProperty, value); }
- }
- public static readonly DependencyProperty TextProperty =
- DependencyProperty.Register("Text", typeof(string), typeof(WatermarkText),
- new PropertyMetadata(string.Empty, new PropertyChangedCallback(OnPropertyChanged)));
-
-
- public string SubText
- {
- get { return (string)GetValue(SubTextProperty); }
- set { SetValue(SubTextProperty, value); }
- }
- public static readonly DependencyProperty SubTextProperty =
- DependencyProperty.Register("SubText", typeof(string), typeof(WatermarkText),
- new PropertyMetadata(string.Empty, new PropertyChangedCallback(OnPropertyChanged)));
-
-
- public Brush WTBackground
- {
- get { return (Brush)GetValue(WTBackgroundProperty); }
- set { SetValue(WTBackgroundProperty, value); }
- }
- public static readonly DependencyProperty WTBackgroundProperty =
- DependencyProperty.Register("WTBackground", typeof(Brush), typeof(WatermarkText),
- new PropertyMetadata(default(Brush), new PropertyChangedCallback(OnPropertyChanged)));
-
-
- public int StrokeThickness
- {
- get { return (int)GetValue(StrokeThicknessProperty); }
- set { SetValue(StrokeThicknessProperty, value); }
- }
- public static readonly DependencyProperty StrokeThicknessProperty =
- DependencyProperty.Register("StrokeThickness", typeof(int), typeof(WatermarkText),
- new PropertyMetadata(0, new PropertyChangedCallback(OnPropertyChanged)));
-
- public Brush Stroke
- {
- get { return (Brush)GetValue(StrokeProperty); }
- set { SetValue(StrokeProperty, value); }
- }
- public static readonly DependencyProperty StrokeProperty =
- DependencyProperty.Register("Stroke", typeof(Brush), typeof(WatermarkText),
- new PropertyMetadata(default(Brush), new PropertyChangedCallback(OnPropertyChanged)));
-
-
- public CornerRadius WTCornerRadius
- {
- get { return (CornerRadius)GetValue(WTCornerRadiusProperty); }
- set { SetValue(WTCornerRadiusProperty, value); }
- }
- public static readonly DependencyProperty WTCornerRadiusProperty =
- DependencyProperty.Register("WTCornerRadius", typeof(CornerRadius), typeof(WatermarkText),
- new PropertyMetadata(new CornerRadius(0), new PropertyChangedCallback(OnPropertyChanged)));
-
-
- public Brush SubForeground
- {
- get { return (Brush)GetValue(SubForegroundProperty); }
- set { SetValue(SubForegroundProperty, value); }
- }
- public static readonly DependencyProperty SubForegroundProperty =
- DependencyProperty.Register("SubForeground", typeof(Brush), typeof(WatermarkText),
- new PropertyMetadata(default(Brush), new PropertyChangedCallback(OnPropertyChanged)));
-
-
-
- private void Maintb_TextChanged(object sender, TextChangedEventArgs e)
- {
- if (Maintb.Text.Trim().Length > 0)
- Subtb.Visibility = Visibility.Collapsed;
- else
- Subtb.Visibility = Visibility.Visible;
- }
- }
- }
|