| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- 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
- {
- /// <summary>
- /// FlatToolbatTextAndImageButton.xaml 的交互逻辑
- /// </summary>
- 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
- }
- }
|