123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370 |
- 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 PDF_Office.CustomControl
- {
- public class PathButton : Button
- {
- static PathButton()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(PathButton), new FrameworkPropertyMetadata(typeof(PathButton)));
- }
- public override void OnApplyTemplate()
- {
- base.OnApplyTemplate();
- if (this.MouseOverBackground == null)
- {
- this.MouseOverBackground = Background;
- }
- if (this.MouseDownBackground == null)
- {
- if (this.MouseOverBackground == null)
- {
- this.MouseDownBackground = Background;
- }
- else
- {
- this.MouseDownBackground = MouseOverBackground;
- }
- }
- if (this.MouseOverBorderBrush == null)
- {
- this.MouseOverBorderBrush = BorderBrush;
- }
- if (this.MouseDownBorderBrush == null)
- {
- if (this.MouseOverBorderBrush == null)
- {
- this.MouseDownBorderBrush = BorderBrush;
- }
- else
- {
- this.MouseDownBorderBrush = MouseOverBorderBrush;
- }
- }
- if (this.MouseOverForeground == null)
- {
- this.MouseOverForeground = Foreground;
- }
- if (this.MouseDownForeground == null)
- {
- if (this.MouseOverForeground == null)
- {
- this.MouseDownForeground = Foreground;
- }
- else
- {
- this.MouseDownForeground = this.MouseOverForeground;
- }
- }
- if (this.IconChecked == null)
- {
- if (this.IconPress == null)
- {
- this.IconChecked = Icon;
- }
- else
- {
- this.IconChecked = this.IconPress;
- }
- }
- if (this.IconCheckedFill == null)
- {
- if (this.IconPressFill == null)
- {
- this.IconCheckedFill = IconFill;
- }
- else
- {
- this.IconCheckedFill = this.IconPressFill;
- }
- }
- }
- #region 依赖项属性
- /// <summary>
- /// 鼠标移上去的背景颜色
- /// </summary>
- public static readonly DependencyProperty MouseOverBackgroundProperty
- = DependencyProperty.Register("MouseOverBackground", typeof(Brush), typeof(PathButton));
- /// <summary>
- /// 鼠标按下去的背景颜色
- /// </summary>
- public static readonly DependencyProperty MouseDownBackgroundProperty
- = DependencyProperty.Register("MouseDownBackground", typeof(Brush), typeof(PathButton));
- /// <summary>
- /// 鼠标移上去的字体颜色
- /// </summary>
- public static readonly DependencyProperty MouseOverForegroundProperty
- = DependencyProperty.Register("MouseOverForeground", typeof(Brush), typeof(PathButton), new PropertyMetadata(null, null));
- /// <summary>
- /// 鼠标按下去的字体颜色
- /// </summary>
- public static readonly DependencyProperty MouseDownForegroundProperty
- = DependencyProperty.Register("MouseDownForeground", typeof(Brush), typeof(PathButton), new PropertyMetadata(null, null));
- /// <summary>
- /// 鼠标移上去的边框颜色
- /// </summary>
- public static readonly DependencyProperty MouseOverBorderBrushProperty
- = DependencyProperty.Register("MouseOverBorderBrush", typeof(Brush), typeof(PathButton), new PropertyMetadata(null, null));
- /// <summary>
- /// 鼠标按下去的边框颜色
- /// </summary>
- public static readonly DependencyProperty MouseDownBorderBrushProperty
- = DependencyProperty.Register("MouseDownBorderBrush", typeof(Brush), typeof(PathButton), new PropertyMetadata(null, null));
- /// <summary>
- /// 圆角
- /// </summary>
- public static readonly DependencyProperty CornerRadiusProperty
- = DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(PathButton), null);
- //图标
- public static readonly DependencyProperty IconProperty
- = DependencyProperty.Register("Icon", typeof(Geometry), typeof(PathButton), null);
- //图标填充色
- public static readonly DependencyProperty IconFillProperty
- = DependencyProperty.Register("IconFill", typeof(Brush), typeof(PathButton), null);
- //图标透明度
- public static readonly DependencyProperty IconOpacityProperty
- = DependencyProperty.Register("IconOpacity", typeof(double), typeof(PathButton), null);
- //按钮是否被选中
- public static readonly DependencyProperty IsCheckedProperty
- = DependencyProperty.Register("IsChecked", typeof(bool), typeof(PathButton), null);
- //选中的图标
- public static readonly DependencyProperty IconCheckedProperty
- = DependencyProperty.Register("IconChecked", typeof(Geometry), typeof(PathButton), null);
- //鼠标移上去的图标填充色
- public static readonly DependencyProperty IconCheckedFillProperty
- = DependencyProperty.Register("IconCheckedFill", typeof(Brush), typeof(PathButton), null);
- //鼠标移上去的透明度
- public static readonly DependencyProperty IconCheckedOpacityProperty
- = DependencyProperty.Register("IconCheckedOpacity", typeof(double), typeof(PathButton), null);
- //鼠标移上去的图标
- public static readonly DependencyProperty IconMouseOverProperty
- = DependencyProperty.Register("IconMouseOver", typeof(Geometry), typeof(PathButton), null);
- //鼠标移上去的图标填充色
- public static readonly DependencyProperty IconMouseOverFillProperty
- = DependencyProperty.Register("IconMouseOverFill", typeof(Brush), typeof(PathButton), null);
- //鼠标移上去的透明度
- public static readonly DependencyProperty IconMouseOverOpacityProperty
- = DependencyProperty.Register("IconMouseOverOpacity", typeof(double), typeof(PathButton), null);
- //鼠标按下去的图标
- public static readonly DependencyProperty IconPressProperty
- = DependencyProperty.Register("IconPress", typeof(Geometry), typeof(PathButton), null);
- //鼠标按下去的图标填充色
- public static readonly DependencyProperty IconPressFillProperty
- = DependencyProperty.Register("IconPressFill", typeof(Brush), typeof(PathButton), null);
- //鼠标按下去的透明度
- public static readonly DependencyProperty IconPressOpacityProperty
- = DependencyProperty.Register("IconPressOpacity", typeof(double), typeof(PathButton), null);
- //图标高度
- public static readonly DependencyProperty IconHeightProperty
- = DependencyProperty.Register("IconHeight", typeof(double), typeof(PathButton), new PropertyMetadata(24.0, null));
- //图标宽度
- public static readonly DependencyProperty IconWidthProperty
- = DependencyProperty.Register("IconWidth", typeof(double), typeof(PathButton), new PropertyMetadata(24.0, null));
- //图标和内容的对齐方式
- public static readonly DependencyProperty IconContentOrientationProperty
- = DependencyProperty.Register("IconContentOrientation", typeof(Orientation), typeof(PathButton), new PropertyMetadata(Orientation.Horizontal, null));
- //图标和内容的距离
- public static readonly DependencyProperty IconContentMarginProperty
- = DependencyProperty.Register("IconContentMargin", typeof(Thickness), typeof(PathButton), new PropertyMetadata(new Thickness(0, 0, 0, 0), null));
- #endregion
- #region 属性包装
- public Brush MouseOverBackground
- {
- get
- {
- return (Brush)GetValue(MouseOverBackgroundProperty);
- }
- set { SetValue(MouseOverBackgroundProperty, value); }
- }
- public Brush MouseDownBackground
- {
- get
- {
- return (Brush)GetValue(MouseDownBackgroundProperty);
- }
- set { SetValue(MouseDownBackgroundProperty, value); }
- }
- public Brush MouseOverForeground
- {
- get
- {
- return (Brush)GetValue(MouseOverForegroundProperty);
- }
- set { SetValue(MouseOverForegroundProperty, value); }
- }
- public Brush MouseDownForeground
- {
- get
- {
- return (Brush)GetValue(MouseDownForegroundProperty);
- }
- set { SetValue(MouseDownForegroundProperty, value); }
- }
- public Brush MouseOverBorderBrush
- {
- get { return (Brush)GetValue(MouseOverBorderBrushProperty); }
- set { SetValue(MouseOverBorderBrushProperty, value); }
- }
- public Brush MouseDownBorderBrush
- {
- get { return (Brush)GetValue(MouseDownBorderBrushProperty); }
- set { SetValue(MouseDownBorderBrushProperty, value); }
- }
- public CornerRadius CornerRadius
- {
- get { return (CornerRadius)GetValue(CornerRadiusProperty); }
- set { SetValue(CornerRadiusProperty, value); }
- }
- public Geometry Icon
- {
- get { return (Geometry)GetValue(IconProperty); }
- set { SetValue(IconProperty, value); }
- }
- public Brush IconFill
- {
- get { return (Brush)GetValue(IconFillProperty); }
- set { SetValue(IconFillProperty, value); }
- }
- public double IconOpacity
- {
- get { return (double)GetValue(IconOpacityProperty); }
- set { SetValue(IconOpacityProperty, value); }
- }
- public bool IsChecked
- {
- get { return (bool)GetValue(IsCheckedProperty); }
- set { SetValue(IsCheckedProperty, value); }
- }
- public Geometry IconChecked
- {
- get { return (Geometry)GetValue(IconCheckedProperty); }
- set { SetValue(IconCheckedProperty, value); }
- }
- public Brush IconCheckedFill
- {
- get { return (Brush)GetValue(IconCheckedFillProperty); }
- set { SetValue(IconCheckedFillProperty, value); }
- }
- public double IconCheckedOpacity
- {
- get { return (double)GetValue(IconCheckedOpacityProperty); }
- set { SetValue(IconCheckedOpacityProperty, value); }
- }
- public Geometry IconMouseOver
- {
- get { return (Geometry)GetValue(IconMouseOverProperty); }
- set { SetValue(IconMouseOverProperty, value); }
- }
- public Brush IconMouseOverFill
- {
- get { return (Brush)GetValue(IconMouseOverProperty); }
- set { SetValue(IconMouseOverProperty, value); }
- }
- public double IconMouseOverOpacity
- {
- get { return (double)GetValue(IconMouseOverProperty); }
- set { SetValue(IconMouseOverProperty, value); }
- }
- public Geometry IconPress
- {
- get { return (Geometry)GetValue(IconPressProperty); }
- set { SetValue(IconPressProperty, value); }
- }
- public Brush IconPressFill
- {
- get { return (Brush)GetValue(IconPressFillProperty); }
- set { SetValue(IconPressFillProperty, value); }
- }
- public double IconPressOpacity
- {
- get { return (double)GetValue(IconPressOpacityProperty); }
- set { SetValue(IconPressOpacityProperty, value); }
- }
- public double IconHeight
- {
- get { return (double)GetValue(IconHeightProperty); }
- set { SetValue(IconHeightProperty, value); }
- }
- public double IconWidth
- {
- get { return (double)GetValue(IconWidthProperty); }
- set { SetValue(IconWidthProperty, value); }
- }
- public Orientation IconContentOrientation
- {
- get { return (Orientation)GetValue(IconContentOrientationProperty); }
- set { SetValue(IconContentOrientationProperty, value); }
- }
- public Thickness IconContentMargin
- {
- get { return (Thickness)GetValue(IconContentMarginProperty); }
- set { SetValue(IconContentMarginProperty, value); }
- }
- #endregion
- }
- }
|