Ejemplo n.º 1
0
        public Chart()
        {
            this.components = new System.ComponentModel.Container();
            InitializeComponent();
            #if XWT || GTK
            #else
            this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true);
            this.UpdateStyles();
            #endif
            this.pads            = new PadList();
            this.canvasColor     = Color.MidnightBlue;
            this.padsHeightArray = new ArrayList();

            this.canvasLeftOffset   = 40; // 10
            this.canvasTopOffset    = 40; // 10
            this.canvasRightOffset  = 40;
            this.canvasBottomOffset = 40;

            this.chartBackColor = Color.MidnightBlue;
            bool contentUpdated = true;
            // Should have a default pad.
            AddPad();
            this.axisBottom = new AxisBottom(this, this.canvasLeftOffset, this.Width - this.canvasRightOffset, this.Height - this.canvasTopOffset);
            this.mouseX     = this.mouseY = -1;
        }
Ejemplo n.º 2
0
 public Chart()
 {
     InitializeComponent();
     RightAxesFont = new Font(Font.FontFamily, this.rightAxesFontSize);
     this.canvasLeftOffset = 10;
     this.canvasTopOffset = 10;
     this.canvasRightOffset = 40;
     this.canvasBottomOffset = 40;
     AddPad();
     this.axisBottom = new AxisBottom(this, this.canvasLeftOffset, this.Width - this.canvasRightOffset, this.Height - this.canvasTopOffset);
     this.chartBackColor = Color.MidnightBlue;
     this.firstIndex = -1;
     this.lastIndex = -1;
 }
