Ejemplo n.º 1
0
		public Chart() : base()
		{
			this.PRRwtLFpd5 = -1;
			this.etYww3BBO8 = -1;
			this.doubleSeriesSmoothingMode = SmoothingMode.HighSpeed;
			this.pads = new PadList();
			this.minCountOfBars = 125;
			this.canvasLeftOffset = 20;
			this.canvasTopOffset = 20;
			this.canvasRightOffset = 20;
			this.canvasBottomOffset = 30;
			this.canvasColor = Color.MidnightBlue;
			this.padsHeightArray = new ArrayList();
			this.padSplitIndex = -1;
			this.contentUpdated = true;
			this.actionType = ChartActionType.None;
			this.updateStyle = ChartUpdateStyle.Trailing;
			this.minAxisGap = 50;
			this.ContextMenuEnabled = true;
			this.LabelDigitsCount = 2;
			this.rightAxesFontSize = 7;
			this.dateTipRectangleColor = Color.LightGray;
			this.dateTipTextColor = Color.Black;
			this.valTipRectangleColor = Color.LightGray;
			this.valTipTextColor = Color.Black;
			this.crossColor = Color.DarkGray;
			this.borderColor = Color.Gray;
			this.splitterColor = Color.LightGray;
			this.candleUpColor = Color.Black;
			this.candleDownColor = Color.Lime;
			this.volumeColor = Color.SteelBlue;
			this.rightAxisGridColor = Color.DimGray;
			this.rightAxisTextColor = Color.LightGray;
			this.rightAxisMinorTickColor = Color.LightGray;
			this.rightAxisMajorTicksColor = Color.LightGray;
			this.itemTextColor = Color.LightGray;
			this.selectedItemTextColor = Color.Yellow;
			this.selectedTransactionHighlightColor = Color.LightBlue;
			this.activeStopColor = Color.Yellow;
			this.executedStopColor = Color.MediumSeaGreen;
			this.canceledStopColor = Color.Gray;
			this.dataLock = new object();
			this.lastDateTime = DateTime.MaxValue;
			this.firstDateTime = DateTime.MinValue;

			this.InitializeComponent();
			this.font = new Font(this.Font.FontFamily, (float)this.rightAxesFontSize);
			this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true);
			this.UpdateStyles();
			this.canvasLeftOffset = 10;
			this.canvasTopOffset = 10;
			this.canvasRightOffset = 40;
			this.canvasBottomOffset = 40;
			this.MouseWheel += new MouseEventHandler(this.HandleMouseWheel);
			this.AddPad();
			this.axisBottom = new AxisBottom(this, this.canvasLeftOffset, this.Width - this.canvasRightOffset, this.Height - this.canvasTopOffset);
			this.hScrollBar.Minimum = 0;
			this.chartBackColor = Color.MidnightBlue;
			this.firstIndex = -1;
			this.lastIndex = -1;
		}
