Пример #1
0
 public Pad(Chart chart, int x1, int x2, int y1, int y2)
 {
     Chart = chart;
     Axis  = new AxisRight(Chart, this, 0, 0, 0);
     SetCanvas(x1, x2, y1, y2);
     Primitives = ArrayList.Synchronized(new ArrayList());
     DrawGrid   = true;
 }
Пример #2
0
 public Pad(Chart chart, int x1, int x2, int y1, int y2)
 {
     Chart = chart;
     Axis = new AxisRight(Chart, this, 0, 0, 0);
     SetCanvas(x1, x2, y1, y2);
     Primitives = ArrayList.Synchronized(new ArrayList());
     DrawGrid = true;
 }
Пример #3
0
 public void SetCanvas(int x1, int x2, int y1, int y2)
 {
     X1          = x1 + this.marginLeft;
     X2          = x2 - this.marginRight;
     Y1          = y1;
     Y2          = y2;
     this.width  = X2 - X1;
     this.height = Y2 - Y1;
     if (Axis == null)
     {
         Axis = new AxisRight(this.chart, this, x2, y1, y2);
     }
     else
     {
         Axis.SetBounds(x2, y1, y2);
     }
 }
Пример #4
0
 public void SetCanvas(int x1, int x2, int y1, int y2)
 {
     X1 = x1 + this.marginLeft;
     X2 = x2 - this.marginRight;
     Y1 = y1;
     Y2 = y2;
     this.width = X2 - X1;
     this.height = Y2 - Y1;
     if (Axis == null)
         Axis = new AxisRight(this.chart, this, x2, y1, y2);
     else
         Axis.SetBounds(x2, y1, y2);
 }
Пример #5
0
        public void Paint()
        {
            var solidBrush1 = new SolidBrush(TitleColor);
            var solidBrush2 = new SolidBrush(LabelColor);
            Pen pen1        = new Pen(TitleColor);
            Pen pen2        = new Pen(GridColor);

            pen2.DashStyle = GridDashStyle;
            Pen pen3 = new Pen(MinorGridColor);

            pen3.DashStyle = MinorGridDashStyle;
            Pen pen4 = new Pen(MinorTicksColor);
            Pen pen5 = new Pen(MajorTicksColor);

            this.min = this.pad.MinValue;
            this.max = this.pad.MaxValue;
            int    num1 = 10;
            int    num2 = 5;
            double num3 = AxisRight.Ceiling125(Math.Abs(this.max - this.min) * 0.999999 / (double)num1);
            double num4 = AxisRight.Ceiling125(num3 / (double)num2);
            double num5 = Math.Ceiling((this.min - 0.001 * num3) / num3) * num3;
            double num6 = Math.Floor((this.max + 0.001 * num3) / num3) * num3;
            int    num7 = 0;
            int    num8 = 0;

            if (num3 != 0.0)
            {
                num7 = Math.Min(10000, (int)Math.Floor((num6 - num5) / num3 + 0.5) + 1);
            }
            if (num3 != 0.0)
            {
                num8 = Math.Abs((int)Math.Floor(num3 / num4 + 0.5)) - 1;
            }
            int num9 = 0;

            for (int index1 = 0; index1 < num7; ++index1)
            {
                double num10 = num5 + (double)index1 * num3;
                string str   = num10.ToString(this.pad.AxisLabelFormat);
                this.pad.DrawHorizontalGrid(pen2, num10);
                this.pad.DrawHorizontalTick(pen5, this.x - (double)this.majorTicksLength - 1.0, num10, this.majorTicksLength);
                if (this.labelEnabled)
                {
                    var    sizeF = this.pad.Graphics.MeasureString(str, this.labelFont);
                    double num11 = (double)sizeF.Width;
                    int    num12 = this.labelOffset;
                    int    num13 = (int)sizeF.Height;
                    if (this.labelAlignment == EAxisLabelAlignment.Centre)
                    {
                        int num14 = (int)(this.x + 2.0);
                        int num15 = this.pad.ClientY(num10) - num13 / 2;
                        if (index1 == 0 || num9 - (num15 + num13) >= 1)
                        {
                            if ((double)num15 > this.y1 && (double)(num15 + num13) < this.y2)
                            {
                                this.pad.Graphics.DrawString(str, LabelFont, solidBrush2, num14, num15);
                            }
                            num9 = num15;
                        }
                    }
                }
                for (int index2 = 1; index2 <= num8; ++index2)
                {
                    double y = num5 + (double)index1 * num3 + (double)index2 * num4;
                    if (y < this.max)
                    {
                        this.pad.DrawHorizontalTick(pen4, this.x - (double)this.minorTicksLength - 1.0, y, this.minorTicksLength);
                    }
                }
            }
            for (int index = 1; index <= num8; ++index)
            {
                double y = num5 - (double)index * num4;
                if (y > this.min && this.minorTicksEnabled)
                {
                    this.pad.DrawHorizontalTick(pen4, this.x - (double)this.minorTicksLength - 1.0, y, this.minorTicksLength);
                }
            }
            foreach (IChartDrawable chartDrawable in this.pad.Primitives)
            {
                if (chartDrawable is IAxesMarked)
                {
                    var axesMarked = chartDrawable as IAxesMarked;
                    if (axesMarked.IsMarkEnable)
                    {
                        double lastValue = axesMarked.LastValue;
                        if (!double.IsNaN(lastValue))
                        {
                            string str   = lastValue.ToString("F" + axesMarked.LabelDigitsCount.ToString());
                            SizeF  sizeF = this.chart.Graphics.MeasureString(str, this.chart.Font);
                            Color  color = Color.FromArgb((int)axesMarked.Color.R ^ 128, (int)axesMarked.Color.G ^ 128, (int)axesMarked.Color.B ^ 128);
                            if (Color.Equals(axesMarked.Color, Color.Black))
                            {
                                //    if (this.CompareColors(axesMarked.Color, Color.Black))
                                color = Color.White;
                            }
                            if (Color.Equals(axesMarked.Color, Color.White))
                            {
                                // if (this.CompareColors(axesMarked.Color, Color.White))
                                color = Color.Black;
                            }
                            this.pad.Graphics.FillRectangle((Brush) new SolidBrush(axesMarked.Color), (float)this.X, (float)((double)this.pad.ClientY(axesMarked.LastValue) - (double)sizeF.Height / 2.0 - 2.0), sizeF.Width, sizeF.Height + 2f);
                            this.pad.Graphics.DrawString(str, this.chart.RightAxesFont, (Brush) new SolidBrush(color), (float)this.X + 2f, (float)((double)this.pad.ClientY(axesMarked.LastValue) - (double)sizeF.Height / 2.0 - 1.0));
                        }
                    }
                }
            }
        }