Ejemplo n.º 3
0
        //TODO: rewrite it!
        public void PaintWithDates(DateTime minDate, DateTime maxDate)
        {
            var solidBrush1 = new SolidBrush(TitleColor);
            var solidBrush2 = new SolidBrush(LabelColor);
            var Pen1        = new Pen(this.titleColor);
            var Pen2        = new Pen(this.gridColor);
            var pen1        = new Pen(this.minorGridColor);
            var pen2        = new Pen(this.minorTicksColor);
            var pen3        = new Pen(this.majorTicksColor);

            Pen2.Width     = this.gridWidth;
            Pen2.DashStyle = this.gridDashStyle;
            pen1.Width     = this.minorGridWidth;
            pen1.DashStyle = this.minorGridDashStyle;
            long      ticks1       = minDate.Ticks;
            long      ticks2       = maxDate.Ticks;
            DateTime  dateTime1    = new DateTime(Math.Max(0L, ticks1));
            EGridSize egridSize    = AxisBottom.CalculateSize((double)(ticks2 - ticks1));
            long      num1         = 0L;
            long      gridDivision = this.GetGridDivision(dateTime1, egridSize);
            int       num2         = 0;
            long      num3         = gridDivision;
            long      num4         = 0L;
            int       num5         = 0;
            long      num6         = ticks2;
            int       num7         = -1;

            while (num3 < num6)
            {
                if (num5 != 0)
                {
                    num3 = AxisBottom.GetNextMajor(num4, egridSize);
                }
                long num8  = num3;
                int  index = this.chart.MainSeries.GetIndex(new DateTime(num3 - 1L), IndexOption.Next);
                if (num7 == index)
                {
                    num4 = num3;
                }
                else
                {
                    num7 = index;
                    if (index != -1)
                    {
                        DateTime dateTime2 = this.chart.MainSeries.GetDateTime(index);
                        TimeSpan timeOfDay = dateTime2.TimeOfDay;
                        long     ticks3    = dateTime2.Ticks;
                        if (ticks3 < num6)
                        {
                            if (this.gridEnabled)
                            {
                                this.chart.DrawVerticalGrid(Pen2, ticks3);
                            }
                            if (this.majorTicksEnabled)
                            {
                                this.chart.DrawVerticalTick(Pen1, ticks3, -5);
                            }
                            if (this.labelEnabled)
                            {
                                string format;
                                if (ticks3 % 864000000000L == this.chart.SessionStart.Ticks || ticks3 % 864000000000L == this.chart.SessionEnd.Ticks)
                                {
                                    format = num4 != 0L ? (new DateTime(num4).Year == new DateTime(ticks3).Year ? "MMM dd" : "yyyy MMM dd") : "yyy MMM dd";
                                }
                                else if (num4 == 0L)
                                {
                                    format = "yyy MMM dd HH:mm";
                                }
                                else
                                {
                                    DateTime dateTime3 = new DateTime(num4);
                                    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 ? "HH:mm" : "HH:mm:ss") : "MMM dd HH:mm") : "MMM dd HH:mm") : "yyy MMM dd HH:mm";
                                }
                                string str   = new DateTime(ticks3).ToString(format);
                                SizeF  sizeF = this.chart.Graphics.MeasureString(str, this.labelFont);
                                int    num9  = (int)sizeF.Width;
                                int    num10 = (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)) - num9), (float)(int)(this.y + (double)this.labelOffset));
                                }
                                if (this.labelAlignment == EAxisLabelAlignment.Centre)
                                {
                                    int num11 = this.chart.ClientX(new DateTime(ticks3)) - num9 / 2;
                                    int num12 = (int)(this.y + (double)this.labelOffset);
                                    if (num5 == 0 || num11 - num2 >= 1)
                                    {
                                        this.chart.Graphics.DrawString(str, this.labelFont, (Brush)solidBrush2, (float)num11, (float)num12);
                                        num2 = num11 + num9;
                                    }
                                }
                            }
                        }
                        num1 = ticks3;
                        num3 = num8;
                        num4 = num3;
                        ++num5;
                    }
                }
            }
            if (this.chart.SessionGridEnabled && (EGridSize)(this.chart.SessionEnd - this.chart.SessionStart).Ticks >= egridSize)
            {
                int  num8 = 0;
                long X;
                for (long index = ticks1 / 864000000000L * 864000000000L + this.chart.SessionStart.Ticks; (X = index + (long)num8 * 864000000000L) < ticks2; ++num8)
                {
                    this.chart.DrawSessionGrid(new Pen(this.chart.SessionGridColor), X);
                }
            }
            if (!this.titleEnabled)
            {
                return;
            }
            int    num13 = (int)this.chart.Graphics.MeasureString("Example", this.labelFont).Height;
            int    num14 = (int)this.chart.Graphics.MeasureString(ticks2.ToString("F1"), this.labelFont).Width;
            double num15 = (double)this.chart.Graphics.MeasureString(this.title, this.titleFont).Height;
            int    num16 = (int)this.chart.Graphics.MeasureString(this.title, this.titleFont).Width;

            if (this.titlePosition == EAxisTitlePosition.Left)
            {
                this.chart.Graphics.DrawString(this.title, this.titleFont, (Brush)solidBrush1, (float)(int)this.x1, (float)(int)(this.y + (double)this.labelOffset + (double)num13 + (double)this.titleOffset));
            }
            if (this.titlePosition == EAxisTitlePosition.Right)
            {
                this.chart.Graphics.DrawString(this.title, this.titleFont, (Brush)solidBrush1, (float)((int)this.x2 - num16), (float)(int)(this.y + (double)this.labelOffset + (double)num13 + (double)this.titleOffset));
            }
            if (this.titlePosition != EAxisTitlePosition.Centre)
            {
                return;
            }
            this.chart.Graphics.DrawString(this.title, this.titleFont, (Brush)solidBrush1, (float)(int)(this.x1 + (this.x2 - this.x1 - (double)num16) / 2.0), (float)(int)(this.y + (double)this.labelOffset + (double)num13 + (double)this.titleOffset));
        }
Ejemplo n.º 4
0
        public Chart()
        {
            this.components = new System.ComponentModel.Container();
            InitializeComponent();
            #if XWT || GTK
            #else
            this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true);
            this.UpdateStyles();
            #endif
            this.pads = new PadList();
            this.canvasColor = Color.MidnightBlue;
            this.padsHeightArray = new ArrayList();

            this.canvasLeftOffset = 40; // 10
            this.canvasTopOffset = 40; // 10
            this.canvasRightOffset = 40;
            this.canvasBottomOffset = 40;

            this.chartBackColor = Color.MidnightBlue;
            bool contentUpdated = true;
            // Should have a default pad.
            AddPad();
            this.axisBottom = new AxisBottom(this, this.canvasLeftOffset, this.Width - this.canvasRightOffset, this.Height - this.canvasTopOffset);
            this.mouseX = this.mouseY = -1;
        }