星火微课系统客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LineTool.cs 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System.Windows;
  2. using System.Windows.Controls;
  3. using System.Windows.Media;
  4. namespace ComeCapture.Controls
  5. {
  6. public class LineTool : StackPanel
  7. {
  8. static LineTool()
  9. {
  10. DefaultStyleKeyProperty.OverrideMetadata(typeof(LineTool), new FrameworkPropertyMetadata(typeof(LineTool)));
  11. }
  12. public LineTool()
  13. {
  14. _Current = this;
  15. }
  16. #region 属性 Current
  17. private static LineTool _Current = null;
  18. public static LineTool 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(LineTool),
  28. new PropertyMetadata(5.0, new PropertyChangedCallback(LineTool.OnLineThicknessPropertyChanged)));
  29. private static void OnLineThicknessPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
  30. {
  31. if (obj is LineTool)
  32. {
  33. (obj as LineTool).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(LineTool),
  48. new PropertyMetadata(new SolidColorBrush(Colors.Red), new PropertyChangedCallback(LineTool.OnLineBrushPropertyChanged)));
  49. private static void OnLineBrushPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
  50. {
  51. if (obj is LineTool)
  52. {
  53. (obj as LineTool).OnLineBrushValueChanged();
  54. }
  55. }
  56. protected void OnLineBrushValueChanged()
  57. {
  58. }
  59. #endregion LineBrush DependencyProperty
  60. }
  61. }