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