using MuchInfo.Chart.Infrastructure.Helpers; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; namespace MuchInfo.Chart.Infrastructure.Controls { /// /// FlatToolbatTextAndImageButton.xaml 的交互逻辑 /// public partial class FlatToolbatTextAndImageButton : UserControl { #region Fields private bool _enabled; private string _toolTip; #endregion Fields #region Constructors public FlatToolbatTextAndImageButton() { this._toolTip = ""; this._enabled = true; this.InitializeComponent(); } #endregion Constructors #region Delegates public delegate void ClickEventHandler(MouseEventArgs e); #endregion Delegates #region Events public event FlatToolbatTextAndImageButton.ClickEventHandler Click; #endregion Events #region Properties #region Public Properties public bool Enabled { get { return this._enabled; } set { bool flag = value != this._enabled; if (flag) { this._enabled = value; flag = this._enabled; if (flag) { this.theImage.Visibility = Visibility.Visible; this.theText.Foreground = new SolidColorBrush(Colors.Black); } else { this.theText.Foreground = new SolidColorBrush(Colors.Gray); } } } } public Brush HighlightBrush { get { return this.theBorder.BorderBrush; } set { this.theBorder.BorderBrush = value; } } public ImageSource Image { get { return this.theImage.Source; } set { this.theImage.Source = value; } } public Stretch ImageStretch { get { return this.theImage.Stretch; } set { this.theImage.Stretch = value; } } public TextAlignment Orientation { get { bool flag = this.theStack.Children[0] == this.theImage; TextAlignment result; if (flag) { result = TextAlignment.Left; } else { result = (TextAlignment)2; } return result; } set { switch (value) { case (TextAlignment)1: this.theStack.Children.Clear(); this.theStack.Children.Add(this.theImage); this.theStack.Children.Add(this.theText); break; case (TextAlignment)2: this.theStack.Children.Clear(); this.theStack.Children.Add(this.theText); this.theStack.Children.Add(this.theImage); break; } } } public bool ShowSeperator { get { return this.Seperator.Visibility == 0; } set { if (value) { this.Seperator.Visibility = Visibility.Visible; } else { this.Seperator.Visibility = Visibility.Collapsed; } } } public string Text { get { return this.theText.Text; } set { this.theText.Text = value; } } public TextBlock TheTextBlock { get { return this.theText; } } #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 theBorder_MouseEnter(object sender, MouseEventArgs e) { this.theBorder.BorderThickness = new Thickness(1.0); this.theBorder.Padding = new Thickness(0.0); //if (!string.IsNullOrWhiteSpace(_toolTip)) //{ // ChartToolTip.ShowTip(this, e, this._toolTip); //} } private void theBorder_MouseLeave(object sender, MouseEventArgs e) { theBorder.BorderThickness = new Thickness(0.0); theBorder.Padding = new Thickness(1.0); //if (!string.IsNullOrWhiteSpace(_toolTip)) //{ // ChartToolTip.HideTip(this); //} } private void theBorder_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { bool flag = this._enabled; if (flag) { OnClick(e); e.Handled = true; } } private void theBorder_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { bool flag = this._enabled; if (flag) { e.Handled = true; } } #endregion Private Methods #endregion Methods } }