| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- using MuchInfo.Chart.Data.EnumTypes;
- using MuchInfo.Chart.Infrastructure.Helpers;
- using MuchInfo.Chart.WPF.Primitives.Interfaces;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Input;
- using System.Windows.Media;
- namespace MuchInfo.Chart.WPF.Controls.Drawing
- {
- /// <summary>
- /// ChartDrawingToolbarButton.xaml 的交互逻辑
- /// </summary>
- public partial class ChartDrawingToolbarButton : UserControl
- {
- #region Fields
- private bool isPressed;
- private ChartDrawingToolbar parentBar;
- #endregion Fields
- #region Constructors
- public ChartDrawingToolbarButton(ChartDrawingToolbar parent)
- {
- this.isPressed = false;
- this.DrawingTarget = null;
- this.Command = PointerType.CursorWithData;
- this.ToolTipText = string.Empty;
- this.parentBar = parent;
- this.InitializeComponent();
- this.myText.Foreground = parent.Foreground;
- }
- #endregion Constructors
- #region Properties
- #region Public Properties
- public PointerType Command
- {
- get;
- set;
- }
- public IDrawingTool DrawingTarget
- {
- get;
- set;
- }
- public DrawingToolType DrawingToolType
- {
- get;
- set;
- }
- public bool IsPressed
- {
- get
- {
- return this.isPressed;
- }
- set
- {
- bool flag = value != this.isPressed;
- if (true)
- {
- this.isPressed = value;
- if (value)
- {
- this.Border.BorderBrush = new SolidColorBrush(ColorHelper.LightGray);
- var linearGradientBrush = new LinearGradientBrush();
- var gradientStop = new GradientStop { Offset = (0.0), Color = (Color.FromArgb(255, 90, 90, 90)) };
- linearGradientBrush.GradientStops.Add(gradientStop);
- gradientStop = new GradientStop { Offset = (0.0), Color = (Color.FromArgb(255, 70, 70, 70)) };
- linearGradientBrush.GradientStops.Add(gradientStop);
- this.Border.Background = (linearGradientBrush);
- this.myText.FontSize = parentBar.ParentChart.ChartFontSize + 1;
- this.myText.Margin = new Thickness(1.0, 0.0, 0.0, 0.0);
- }
- else
- {
- this.Border.BorderBrush = (new SolidColorBrush(ColorHelper.DimGray));
- this.Border.Background = (new SolidColorBrush(Colors.Transparent));
- this.myText.FontSize = parentBar.ParentChart.ChartFontSize;
- this.myText.Margin = new Thickness(2.0, 0.0, 10.0, 0.0);
- }
- }
- }
- }
- public string LabelText
- {
- get
- {
- return this.myText.Text;
- }
- set
- {
- this.myText.Text = (value);
- if (string.IsNullOrWhiteSpace(value))
- {
- this.myText.Visibility = Visibility.Collapsed;
- }
- else
- {
- this.myText.Visibility = Visibility.Visible;
- }
- }
- }
- public string ToolTipText
- {
- get;
- set;
- }
- #endregion Public Properties
- #endregion Properties
- #region Methods
- #region Internal Methods
- /// <summary>
- /// 触发button click事件
- /// </summary>
- internal void ButtonClick()
- {
- Border_MouseLeftButtonDown(null, null);
- }
- #endregion Internal Methods
- #region Private Methods
- private void Border_MouseEnter(object sender, MouseEventArgs e)
- {
- this.Border.MinWidth = this.Border.ActualWidth;
- this.Border.BorderBrush = (new SolidColorBrush(ColorHelper.LightGray));
- this.myText.FontSize = parentBar.ParentChart.ChartFontSize + 2;
- this.myText.Margin = new Thickness(1.0, 0.0, 0.0, 0.0);
- if (!string.IsNullOrWhiteSpace(this.ToolTipText))
- {
- //ChartToolTip.ShowTip(this, e, this.ToolTip);
- }
- }
- private void Border_MouseLeave(object sender, MouseEventArgs e)
- {
- this.Border.MinWidth = (0.0);
- if (this.isPressed)
- {
- this.Border.BorderBrush = (new SolidColorBrush(ColorHelper.LightGray));
- }
- else
- {
- this.Border.BorderBrush = (new SolidColorBrush(ColorHelper.DimGray));
- this.myText.FontSize = parentBar.ParentChart.ChartFontSize;
- this.myText.Margin = new Thickness(2.0, 0.0, 10.0, 0.0);
- }
- //if (!string.IsNullOrWhiteSpace(this.ToolTipText))
- //{
- // ChartToolTip.HideTip(this);
- //}
- }
- private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- if (this.parentBar != null)
- {
- this.parentBar.ButtonSelectChanged(this);
- }
- //if (!string.IsNullOrWhiteSpace(this.ToolTipText))
- //{
- // ChartToolTip.HideTip(this);
- //}
- }
- #endregion Private Methods
- #endregion Methods
- }
- }
|