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
{
///
/// PhotoButton.xaml 的交互逻辑
///
public partial class PhotoButton : UserControl
{
public PhotoButton()
{
InitializeComponent();
}
///
/// 筛选设置实体
///
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;
}
///
/// 按钮内容
///
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;
}
///
/// 字号
///
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;
}
///
/// 是否选中
///
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;
}
}
}
}