Ejemplo n.º 2
0
        public void PaintWithDates(DateTime minDate, DateTime maxDate)
        {
            SolidBrush solidBrush1 = new SolidBrush(this.titleColor);
            SolidBrush solidBrush2 = new SolidBrush(this.labelColor);
            Pen        pen1        = new Pen(this.titleColor);
            Pen        pen2        = new Pen(this.gridColor);
            Pen        pen3        = new Pen(this.minorGridColor);
            Pen        pen4        = new Pen(this.minorTicksColor);
            Pen        pen5        = new Pen(this.majorTicksColor);

            pen2.Width     = this.gridWidth;
            pen2.DashStyle = this.gridDashStyle;
            pen3.Width     = this.minorGridWidth;
            pen3.DashStyle = this.minorGridDashStyle;
            long      ticks1    = minDate.Ticks;
            long      ticks2    = maxDate.Ticks;
            DateTime  dateTime1 = new DateTime(Math.Max(0, ticks1));
            EGridSize gridSize  = AxisBottom.CalculateSize(ticks2 - ticks1);
            long      num1      = 0L;
            long      num2      = this.c9T0e1qB80(dateTime1, gridSize);
            int       num3      = 0;
            long      num4      = num2;
            long      num5      = 0L;
            int       num6      = 0;
            long      num7      = ticks2;
            int       num8      = -1;

            while (num4 < num7)
            {
                if (num6 != 0)
                {
                    num4 = AxisBottom.GetNextMajor(num5, gridSize);
                }
                long num9  = num4;
                int  index = this.chart.MainSeries.GetIndex(new DateTime(num4 - 1L), EIndexOption.Next);
                if (num8 == index)
                {
                    num5 = num4;
                }
                else
                {
                    num8 = index;
                    if (index != -1)
                    {
                        DateTime dateTime2 = this.chart.MainSeries.GetDateTime(index);
                        TimeSpan timeOfDay = dateTime2.TimeOfDay;
                        long     ticks3    = dateTime2.Ticks;
                        if (ticks3 < num7)
                        {
                            if (this.gridEnabled)
                            {
                                this.chart.IXrxgFKyT(pen2, ticks3);
                            }
                            if (this.majorTicksEnabled)
                            {
                                this.chart.NXKu7WiuX(pen1, ticks3, -5);
                            }
                            if (this.labelEnabled)
                            {
                                string format;
                                if (ticks3 % 864000000000L == this.chart.SessionStart.Ticks || ticks3 % 864000000000 == this.chart.SessionEnd.Ticks)
                                {
                                    format = num5 != 0 ? (new DateTime(num5).Year == new DateTime(ticks3).Year ? "years" : "month") : "days";
                                }
                                else if (num5 == 0L)
                                {
                                    format = "days";
                                }
                                else
                                {
                                    DateTime dateTime3 = new DateTime(num5);
                                    DateTime dateTime4 = new DateTime(ticks3);
                                    format = dateTime3.Year == dateTime4.Year ? (dateTime3.Month == dateTime4.Month ? (dateTime3.Day == dateTime4.Day ? (dateTime3.Minute != dateTime4.Minute || dateTime3.Hour != dateTime4.Hour ? "hour" : "minute") : "second") : "aaaa") : "bbbb";
                                }
                                string str   = new DateTime(ticks3).ToString(format);
                                SizeF  sizeF = this.chart.Graphics.MeasureString(str, this.labelFont);
                                int    num10 = (int)sizeF.Width;
                                int    num11 = (int)sizeF.Height;
                                if (this.labelAlignment == EAxisLabelAlignment.Right)
                                {
                                    this.chart.Graphics.DrawString(str, this.labelFont, (Brush)solidBrush2, (float)this.chart.ClientX(new DateTime(ticks3)), (float)(int)(this.y + (double)this.labelOffset));
                                }
                                if (this.labelAlignment == EAxisLabelAlignment.Left)
                                {
                                    this.chart.Graphics.DrawString(str, this.labelFont, (Brush)solidBrush2, (float)(this.chart.ClientX(new DateTime(ticks3)) - num10), (float)(int)(this.y + (double)this.labelOffset));
                                }
                                if (this.labelAlignment == EAxisLabelAlignment.Centre)
                                {
                                    int num12 = this.chart.ClientX(new DateTime(ticks3)) - num10 / 2;
                                    int num13 = (int)(this.y + (double)this.labelOffset);
                                    if (num6 == 0 || num12 - num3 >= 1)
                                    {
                                        this.chart.Graphics.DrawString(str, this.labelFont, solidBrush2, (float)num12, (float)num13);
                                        num3 = num12 + num10;
                                    }
                                }
                            }
                        }
                        num1 = ticks3;
                        num4 = num9;
                        num5 = num4;
                        ++num6;
                    }
                }
            }
            if (this.chart.SessionGridEnabled && (EGridSize)(this.chart.SessionEnd - this.chart.SessionStart).Ticks >= gridSize)
            {
                int  num9 = 0;
                long num10;
                for (long index = ticks1 / 864000000000L * 864000000000L + this.chart.SessionStart.Ticks; (num10 = index + (long)num9 * 864000000000L) < ticks2; ++num9)
                {
                    this.chart.pw9AQjMR6(new Pen(this.chart.SessionGridColor), num10);
                }
            }
            if (!this.titleEnabled)
            {
                return;
            }
            int    num14 = (int)this.chart.Graphics.MeasureString("", this.labelFont).Height;
            int    num15 = (int)this.chart.Graphics.MeasureString(ticks2.ToString("D"), this.labelFont).Width;
            double num16 = (double)this.chart.Graphics.MeasureString(this.title, this.titleFont).Height;
            int    num17 = (int)this.chart.Graphics.MeasureString(this.title, this.titleFont).Width;

            if (this.titlePosition == EAxisTitlePosition.Left)
            {
                this.chart.Graphics.DrawString(this.title, this.titleFont, solidBrush1, (float)(int)this.x1, (float)(int)(this.y + (double)this.labelOffset + (double)num14 + (double)this.titleOffset));
            }
            if (this.titlePosition == EAxisTitlePosition.Right)
            {
                this.chart.Graphics.DrawString(this.title, this.titleFont, solidBrush1, (float)((int)this.x2 - num17), (float)(int)(this.y + (double)this.labelOffset + (double)num14 + (double)this.titleOffset));
            }
            if (this.titlePosition != EAxisTitlePosition.Centre)
            {
                return;
            }
            this.chart.Graphics.DrawString(this.title, this.titleFont, solidBrush1, (float)(int)(this.x1 + (this.x2 - this.x1 - (double)num17) / 2.0), (float)(int)(this.y + (double)this.labelOffset + (double)num14 + (double)this.titleOffset));
        }