BorderedTextButton.xaml.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using System.Windows;
  2. using System.Windows.Controls;
  3. using System.Windows.Input;
  4. using System.Windows.Media;
  5. namespace MuchInfo.Chart.Infrastructure.Controls
  6. {
  7. /// <summary>
  8. /// BorderedTextButton.xaml 的交互逻辑
  9. /// </summary>
  10. public partial class BorderedTextButton : UserControl
  11. {
  12. #region Constructors
  13. public BorderedTextButton()
  14. {
  15. this.InitializeComponent();
  16. }
  17. #endregion Constructors
  18. #region Delegates
  19. public delegate void ClickEventHandler(MouseEventArgs e);
  20. #endregion Delegates
  21. #region Events
  22. public event BorderedTextButton.ClickEventHandler Click;
  23. #endregion Events
  24. #region Properties
  25. #region Public Properties
  26. public Brush ButtonBackground
  27. {
  28. get
  29. {
  30. return this.borderButton.Background;
  31. }
  32. set
  33. {
  34. this.borderButton.Background = value;
  35. }
  36. }
  37. public Brush ButtonBorderBrush
  38. {
  39. get
  40. {
  41. return this.borderButton.BorderBrush;
  42. }
  43. set
  44. {
  45. this.borderButton.BorderBrush = value;
  46. }
  47. }
  48. public string Text
  49. {
  50. get
  51. {
  52. return this.theText.Text;
  53. }
  54. set
  55. {
  56. this.theText.Text = value;
  57. }
  58. }
  59. #endregion Public Properties
  60. #endregion Properties
  61. #region Methods
  62. #region Protected Methods
  63. protected virtual void OnClick(MouseEventArgs e)
  64. {
  65. ClickEventHandler handler = Click;
  66. if (handler != null) handler(e);
  67. }
  68. #endregion Protected Methods
  69. #region Private Methods
  70. private void borderButton_MouseEnter(object sender, MouseEventArgs e)
  71. {
  72. borderButton.BorderThickness = new Thickness(3.0);
  73. borderButton.Padding = new Thickness(5.0, 3.0, 5.0, 3.0);
  74. }
  75. private void borderButton_MouseLeave(object sender, MouseEventArgs e)
  76. {
  77. borderButton.BorderThickness = new Thickness(2.0);
  78. borderButton.Padding = new Thickness(6.0, 4.0, 6.0, 4.0);
  79. }
  80. private void borderButton_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  81. {
  82. OnClick(e);
  83. }
  84. #endregion Private Methods
  85. #endregion Methods
  86. }
  87. }