| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- using ivf_tl_Entity;
- 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;
- namespace ivf_tl_Operate.CustomUserControls
- {
- /// <summary>
- /// PhotoButton.xaml 的交互逻辑
- /// </summary>
- public partial class PhotoButton : UserControl
- {
- public PhotoButton()
- {
- InitializeComponent();
- }
- /// <summary>
- /// 筛选设置实体
- /// </summary>
- public PhotoBoxSetting PhotoBoxSetting { get; set; }
- public new double Width
- {
- get { return (double)GetValue(WidthProperty); }
- set { SetValue(WidthProperty, value); }
- }
- public static new readonly DependencyProperty WidthProperty =
- DependencyProperty.Register("Width", typeof(double), typeof(PhotoButton), new PropertyMetadata(140.0, new PropertyChangedCallback(OnWidthPropertyChangedCallback)));
- private static void OnWidthPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (!(d is PhotoButton source)) return;
- if (!(e.NewValue is double width)) return;
- source._border.Width = width;
- }
- public new double Height
- {
- get { return (double)GetValue(HeightProperty); }
- set { SetValue(HeightProperty, value); }
- }
- public static new readonly DependencyProperty HeightProperty =
- DependencyProperty.Register("Height", typeof(double), typeof(PhotoButton), new PropertyMetadata(80.0, new PropertyChangedCallback(OnHeightPropertyChangedCallback)));
- private static void OnHeightPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (!(d is PhotoButton source)) return;
- if (!(e.NewValue is double height)) return;
- source._border.Height = height;
- }
- /// <summary>
- /// 按钮内容
- /// </summary>
- public new string Content
- {
- get { return (string)GetValue(ContentProperty); }
- set { SetValue(ContentProperty, value); }
- }
- public static new readonly DependencyProperty ContentProperty =
- DependencyProperty.Register("Content", typeof(string), typeof(PhotoButton), new PropertyMetadata("", new PropertyChangedCallback(OnContentPropertyChangedCallback)));
- private static void OnContentPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (!(d is PhotoButton source)) return;
- if (!(e.NewValue is string content)) return;
- source._text.Text = content;
- }
- /// <summary>
- /// 字号
- /// </summary>
- public new double FontSize
- {
- get { return (double)GetValue(FontSizeProperty); }
- set { SetValue(FontSizeProperty, value); }
- }
- public static new readonly DependencyProperty FontSizeProperty =
- DependencyProperty.Register("FontSize", typeof(double), typeof(PhotoButton), new PropertyMetadata(33.0, new PropertyChangedCallback(OnFontSizePropertyChangedCallback)));
- private static void OnFontSizePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (!(d is PhotoButton source)) return;
- if (!(e.NewValue is double fontsize)) return;
- source._text.FontSize = fontsize;
- }
- /// <summary>
- /// 是否选中
- /// </summary>
- public bool IsSelected
- {
- get { return (bool)GetValue(IsSelectedProperty); }
- set { SetValue(IsSelectedProperty, value); }
- }
- public static readonly DependencyProperty IsSelectedProperty =
- DependencyProperty.Register("IsSelected", typeof(bool), typeof(PhotoButton), new PropertyMetadata(false, new PropertyChangedCallback(OnIsSelectedPropertyChangedCallback)));
- private static void OnIsSelectedPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (!(d is PhotoButton source)) return;
- if (!(e.NewValue is bool isSelected)) return;
- if (isSelected)
- {
- LinearGradientBrush brush = new LinearGradientBrush();
- brush.StartPoint = new Point(0, 0);
- brush.EndPoint = new Point(0, 1);
- brush.GradientStops.Add(new GradientStop(Color.FromRgb(61, 98, 148), 0.1));//蓝色
- brush.GradientStops.Add(new GradientStop(Color.FromRgb(117, 153, 204), 0.9));
- source._border.Background = brush;
- }
- else
- {
- LinearGradientBrush brush = new LinearGradientBrush();
- brush.StartPoint = new Point(0, 0);
- brush.EndPoint = new Point(0, 1);
- brush.GradientStops.Add(new GradientStop(Color.FromRgb(111, 115, 119), 0.1));//灰色
- brush.GradientStops.Add(new GradientStop(Color.FromRgb(173, 177, 182), 0.9));
- source._border.Background = brush;
- }
- }
- }
- }
|