星火微课系统客户端
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System.Windows;
  2. using System.Windows.Controls;
  3. using System.Windows.Media;
  4. namespace ComeCapture.Controls
  5. {
  6. public class RectangleTool : StackPanel
  7. {
  8. static RectangleTool()
  9. {
  10. DefaultStyleKeyProperty.OverrideMetadata(typeof(RectangleTool), new FrameworkPropertyMetadata(typeof(RectangleTool)));
  11. }
  12. public RectangleTool()
  13. {
  14. _Current = this;
  15. }
  16. #region 属性 Current
  17. private static RectangleTool _Current = null;
  18. public static RectangleTool Current => _Current;
  19. #endregion 属性 Current
  20. #region LineThickness DependencyProperty
  21. public double LineThickness
  22. {
  23. get => (double)GetValue(LineThicknessProperty);
  24. set => SetValue(LineThicknessProperty, value);
  25. }
  26. public static readonly DependencyProperty LineThicknessProperty =
  27. DependencyProperty.Register("LineThickness", typeof(double), typeof(RectangleTool),
  28. new PropertyMetadata(5.0, new PropertyChangedCallback(RectangleTool.OnLineThicknessPropertyChanged)));
  29. private static void OnLineThicknessPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
  30. {
  31. if (obj is RectangleTool)
  32. {
  33. (obj as RectangleTool).OnLineThicknessValueChanged();
  34. }
  35. }
  36. protected void OnLineThicknessValueChanged()
  37. {
  38. }
  39. #endregion LineThickness DependencyProperty
  40. #region LineBrush DependencyProperty
  41. public SolidColorBrush LineBrush
  42. {
  43. get => (SolidColorBrush)GetValue(LineBrushProperty);
  44. set => SetValue(LineBrushProperty, value);
  45. }
  46. public static readonly DependencyProperty LineBrushProperty =
  47. DependencyProperty.Register("LineBrush", typeof(SolidColorBrush), typeof(RectangleTool),
  48. new PropertyMetadata(new SolidColorBrush(Colors.Red), new PropertyChangedCallback(RectangleTool.OnLineBrushPropertyChanged)));
  49. private static void OnLineBrushPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
  50. {
  51. if (obj is RectangleTool)
  52. {
  53. (obj as RectangleTool).OnLineBrushValueChanged();
  54. }
  55. }
  56. protected void OnLineBrushValueChanged()
  57. {
  58. }
  59. #endregion LineBrush DependencyProperty
  60. }
  61. }