星火微课系统客户端
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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. using ComeCapture.Models;
  2. using System.Windows;
  3. using System.Windows.Controls;
  4. using System.Windows.Media;
  5. namespace ComeCapture.Controls
  6. {
  7. public class ToolButton : RadioButton
  8. {
  9. static ToolButton()
  10. {
  11. DefaultStyleKeyProperty.OverrideMetadata(
  12. typeof(ToolButton),
  13. new FrameworkPropertyMetadata(typeof(ToolButton))
  14. );
  15. }
  16. #region 覆写点击事件(可弹起)
  17. protected override void OnClick()
  18. {
  19. if (IsImageEditBar)
  20. {
  21. switch (Tool)
  22. {
  23. case Tool.Revoke:
  24. JieTuWindow.Current.OnRevoke();
  25. break;
  26. case Tool.Save:
  27. JieTuWindow.Current.OnSave();
  28. break;
  29. case Tool.Cancel:
  30. JieTuWindow.Current.OnCancel();
  31. break;
  32. case Tool.OK:
  33. JieTuWindow.Current.OnOK();
  34. break;
  35. default:
  36. IsChecked = !IsChecked;
  37. SizeColorBar.Current.Selected = IsChecked == true ? Tool : Tool.Null;
  38. break;
  39. }
  40. }
  41. else
  42. {
  43. if (IsChecked == false)
  44. {
  45. IsChecked = true;
  46. if (LineColor != null)
  47. {
  48. SizeColorBar.Current.ChangeColor(LineColor);
  49. }
  50. }
  51. }
  52. }
  53. #endregion 覆写点击事件(可弹起)
  54. #region Tool DependencyProperty
  55. public Tool Tool
  56. {
  57. get => (Tool)GetValue(ToolProperty);
  58. set => SetValue(ToolProperty, value);
  59. }
  60. public static readonly DependencyProperty ToolProperty =
  61. DependencyProperty.Register("Tool", typeof(Tool), typeof(ToolButton),
  62. new PropertyMetadata(Tool.Null, new PropertyChangedCallback(ToolButton.OnToolPropertyChanged)));
  63. private static void OnToolPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
  64. {
  65. if (obj is ToolButton)
  66. {
  67. (obj as ToolButton).OnToolValueChanged();
  68. }
  69. }
  70. protected void OnToolValueChanged()
  71. {
  72. }
  73. #endregion Tool DependencyProperty
  74. #region IsImageEditBar DependencyProperty
  75. public bool IsImageEditBar
  76. {
  77. get => (bool)GetValue(IsImageEditBarProperty);
  78. set => SetValue(IsImageEditBarProperty, value);
  79. }
  80. public static readonly DependencyProperty IsImageEditBarProperty =
  81. DependencyProperty.Register("IsImageEditBar", typeof(bool), typeof(ToolButton),
  82. new PropertyMetadata(false, new PropertyChangedCallback(ToolButton.OnIsImageEditBarPropertyChanged)));
  83. private static void OnIsImageEditBarPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
  84. {
  85. if (obj is ToolButton)
  86. {
  87. (obj as ToolButton).OnIsImageEditBarValueChanged();
  88. }
  89. }
  90. protected void OnIsImageEditBarValueChanged()
  91. {
  92. }
  93. #endregion IsImageEditBar DependencyProperty
  94. #region LineColor DependencyProperty
  95. public SolidColorBrush LineColor
  96. {
  97. get => (SolidColorBrush)GetValue(LineColorProperty);
  98. set => SetValue(LineColorProperty, value);
  99. }
  100. public static readonly DependencyProperty LineColorProperty =
  101. DependencyProperty.Register("LineColor", typeof(SolidColorBrush), typeof(ToolButton),
  102. new PropertyMetadata(null, new PropertyChangedCallback(ToolButton.OnLineColorPropertyChanged)));
  103. private static void OnLineColorPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
  104. {
  105. if (obj is ToolButton)
  106. {
  107. (obj as ToolButton).OnLineColorValueChanged();
  108. }
  109. }
  110. protected void OnLineColorValueChanged()
  111. {
  112. }
  113. #endregion LineColor DependencyProperty
  114. }
  115. }