终端一体化运控平台
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Quadrilateral.xaml.cs 3.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. namespace BPASmartClient.CustomResource.UserControls
  16. {
  17. /// <summary>
  18. /// Quadrilateral.xaml 的交互逻辑
  19. /// </summary>
  20. public partial class Quadrilateral : UserControl
  21. {
  22. public Quadrilateral()
  23. {
  24. InitializeComponent();
  25. }
  26. public static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  27. {
  28. (d as Quadrilateral).Refresh();
  29. }
  30. /// <summary>
  31. /// 依赖属性更改的委托
  32. /// </summary>
  33. private void Refresh()
  34. {
  35. this.poly.Fill = FillColor;
  36. this.poly.StrokeThickness = StrokeThickness;
  37. this.poly.Stroke = Stroke;
  38. }
  39. #region FillColor:填充颜色 依赖属性
  40. /// <summary>
  41. /// 填充颜色
  42. /// </summary>
  43. public Brush FillColor
  44. {
  45. get { return (Brush)GetValue(FillColorProperty); }
  46. set { SetValue(FillColorProperty, value); }
  47. }
  48. public static readonly DependencyProperty FillColorProperty =
  49. DependencyProperty.Register("FillColor", typeof(Brush), typeof(Quadrilateral),
  50. new PropertyMetadata(default(Brush), new PropertyChangedCallback(OnPropertyChanged)));
  51. #endregion
  52. #region 外边线宽度
  53. /// <summary>
  54. /// 外边线宽度
  55. /// </summary>
  56. public int StrokeThickness
  57. {
  58. get { return (int)GetValue(StrokeThicknessProperty); }
  59. set { SetValue(StrokeThicknessProperty, value); }
  60. }
  61. public static readonly DependencyProperty StrokeThicknessProperty =
  62. DependencyProperty.Register("StrokeThickness", typeof(int), typeof(Quadrilateral),
  63. new PropertyMetadata(0, new PropertyChangedCallback(OnPropertyChanged)));
  64. #endregion
  65. #region 外边框颜色
  66. /// <summary>
  67. /// 外边框颜色
  68. /// </summary>
  69. public Brush Stroke
  70. {
  71. get { return (Brush)GetValue(StrokeProperty); }
  72. set { SetValue(StrokeProperty, value); }
  73. }
  74. public static readonly DependencyProperty StrokeProperty =
  75. DependencyProperty.Register("Stroke", typeof(Brush), typeof(Quadrilateral),
  76. new PropertyMetadata(default(Brush), new PropertyChangedCallback(OnPropertyChanged)));
  77. #endregion
  78. private void Canvas_SizeChanged(object sender, SizeChangedEventArgs e)
  79. {
  80. PointCollection points = new PointCollection();
  81. points.Add(new Point(0, 0));
  82. points.Add(new Point(e.NewSize.Width - (e.NewSize.Height / 2), 0));
  83. points.Add(new Point(e.NewSize.Width, e.NewSize.Height));
  84. points.Add(new Point(e.NewSize.Height / 2, e.NewSize.Height));
  85. this.poly.Points = points;
  86. }
  87. }
  88. }