using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; namespace MuchInfo.Chart.Infrastructure.Controls { /// /// BorderedTextButton.xaml 的交互逻辑 /// public partial class BorderedTextButton : UserControl { #region Constructors public BorderedTextButton() { this.InitializeComponent(); } #endregion Constructors #region Delegates public delegate void ClickEventHandler(MouseEventArgs e); #endregion Delegates #region Events public event BorderedTextButton.ClickEventHandler Click; #endregion Events #region Properties #region Public Properties public Brush ButtonBackground { get { return this.borderButton.Background; } set { this.borderButton.Background = value; } } public Brush ButtonBorderBrush { get { return this.borderButton.BorderBrush; } set { this.borderButton.BorderBrush = value; } } public string Text { get { return this.theText.Text; } set { this.theText.Text = value; } } #endregion Public Properties #endregion Properties #region Methods #region Protected Methods protected virtual void OnClick(MouseEventArgs e) { ClickEventHandler handler = Click; if (handler != null) handler(e); } #endregion Protected Methods #region Private Methods private void borderButton_MouseEnter(object sender, MouseEventArgs e) { borderButton.BorderThickness = new Thickness(3.0); borderButton.Padding = new Thickness(5.0, 3.0, 5.0, 3.0); } private void borderButton_MouseLeave(object sender, MouseEventArgs e) { borderButton.BorderThickness = new Thickness(2.0); borderButton.Padding = new Thickness(6.0, 4.0, 6.0, 4.0); } private void borderButton_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { OnClick(e); } #endregion Private Methods #endregion Methods } }