|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- 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 BPASmartClient.CustomResource.UserControls
- {
- /// <summary>
- /// BeveledButton.xaml 的交互逻辑
- /// </summary>
- public partial class BeveledButton : UserControl
- {
- public BeveledButton()
- {
- InitializeComponent();
- }
-
- public static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- (d as BeveledButton).Refresh();
- }
-
- /// <summary>
- /// 依赖属性更改的委托
- /// </summary>
- private void Refresh()
- {
- this.poly.Fill = FillColor;
- this.poly.StrokeThickness = StrokeThickness;
- this.poly.Stroke = Stroke;
- }
-
- #region FillColor:填充颜色 依赖属性
- /// <summary>
- /// 填充颜色
- /// </summary>
- public Brush FillColor
- {
- get { return (Brush)GetValue(FillColorProperty); }
- set { SetValue(FillColorProperty, value); }
- }
- public static readonly DependencyProperty FillColorProperty =
- DependencyProperty.Register("FillColor", typeof(Brush), typeof(BeveledButton),
- new PropertyMetadata(default(Brush), new PropertyChangedCallback(OnPropertyChanged)));
- #endregion
-
- #region 外边线宽度
- /// <summary>
- /// 外边线宽度
- /// </summary>
- public int StrokeThickness
- {
- get { return (int)GetValue(StrokeThicknessProperty); }
- set { SetValue(StrokeThicknessProperty, value); }
- }
- public static readonly DependencyProperty StrokeThicknessProperty =
- DependencyProperty.Register("StrokeThickness", typeof(int), typeof(BeveledButton),
- new PropertyMetadata(0, new PropertyChangedCallback(OnPropertyChanged)));
- #endregion
-
- #region 外边框颜色
- /// <summary>
- /// 外边框颜色
- /// </summary>
- public Brush Stroke
- {
- get { return (Brush)GetValue(StrokeProperty); }
- set { SetValue(StrokeProperty, value); }
- }
- public static readonly DependencyProperty StrokeProperty =
- DependencyProperty.Register("Stroke", typeof(Brush), typeof(BeveledButton),
- new PropertyMetadata(default(Brush), new PropertyChangedCallback(OnPropertyChanged)));
- #endregion
-
- #region 输入文本
-
- public string Text
- {
- get { return (string)GetValue(TextProperty); }
- set { SetValue(TextProperty, value); }
- }
- public static readonly DependencyProperty TextProperty =
- DependencyProperty.Register("Text", typeof(string), typeof(BeveledButton),
- new PropertyMetadata(string.Empty, new PropertyChangedCallback(OnPropertyChanged)));
-
- #endregion
-
-
- #region 设置是否是平行四边形
- public bool IsParallelogram
- {
- get { return (bool)GetValue(IsParallelogramProperty); }
- set { SetValue(IsParallelogramProperty, value); }
- }
- public static readonly DependencyProperty IsParallelogramProperty =
- DependencyProperty.Register("IsParallelogram", typeof(bool), typeof(BeveledButton),
- new PropertyMetadata(false, new PropertyChangedCallback(OnPropertyChanged)));
- #endregion
-
-
-
- private void Canvas_SizeChanged(object sender, SizeChangedEventArgs e)
- {
- PointCollection points = new PointCollection();
- points.Add(new Point(0, 0));
- points.Add(new Point(e.NewSize.Width - (e.NewSize.Height / 2), 0));
- points.Add(new Point(e.NewSize.Width, e.NewSize.Height));
- points.Add(new Point(IsParallelogram ? (e.NewSize.Height / 2) : 0, e.NewSize.Height));
- this.poly.Points = points;
- //this.tb.Text = Text;
- }
- }
- }
|