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
{
///
/// ChartDrawingToolbarButton.xaml 的交互逻辑
///
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
///
/// 触发button click事件
///
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
}
}