| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- 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>
- /// FlatToolbarTextButton.xaml 的交互逻辑
- /// </summary>
- public partial class FlatToolbarTextButton : UserControl
- {
- #region Fields
- private Border _seperatorBorder;
- private TextBlock _textLine2TextBlock;
- private string _toolTip;
- #endregion Fields
- #region Constructors
- public FlatToolbarTextButton()
- {
- this._toolTip = string.Empty;
- this._textLine2TextBlock = null;
- this.InitializeComponent();
- }
- #endregion Constructors
- #region Delegates
- public delegate void ClickEventHandler(MouseEventArgs e);
- #endregion Delegates
- #region Events
- public event FlatToolbarTextButton.ClickEventHandler Click;
- #endregion Events
- #region Properties
- #region Public Properties
- public Brush HighlightBrush
- {
- get
- {
- return this.theBorder.BorderBrush;
- }
- set
- {
- this.theBorder.BorderBrush = (value);
- }
- }
- public bool ShowSeperator
- {
- get
- {
- return this._seperatorBorder != null;
- }
- set
- {
- bool flag = value && this._seperatorBorder == null;
- if (flag)
- {
- this._seperatorBorder = new Border
- {
- IsHitTestVisible = (false),
- HorizontalAlignment = HorizontalAlignment.Right,
- VerticalAlignment = VerticalAlignment.Stretch,
- BorderBrush = new SolidColorBrush(ColorHelper.DarkGray),
- BorderThickness = new Thickness(1.0, 0.0, 0.0, 0.0),
- Margin = new Thickness(3.0, 4.0, 3.0, 4.0)
- };
- this._seperatorBorder.SetValue(Grid.ColumnProperty, 2);
- this.LayoutRoot.Children.Add(this._seperatorBorder);
- }
- else
- {
- flag = (!value & this._seperatorBorder != null);
- if (flag)
- {
- this.LayoutRoot.Children.Remove(this._seperatorBorder);
- this._seperatorBorder = null;
- }
- }
- }
- }
- public string Text
- {
- get
- {
- return this.theText.Text;
- }
- set
- {
- this.theText.Text = (value);
- }
- }
- public string TextLine2
- {
- get
- {
- bool flag = this._textLine2TextBlock == null;
- string result;
- if (flag)
- {
- result = "";
- }
- else
- {
- result = this._textLine2TextBlock.Text;
- }
- return result;
- }
- set
- {
- if (!string.IsNullOrWhiteSpace(value))
- {
- bool flag2 = this._textLine2TextBlock == null;
- if (flag2)
- {
- this._textLine2TextBlock = new TextBlock();
- _textLine2TextBlock.Margin = new Thickness(3.0, -2.0, 3.0, -1.0);
- this.stackText.Children.Add(this._textLine2TextBlock);
- }
- this._textLine2TextBlock.Text = value;
- }
- else
- {
- bool flag2 = this._textLine2TextBlock != null;
- if (flag2)
- {
- this.stackText.Children.Remove(this._textLine2TextBlock);
- this._textLine2TextBlock = null;
- }
- }
- }
- }
- public TextWrapping TextWrapping
- {
- get
- {
- return this.theText.TextWrapping;
- }
- set
- {
- this.theText.TextWrapping = (value);
- }
- }
- public TextBlock theTextBlock
- {
- get
- {
- return this.theText;
- }
- }
- #endregion Public Properties
- #endregion Properties
- #region Methods
- #region Protected Methods
- protected virtual void OnClick(MouseEventArgs e)
- {
- var handler = Click;
- if (handler != null) handler(e);
- }
- #endregion Protected Methods
- #region Private Methods
- private void theBorder_MouseEnter(object sender, MouseEventArgs e)
- {
- theBorder.BorderThickness = new Thickness(1.0);
- 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)
- {
- OnClick(e);
- e.Handled = (true);
- }
- private void theBorder_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
- {
- e.Handled = (true);
- }
- #endregion Private Methods
- #endregion Methods
- }
- }
|