using Microsoft.VisualBasic.CompilerServices;
using MuchInfo.Chart.Data.EnumTypes;
using MuchInfo.Chart.Data.Interfaces;
using MuchInfo.Chart.Infrastructure.Helpers;
using MuchInfo.Chart.WPF.Controls.DateScaling;
using MuchInfo.Chart.WPF.Controls.Indicator;
using MuchInfo.Chart.WPF.Controls.ValueScaling;
using MuchInfo.Chart.WPF.Primitives;
using MuchInfo.Chart.WPF.Primitives.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace MuchInfo.Chart.WPF
{
///
/// ChartPane.xaml 的交互逻辑
///
public partial class ChartPane : UserControl, IDeletable
{
#region Fields
private List _allElements;
private Border _border;
private Chart _chart;
private DateMarginSplitter _dataMarginSplitter;
private List _drawingPlots;
private IDrawingTool _drawingTool;
///
/// 鼠标按下状态
///
private bool _isMouseDown;
private List _plots;
private Rect _rect;
private ValueScaleDisplayCollection _rightScaleControl;
private ValueScaleDisplayCollection _leftScaleControl;
private ScaleLayer _scaleLayer;
private StackPanel _stackPanel;
private double _width;
private bool _isTimeSpaning = false; //是否是分时图的图表容器
#endregion Fields
#region Constructors
public ChartPane()
{
base.SizeChanged += (new SizeChangedEventHandler(this.Pane_SizeChanged));
this.AllScaleLayers = new List();
this._rightScaleControl = new ValueScaleDisplayCollection();
this._leftScaleControl = new ValueScaleDisplayCollection();
this._border = new Border();
this._stackPanel = new StackPanel();
this._width = 0.0;
this._isMouseDown = false;
this._drawingPlots = new List();
this.InitializeComponent();
btnMore.Padding = new Thickness(4.0, 1.0, 4.0, 1.0);
btnMore.BorderThickness = new Thickness(0.0);
this.Legend.Children.Remove(this.btnMore);
this._stackPanel.Orientation = Orientation.Horizontal;
_border.BorderThickness = new Thickness(1.0);
_border.BorderBrush = new SolidColorBrush(ColorHelper.DimGray);
_border.CornerRadius = new CornerRadius(3.0);
_border.Padding = new Thickness(1.0, 3.0, 1.0, 3.0);
this._border.Background = (new SolidColorBrush(Colors.Gray));
this._border.Child = (this._stackPanel);
}
public ChartPane(Chart chart)
: this()
{
this.SetChart(chart);
}
public ChartPane(Chart chart, bool isTimeSpaning)
: this()
{
this.SetChart(chart);
_isTimeSpaning = isTimeSpaning;
}
#endregion Constructors
#region Properties
#region Public Properties
///
/// 是否为分时图
///
public bool IsTimeSpaning { get { return _isTimeSpaning; } }
public List AllScaleLayers
{
get;
private set;
}
#endregion Public Properties
#region Internal Properties
///
/// Gets the right scale control.
///
internal FrameworkElement RightScaleControl
{
get
{
return this._rightScaleControl;
}
}
internal FrameworkElement LeftScaleControl
{
get
{
return this._leftScaleControl;
}
}
#endregion Internal Properties
#region Private Properties
internal bool IsPriceHistory
{
get
{
if (this.AllScaleLayers == null || !this.AllScaleLayers.Any()) return false;
//var price = from scaleLayer in AllScaleLayers
// where scaleLayer != null
// select scaleLayer.AllPlots() into plots
// where plots != null && plots.Any()
// from plot in plots
// select plot.Calculation() into calc
// where calc is PriceHistoryCalculation
// select calc;
//var first = price.FirstOrDefault() as PriceHistoryCalculation;
//if (first == null) return false;
//return first.IsFirstChart;
bool result = false;
foreach (var scaleLayer in AllScaleLayers)
{
foreach (var formula in scaleLayer.AllDisplayFormula)
{
if (formula.FormulaModel != null && formula.FormulaModel.IsMain)
{
result = formula.FormulaModel.IsMain;
break;
}
}
if (result) break;
}
return result;
}
}
#endregion Private Properties
#endregion Properties
#region Methods
#region Public Methods
///
/// 只显示第一个图表的网格
///
public void DisplayFristGrid()
{
if (this.AllScaleLayers == null || !this.AllScaleLayers.Any()) return;
for (int i = 1; i < this.AllScaleLayers.Count; i++)
{
var valueScale = this.AllScaleLayers[i].GetLeftValueScaleDisplay();
valueScale.DrawGridLines = false;
}
}
public void AddScaleLayer(ScaleLayer sl)
{
this.AllScaleLayers.Add(sl);
ValueScaleDisplay valueScaleDisplay = sl.GetRightValueScaleDisplay();
if (valueScaleDisplay != null)
{
this._rightScaleControl.AddScale(valueScaleDisplay);
}
var leftValueScaleDisplay = sl.GetLeftValueScaleDisplay();
if (leftValueScaleDisplay != null)
{
this._leftScaleControl.AddScale(leftValueScaleDisplay);
}
ValueScaleBufferAdjuster valueScaleBufferAdjuster = sl.GetRightValueScaleDisplay().GetTopAdjuster();
if (valueScaleBufferAdjuster != null)
{
valueScaleBufferAdjuster.SetValue(Canvas.LeftProperty, this.PaintArea.ActualWidth * 0.75);
valueScaleBufferAdjuster.Width = (this.PaintArea.ActualWidth * 0.25);
valueScaleBufferAdjuster.HorizontalAlignment = HorizontalAlignment.Right;
this.PaintArea.Children.Add(valueScaleBufferAdjuster);
valueScaleBufferAdjuster = sl.GetRightValueScaleDisplay().GetBottomAdjuster();
valueScaleBufferAdjuster.SetValue(Canvas.LeftProperty, this.PaintArea.ActualWidth * 0.75);
valueScaleBufferAdjuster.Width = (this.PaintArea.ActualWidth * 0.25);
valueScaleBufferAdjuster.HorizontalAlignment = HorizontalAlignment.Right;
this.PaintArea.Children.Add(valueScaleBufferAdjuster);
}
}
//public List AllScaleLayers()
//{
// return this.AllScaleLayers;
//}
//public void FromXML(XElement node)
//{
// bool flag;
// try
// {
// IEnumerator enumerator = node.Elements().GetEnumerator();
// while (enumerator.MoveNext())
// {
// XElement current = enumerator.Current;
// IXmlSavable iXMLSavable = XmlTypeCreator.MakeElement(current);
// flag = (iXMLSavable != null && iXMLSavable is ScaleLayer);
// if (flag)
// {
// this.Pane_5151((ScaleLayer)iXMLSavable);
// }
// }
// }
// finally
// {
// //IEnumerator enumerator;
// //flag = (enumerator != null);
// //if (flag)
// //{
// // enumerator.Dispose();
// //}
// }
// flag = (node.Attribute("ScaleIndex") != null);
// if (flag)
// {
// this.rightScaleControl.SelectedIndexXml = int.Parse(node.Attribute("ScaleIndex").Value);
// }
//}
public Chart GetChart()
{
return this._chart;
}
public Rect LastDrawnRect()
{
return this._rect;
}
public void OnDelete()
{
try
{
List.Enumerator enumerator = this.AllScaleLayers.GetEnumerator();
while (enumerator.MoveNext())
{
ScaleLayer current = enumerator.Current;
current.OnDelete();
}
}
finally
{
//List.Enumerator enumerator;
//enumerator.Dispose();
}
}
public string RootName()
{
return "CHARTPANE";
}
public void SetChart(Chart aChart)
{
this._chart = aChart;
}
#endregion Public Methods
#region Internal Methods
internal int AllScaleLayersCount()
{
return this.AllScaleLayers.Count;
}
///
/// 是否刷新图表
///
internal bool RefreshChartFlag { get; set; }
///
///
///
///
///
/// 是否更新数据集
internal void BuildChartPane(IDateScaler dateScale, DateScaleDisplay dateScalePlot, bool isUpdateDataSet = false)
{
this.btnRemovePane.Visibility = IsPriceHistory ? Visibility.Collapsed : Visibility.Visible;
this.Legend.Visibility = Visibility.Visible;
var list = new List();
var list2 = new List();
var height = Math.Max(this.PaintArea.ActualHeight - 6.0, 0);
var width = Math.Max((float)(this.PaintArea.ActualWidth - (double)_chart.RightBuffer), 0);
var rect = new Rect(0.0, 0.0, (double)width, (double)height);
list.Add(dateScalePlot.BuildPath(dateScale, rect, this._chart));
if (this.AllScaleLayers != null && this.AllScaleLayers.Any())
{
foreach (var current in AllScaleLayers)
{
//更新plot数据集
if (isUpdateDataSet) current.UpdatePlotsDataSource(_chart.DataSet, RefreshChartFlag);
if (_chart.DataSet != null && _chart.DataSet.DataPoints != null
&& _chart.DataSet.DataPoints.Any()
|| _chart.CycleType == CycleType.TimeSharing)
{
list.AddRange(current.BuildScaleLayer(this._chart, this, dateScale, rect));
list2.AddRange(current.GetAllPlotElements());
}
}
}
this._allElements = list;
this._plots = list2;
this._rect = rect;
this.RemoveChartPane();
//指定左边数据控件的最小宽度-随字体变化
this._leftScaleControl.MinWidth = this._chart.ChartFontSize * 3 + 10;
this._leftScaleControl.DoPending();
//指定右边数据控件的最小宽度-随字体变化
this._rightScaleControl.MinWidth = this._chart.ChartFontSize * 3 + 10;
this._rightScaleControl.DoPending();
this.UpdateDateMarginSplitter();
}
///
/// 创建分时图
///
///
///
internal void BuildTimeShareChartPane(IDateScaler dateScale, DateScaleDisplay dateScalePlot)
{
this.btnRemovePane.Visibility = Visibility.Collapsed;
this.Legend.Visibility = Visibility.Visible;
var list = new List();
var list2 = new List();
var height = Math.Max(this.PaintArea.ActualHeight - 6.0, 0); //(double)_chart.RightBuffer
var width = Math.Max((float)(this.PaintArea.ActualWidth - _chart.RightBuffer), 0);
var rect = new Rect(0.0, 0.0, (double)width, (double)height);
list.AddRange(dateScalePlot.BuilTimeSpandPath(dateScale, rect, this._chart));
if (this.AllScaleLayers != null && this.AllScaleLayers.Any())
{
foreach (var current in AllScaleLayers)
{
list.AddRange(current.BuildScaleLayer(this._chart, this, dateScale, rect));
list2.AddRange(current.GetAllPlotElements());
}
}
this._allElements = list;
this._plots = list2;
this._rect = rect;
this.RemoveChartPane();
//指定左边数据控件的最小宽度-随字体变化
this._leftScaleControl.MinWidth = this._chart.ChartFontSize * 3 + 10;
this._leftScaleControl.DoPending();
//指定右边数据控件的最小宽度-随字体变化
this._rightScaleControl.MinWidth = this._chart.ChartFontSize * 3 + 10;
this._rightScaleControl.DoPending();
this.UpdateDateMarginSplitter();
}
///
/// 获取矩形第一行真实高度
///
///
internal double GetActualHeight()
{
return this.LayoutRoot.RowDefinitions[0].ActualHeight;
}
internal ScaleLayer GetScaleLayer(int index)
{
return this.AllScaleLayers[index];
}
///
/// 处理当前图例有画线工具时执行操作
///
internal void OnDrawing()
{
if (this._chart != null && _chart.CurrentDrawingTool != null)
{
if (this.PaintArea.Cursor != Cursors.None)
{
this.PaintArea.Cursor = Cursors.None;
this.PaintArea.Background = (new SolidColorBrush(Colors.Transparent));
}
}
else
{
if (this.PaintArea.Cursor != Cursors.Arrow)
{
this.PaintArea.Cursor = Cursors.Arrow;
}
if (this.PaintArea.Background != null)
{
this.PaintArea.Background = null;
}
}
}
internal void RemoveAllScaleLayers()
{
var scalerLayers = AllScaleLayers;
if (scalerLayers == null || !scalerLayers.Any()) return;
ScaleLayer mainLayer = null;
foreach (var current in scalerLayers)
{
if (current.HasPricePlot())
{
mainLayer = current;
continue;
}
ClearScaleLayer(current);
}
this.AllScaleLayers.Clear();
if (mainLayer != null)
{
this.AllScaleLayers.Add(mainLayer);
}
}
private void ClearScaleLayer(ScaleLayer sl)
{
sl.RemoveAllPlots();
var valueScaleDisplay = sl.GetRightValueScaleDisplay();
if (valueScaleDisplay != null)
{
this.PaintArea.Children.Remove(valueScaleDisplay.GetTopAdjuster());
this.PaintArea.Children.Remove(valueScaleDisplay.GetBottomAdjuster());
this._rightScaleControl.RemoveScale(valueScaleDisplay);
}
var leftValueScaleDisplay = sl.GetLeftValueScaleDisplay();
if (leftValueScaleDisplay != null)
{
this.PaintArea.Children.Remove(leftValueScaleDisplay.GetTopAdjuster());
this.PaintArea.Children.Remove(leftValueScaleDisplay.GetBottomAdjuster());
this._leftScaleControl.RemoveScale(leftValueScaleDisplay);
}
}
internal void RemoveScaleLayer(ScaleLayer sl)
{
this.AllScaleLayers.Remove(sl);
ClearScaleLayer(sl);
var flag = (this.AllScaleLayers.Count == 0);
if (flag)
{
this._chart.RemoveChartPane(this);
}
}
internal void SimulateDrawingMouseDown(object sender, MouseButtonEventArgs e)
{
this.PaintArea_MouseLeftButtonDown(RuntimeHelpers.GetObjectValue(sender), e);
}
#endregion Internal Methods
#region Private Methods
private void btnMore_MouseEnter(object sender, MouseEventArgs e)
{
this.btnMore.Padding = new Thickness(3.0, 0.0, 3.0, 0.0);
this.btnMore.BorderThickness = new Thickness(1.0);
}
private void btnMore_MouseLeave(object sender, MouseEventArgs e)
{
this.btnMore.Padding = new Thickness(4.0, 1.0, 4.0, 1.0);
this.btnMore.BorderThickness = new Thickness(0.0);
}
private void btnMore_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
//Popup popup = PopUpManager.CreateAppOverlay();
//this.Pane_1692.Background = (new SolidColorBrush(this.parentContainer.BackColorTop));
//popup.Child = (this.Pane_1692);
//popup.IsOpen = (true);
//popup.InvalidateArrange();
//popup.UpdateLayout();
//PopUpManager.MovePopup(popup, this.btnMore, PopUpManager.eRelativePositionHoriz.eFlushLefts, PopUpManager.eRelativePositionVert.eBelow);
//MuchInfo.Chart.Utilities.Helpers.Geometry.EnsureControlInApplication(popup);
}
private void btnRemovePane_MouseEnter(object sender, MouseEventArgs e)
{
this.btnRemovePane.Background = new SolidColorBrush(Color.FromArgb(255, 50, 50, 50));
this.txtRemovePane.Foreground = new SolidColorBrush(ColorHelper.Red);
this.btnRemovePane.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 110, 110, 110));
}
private void btnRemovePane_MouseLeave(object sender, MouseEventArgs e)
{
this.btnRemovePane.Background = null;
this.txtRemovePane.Foreground = new SolidColorBrush(ColorHelper.Gray);
this.btnRemovePane.BorderBrush = new SolidColorBrush(ColorHelper.Gray);
}
private void btnRemovePane_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this._isMouseDown = true;
}
private void btnRemovePane_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (_isMouseDown)
{
this._chart.RemoveChartPane(this);
}
}
private void MoveDrawingTool(MouseEventArgs e)
{
bool flag = this._drawingTool != null;
if (flag)
{
Point position = e.GetPosition(this.PaintArea);
//加上左边纵坐标位移
position.X += this._chart.GetChartPanelOffset();
var num = (float)(this.PaintArea.ActualHeight - 6.0);
flag = (num < 0f);
if (flag)
{
num = 0f;
}
var num2 = (float)(this.PaintArea.ActualWidth - (double)this._chart.RightBuffer);
flag = (num2 < 0f);
if (flag)
{
num2 = 0f;
}
flag = (position.X < 0.0);
if (flag)
{
position.X = (0.0);
}
flag = (position.Y < 0.0);
if (flag)
{
position.Y = (0.0);
}
flag = (position.X > (double)num2);
if (flag)
{
position.X = ((double)num2);
}
flag = (position.Y > (double)num);
if (flag)
{
position.Y = ((double)num);
}
DateTime aDate = this._chart.DateScaler.OriginalDateFromX(position.X);
float aVal = this._scaleLayer.GetRightValueScaler().ValueFromPercent((float)(1.0 - position.Y / this.PaintArea.ActualHeight));
this._drawingTool.MoveSecondPoint(aDate, aVal, position);
this.UpdateDrawingPlots();
}
}
private void PaintArea_LostMouseCapture(object sender, MouseEventArgs e)
{
var symbol = this._chart.CurrentSymbol;
if (string.IsNullOrWhiteSpace(symbol)) return;
if (this._drawingTool != null && this._chart != null)
{
this._scaleLayer.AddDrawing(symbol, this._drawingTool);
IDrawingTool pane_ = this._drawingTool;
this._drawingTool = null;
this._chart.SetDrawingTool();
this._chart.Refresh();
pane_.InitDone(e);
this._chart.Refresh();
}
}
private void PaintArea_MouseEnter(object sender, MouseEventArgs e)
{
var symbol = this._chart.CurrentSymbol;
if (string.IsNullOrWhiteSpace(symbol)) return;
if (_chart.PointerType == PointerType.Drawing)
{
this.OnDrawing();
this.SetCursorImagePos(e, true);
}
else
{
this.OnDrawing();
this._chart.DrawingToolExecute();
}
}
private void PaintArea_MouseLeave(object sender, MouseEventArgs e)
{
var symbol = this._chart.CurrentSymbol;
if (string.IsNullOrWhiteSpace(symbol)) return;
this.PaintArea.Cursor = Cursors.Arrow;
this.PaintArea.Background = (null);
this.SetCursorImagePos(e, false);
}
private void PaintArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
var symbol = this._chart.CurrentSymbol;
if (string.IsNullOrWhiteSpace(symbol)) return;
try
{
bool flag = _chart.CurrentDrawingTool != null && this.AllScaleLayers.Count > 0;
if (flag)
{
this._scaleLayer = this.AllScaleLayers[0];
this._drawingTool = _chart.CurrentDrawingTool.Clone();
e.Handled = true;
this.PaintArea.CaptureMouse();
Point position = e.GetPosition(this.PaintArea);
//加上左边纵坐标位移
position.X += this._chart.GetChartPanelOffset();
DateTime aDate = this._chart.DateScaler.OriginalDateFromX(position.X);
float aVal =
this._scaleLayer.GetRightValueScaler()
.ValueFromPercent((float)(1.0 - position.Y / this.PaintArea.ActualHeight));
this._drawingTool.InitPoint(aDate, aVal, this._scaleLayer, this._rect, position);
this._drawingTool.MoveSecondPoint(aDate, aVal, position);
this.UpdateDrawingPlots();
}
}
catch (Exception ex)
{
}
}
private void PaintArea_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
var symbol = this._chart.CurrentSymbol;
if (this._drawingTool != null && !string.IsNullOrWhiteSpace(symbol) && this._chart != null)
{
this.MoveDrawingTool(e);
this._scaleLayer.AddDrawing(this._chart.CurrentSymbol, this._drawingTool);
this._drawingTool = null;
this._chart.SetDrawingTool();
this.PaintArea.ReleaseMouseCapture();
}
}
private void PaintArea_MouseMove(object sender, MouseEventArgs e)
{
var symbol = this._chart.CurrentSymbol;
if (string.IsNullOrWhiteSpace(symbol)) return;
bool flag = _chart.PointerType == PointerType.Drawing;
if (flag)
{
this.MoveDrawingTool(e);
this.SetCursorImagePos(e, true);
}
else
{
this.OnDrawing();
this._chart.DrawingToolExecute();
}
}
private void PaintArea_SizeChanged(object sender, SizeChangedEventArgs e)
{
var symbol = this._chart.CurrentSymbol;
if (string.IsNullOrWhiteSpace(symbol)) return;
foreach (var current in this.PaintArea.Children)
{
if (current is ValueScaleBufferAdjuster)
{
var valueScaleBufferAdjuster = (ValueScaleBufferAdjuster)current;
valueScaleBufferAdjuster.SetValue(Canvas.LeftProperty, this.PaintArea.ActualWidth * 0.75);
valueScaleBufferAdjuster.Width = (this.PaintArea.ActualWidth * 0.25);
}
}
}
private void Pane_SizeChanged(object sender, SizeChangedEventArgs e)
{
bool flag = this._chart != null;
if (flag && RefreshChartFlag)
{
this._chart.Refresh();
RefreshChartFlag = false;
}
}
private void RemoveChartPane()
{
var list = new List();
foreach (var current in this.PaintArea.Children)
{
var pane = current as UIElement;
if (!(pane is DateMarginSplitter) && !(pane is ValueScaleBufferAdjuster))
{
list.Add(pane);
}
}
foreach (var uiElement in list)
{
this.PaintArea.Children.Remove(uiElement);
}
if (this._allElements != null)
{
foreach (var uiElement in _allElements)
{
this.PaintArea.Children.Add(uiElement);
}
}
var flag = this.Legend.Children.Contains(this.btnMore);
if (flag)
{
this.Legend.Children.Remove(this.btnMore);
}
bool flag2 = false;
double num = this.LayoutRoot.ActualWidth - (this.colLeft.ActualWidth + this.btnMore.Width);
bool flag3;
checked
{
flag = (this._stackPanel.Children.Count + this.Legend.Children.Count != this._plots.Count);
if (flag)
{
flag2 = true;
}
else
{
flag = (this.LayoutRoot.ActualWidth != this._width);
if (flag)
{
flag2 = true;
}
else
{
try
{
int arg_248_0 = 0;
int num2 = this.Legend.Children.Count - 1;
int num3 = arg_248_0;
while (true)
{
int arg_2ED_0 = num3;
int num4 = num2;
if (arg_2ED_0 > num4)
{
goto IL_2F2;
}
flag = (num3 < this.Legend.Children.Count);
if (flag)
{
flag3 = (this.Legend.Children[num3] != this._plots[num3]);
if (flag3)
{
break;
}
}
else
{
flag3 = (this._stackPanel.Children[num3 - this.Legend.Children.Count] != this._plots[num3]);
if (flag3)
{
goto Block_27;
}
}
num3++;
}
flag2 = true;
goto IL_2F2;
Block_27:
flag2 = true;
IL_2F2: ;
}
catch (Exception expr_2F4)
{
ProjectData.SetProjectError(expr_2F4);
flag2 = true;
ProjectData.ClearProjectError();
}
}
}
flag3 = flag2;
}
if (flag3)
{
if (this._plots != null && this._plots.Any())
{
foreach (var plot in this._plots)
{
var indicatorLegend = plot as IndicatorLegend;
if (indicatorLegend == null) continue;
indicatorLegend.Abbreviate = false;
}
}
bool flag4 = false;
this.Legend.Children.Clear();
this._stackPanel.Children.Clear();
if (this._plots != null && this._plots.Any())
{
foreach (var current in this._plots)
{
this.Legend.Children.Add(current);
flag3 = (current.ActualWidth < num);
if (!flag3)
{
flag4 = true;
break;
}
num -= current.ActualWidth;
}
}
flag3 = flag4;
if (flag3)
{
this.Legend.Children.Clear();
this._stackPanel.Children.Clear();
num = this.LayoutRoot.ActualWidth - (this.colLeft.ActualWidth + this.btnMore.Width);
if (this._plots != null && this._plots.Any())
{
foreach (var current in this._plots)
{
if (current is IndicatorLegend)
{
((IndicatorLegend)current).Abbreviate = true;
}
this.Legend.Children.Add(current);
if (current.ActualWidth < num)
{
num -= current.ActualWidth;
}
else
{
this.Legend.Children.Remove(current);
if (current is IndicatorLegend)
{
((IndicatorLegend)current).Abbreviate = false;
}
num = -1.0;
this._stackPanel.Children.Add(current);
Grid grid = new Grid();
grid.Height = (4.0);
this._stackPanel.Children.Add(grid);
if (this.btnMore.Parent == null)
{
this.Legend.Children.Add(this.btnMore);
}
}
}
}
}
}
this.UpdateDrawingPlots();
this._width = this.LayoutRoot.ActualWidth;
}
private void SetCursorImagePos(MouseEventArgs e, bool Allow)
{
bool flag = Allow && this._chart != null && this._chart.CurrentDrawingTool != null;
if (flag)
{
this._chart.SetCursorImagePos(true, e);
}
else
{
flag = (this._chart != null);
if (flag)
{
this._chart.SetCursorImagePos(false, e);
}
}
}
private void UpdateDateMarginSplitter()
{
if (this.AllScaleLayers.Where(x => x.AllPlots.Where(y => y != null).Count() > 0).Count() > 0)
{
if (this._dataMarginSplitter == null)
{
this._dataMarginSplitter = new DateMarginSplitter(this.PaintArea, this._chart);
this._dataMarginSplitter.VerticalAlignment = (VerticalAlignment)(2);
this.PaintArea.Children.Add(this._dataMarginSplitter);
}
var allDateScaler = (AllDateScaler)this._chart.DateScaler;
this._dataMarginSplitter.DateMarginSplitter_2672(allDateScaler);
int indexOfLastDataDate = allDateScaler.IndexOfLastDataDate;
if (indexOfLastDataDate <= allDateScaler.EndIndex)
{
float num = allDateScaler.PercentFromIndex(indexOfLastDataDate);
double num2 = (double)allDateScaler.XforDate(allDateScaler.DateValue(indexOfLastDataDate));
num2 += (allDateScaler.DistanceBetweenDates() * 0.3);
this._dataMarginSplitter.SetValue(Canvas.LeftProperty, num2);
this._dataMarginSplitter.SetValue(Canvas.TopProperty, 0.0);
this._dataMarginSplitter.Visibility = Visibility.Visible;
this._dataMarginSplitter.Height = (Math.Max(0.0, this.PaintArea.ActualHeight - 3.0));
}
else
{
this._dataMarginSplitter.Visibility = Visibility.Collapsed;
}
}
else
{
if (this._dataMarginSplitter != null)
{
this.PaintArea.Children.Remove(this._dataMarginSplitter);
this._dataMarginSplitter = null;
}
}
}
private void UpdateDrawingPlots()
{
if (_drawingPlots != null)
{
foreach (var plot in _drawingPlots)
{
if (this.PaintArea.Children.Contains(plot))
{
this.PaintArea.Children.Remove(plot);
}
}
this._drawingPlots.Clear();
}
if (this._drawingTool != null)
{
float num = (float)(this.PaintArea.ActualHeight - 6.0);
if (num < 0f)
{
num = 0f;
}
float num2 = (float)(this.PaintArea.ActualWidth - (double)this._chart.RightBuffer);
if (num2 < 0f)
{
num2 = 0f;
}
var aRect = new Rect(0.0, 0.0, (double)num2, (double)num);
this._drawingPlots = this._drawingTool.GetPlots(this._chart, this._scaleLayer, aRect, false);
if (_drawingPlots != null)
{
foreach (var plot in _drawingPlots)
{
this.PaintArea.Children.Add(plot);
}
}
}
}
#endregion Private Methods
#endregion Methods
}
}