using System; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using Microsoft.VisualBasic; using MuchInfo.Chart.Infrastructure.Helpers; using MuchInfo.Chart.WPF.Primitives; namespace MuchInfo.Chart.WPF.Controls.DateScaling { public partial class FutureDateSplit : UserControl { #region Fields private AllDateScaler _allDateScaler; private Canvas _canvas; private Chart _chart; private Color _color; private DateTime _endDate; private bool _flag; private bool _flag2; private float _splitPercent; private double _x; #endregion Fields #region Constructors public FutureDateSplit(Canvas aParent, Chart aChart) { this._flag = false; this._splitPercent = 0f; this._flag2 = false; this.InitializeComponent(); this._canvas = aParent; this._chart = aChart; } #endregion Constructors #region Methods #region Internal Methods internal void BuildFutureDateSplit(AllDateScaler aScaler, Color aColor, double aFontSize, bool isForex) { this._allDateScaler = aScaler; this._color = aColor; DateTime EndDateTime = this._allDateScaler.DateValue(this._allDateScaler.EndDateIndex); DateTime StartDateTime = this._allDateScaler.DateValue(this._allDateScaler.StartDateIndex); TimeSpan ts = EndDateTime - StartDateTime; if (ts.TotalMinutes > 0 && ts.TotalMinutes < 3600) { this.theLabel.Text = Strings.Format(EndDateTime, "yyyy-MM-dd"); } else if (ts.Days > 1 && ts.Days < 30) { this.theLabel.Text = Strings.Format(EndDateTime, "yyyy-MM-dd"); } else if (ts.Days > 30) { this.theLabel.Text = Strings.Format(EndDateTime, "yyyy-MM"); } this.theLabel.Foreground = (new SolidColorBrush(this._color)); this.theLabel.FontSize = aFontSize * 0.9; } #endregion Internal Methods #region Private Methods private void FutureDateSplit_2756(double inX) { double num = inX; bool flag = inX < (double)this._allDateScaler.WidthWithBarBuffer() * 0.1; if (flag) { num = (double)this._allDateScaler.WidthWithBarBuffer() * 0.1; } double num2 = num - this._x; double num3 = (double)this._allDateScaler.WidthWithBarBuffer(); flag = (num3 > 0.0); if (flag) { double num4 = -1.0 * num2 / num3; this._allDateScaler.FutureSplitPercent = (float)((double)this._splitPercent + num4); flag = (this._splitPercent != this._allDateScaler.FutureSplitPercent && DateTime.Compare(this._endDate, DateTime.MaxValue) != 0); if (flag) { bool flag2 = (double)Math.Abs(this._splitPercent - this._allDateScaler.FutureSplitPercent) > 0.2; if (flag2) { //this.FutureDateSplit_796 = this.FutureDateSplit_796; } checked { int num5 = (int)Math.Round((double)unchecked((this._allDateScaler.FutureSplitPercent - this._splitPercent) * (float)this._allDateScaler.NumBars)); flag2 = (num5 != 0); if (flag2) { int num6 = this._allDateScaler.IndexFromDate(this._endDate); num6 += num5; flag2 = (num6 >= 0 && num6 < this._allDateScaler.Count()); if (flag2) { this._allDateScaler.DesiredEndDate = this._allDateScaler.DateValue(num6); } } } } this._chart.Refresh(true); } } private void FutureEnter() { bool flag = false; if (flag) { this.arrowLeft.Fill = (new SolidColorBrush(this._color)); this.arrowRight.Fill = (new SolidColorBrush(this._color)); this.arrowLeft.Stroke = (new SolidColorBrush(ColorHelper.SteelBlue)); this.arrowRight.Stroke = (this.arrowLeft.Stroke); this.theBorder.Background = (new SolidColorBrush(ColorHelper.ColorFromString("#55AAAAAA"))); } else { this.arrowLeft.Stroke = (new SolidColorBrush(Colors.Transparent)); this.arrowRight.Stroke = (this.arrowLeft.Stroke); this.arrowLeft.Fill = (new SolidColorBrush(Color.FromArgb(100, this._color.R, this._color.G, this._color.B))); this.arrowRight.Fill = (this.arrowLeft.Fill); this.theBorder.Background = (new SolidColorBrush(Colors.Transparent)); } } private void theBorder_LostMouseCapture(object sender, MouseEventArgs e) { this._flag2 = false; this.FutureEnter(); } private void theBorder_MouseEnter(object sender, MouseEventArgs e) { if (_flag) { this.FutureEnter(); } } private void theBorder_MouseLeave(object sender, MouseEventArgs e) { this.FutureEnter(); } private void theBorder_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (_flag) { this.theBorder.CaptureMouse(); this._flag2 = true; this._x = e.GetPosition(this._canvas).X; this._splitPercent = this._allDateScaler.FutureSplitPercent; this._endDate = this._allDateScaler.DesiredEndDate; } } private void theBorder_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (_flag2) { this._flag2 = false; this.FutureDateSplit_2756(e.GetPosition(this._canvas).X); } this.theBorder.ReleaseMouseCapture(); } private void theBorder_MouseMove(object sender, MouseEventArgs e) { if (_flag2) { this.FutureDateSplit_2756(e.GetPosition(this._canvas).X); } } //private void UpdateControls() //{ // int num = this._allDateScaler.IndexOfLastDataDate; // bool flag = this._allDateScaler.EndIndex > num; // bool flag2 = this._allDateScaler.EndIndex < num; // if (flag2) // { // num = this._allDateScaler.EndIndex; // this._flag = false; // } // else // { // this._flag = true; // } // this._flag = false; // flag2 = this._flag; // if (flag2) // { // this.Cursor = (Cursors.SizeWE); // this.arrowLeft.Visibility = Visibility.Visible; // this.arrowRight.Visibility = Visibility.Visible; // this.rightArrowDef.MinWidth = 10.0; // } // else // { // this.Cursor = (Cursors.Arrow); // this.arrowLeft.Visibility = Visibility.Collapsed; // this.arrowRight.Visibility = Visibility.Collapsed; // this.rightArrowDef.MinWidth = 0.0; // } // flag2 = !flag; // if (flag2) // { // this.arrowRight.Visibility = Visibility.Collapsed; // } //} #endregion Private Methods #endregion Methods } }