private void SetAxisSegmentPosition(AxisScaleSegmentCollection axisSegments)
        {
            int num = 0;

            foreach (AxisScaleSegment axisSegment in axisSegments)
            {
                if (axisSegment.Tag is int)
                {
                    num += (int)axisSegment.Tag;
                }
            }
            double num2 = Math.Min(minSegmentSize, Math.Floor(100.0 / (double)axisSegments.Count));
            double num3 = 0.0;

            for (int i = 0; i < axisSegments.Count; i++)
            {
                axisSegments[i].Position = ((num3 > 100.0) ? 100.0 : num3);
                axisSegments[i].Size     = Math.Round((double)(int)axisSegments[i].Tag / ((double)num / 100.0), 5);
                if (axisSegments[i].Size < num2)
                {
                    axisSegments[i].Size = num2;
                }
                if (i < axisSegments.Count - 1)
                {
                    axisSegments[i].Spacing = segmentSpacing;
                }
                num3 += axisSegments[i].Size;
            }
            double num4 = 0.0;

            do
            {
                num4 = 0.0;
                double num5 = double.MinValue;
                int    num6 = -1;
                for (int j = 0; j < axisSegments.Count; j++)
                {
                    num4 += axisSegments[j].Size;
                    if (axisSegments[j].Size > num5)
                    {
                        num5 = axisSegments[j].Size;
                        num6 = j;
                    }
                }
                if (num4 > 100.0)
                {
                    axisSegments[num6].Size -= num4 - 100.0;
                    if (axisSegments[num6].Size < num2)
                    {
                        axisSegments[num6].Size = num2;
                    }
                    double num7 = axisSegments[num6].Position + axisSegments[num6].Size;
                    for (int k = num6 + 1; k < axisSegments.Count; k++)
                    {
                        axisSegments[k].Position = num7;
                        num7 += axisSegments[k].Size;
                    }
                }
            }while (num4 > 100.0);
        }
        internal void GetAxisSegmentForScaleBreaks(AxisScaleSegmentCollection axisSegments)
        {
            axisSegments.Clear();
            if (!IsEnabled())
            {
                return;
            }
            FillAxisSegmentCollection(axisSegments);
            if (axisSegments.Count < 1)
            {
                return;
            }
            int startScaleFromZeroSegmentIndex = GetStartScaleFromZeroSegmentIndex(axisSegments);
            int num = 0;

            foreach (AxisScaleSegment axisSegment in axisSegments)
            {
                bool   shouldStartFromZero = (num == startScaleFromZeroSegmentIndex) ? true : false;
                double minimum             = axisSegment.ScaleMinimum;
                double maximum             = axisSegment.ScaleMaximum;
                axisSegment.Interval     = axis.EstimateNumberAxis(ref minimum, ref maximum, shouldStartFromZero, axis.prefferedNumberofIntervals, axis.Crossing, autoMaximum: true, autoMinimum: true);
                axisSegment.ScaleMinimum = minimum;
                axisSegment.ScaleMaximum = maximum;
                if (axisSegment.ScaleMinimum < axis.Minimum)
                {
                    axisSegment.ScaleMinimum = axis.Minimum;
                }
                if (axisSegment.ScaleMaximum > axis.Maximum)
                {
                    axisSegment.ScaleMaximum = axis.Maximum;
                }
                num++;
            }
            bool             flag = false;
            AxisScaleSegment axisScaleSegment2 = axisSegments[0];

            for (int i = 1; i < axisSegments.Count; i++)
            {
                AxisScaleSegment axisScaleSegment3 = axisSegments[i];
                if (axisScaleSegment3.ScaleMinimum <= axisScaleSegment2.ScaleMaximum)
                {
                    if (axisScaleSegment3.ScaleMaximum > axisScaleSegment2.ScaleMaximum)
                    {
                        axisScaleSegment2.ScaleMaximum = axisScaleSegment3.ScaleMaximum;
                    }
                    flag = true;
                    axisSegments.RemoveAt(i);
                    i--;
                }
                else
                {
                    axisScaleSegment2 = axisScaleSegment3;
                }
            }
            if (flag)
            {
                SetAxisSegmentPosition(axisSegments);
            }
        }
 private int GetStartScaleFromZeroSegmentIndex(AxisScaleSegmentCollection axisSegments)
 {
     if (StartFromZero == AutoBool.Auto || StartFromZero == AutoBool.True)
     {
         int num = 0;
         foreach (AxisScaleSegment axisSegment in axisSegments)
         {
             if (axisSegment.ScaleMinimum < 0.0 && axisSegment.ScaleMaximum > 0.0)
             {
                 return(-1);
             }
             if (axisSegment.ScaleMinimum > 0.0 || num == axisSegments.Count - 1)
             {
                 if (StartFromZero == AutoBool.Auto && axisSegment.ScaleMinimum > 2.0 * (axisSegment.ScaleMaximum - axisSegment.ScaleMinimum))
                 {
                     return(-1);
                 }
                 return(num);
             }
             num++;
         }
     }
     return(-1);
 }
        private void FillAxisSegmentCollection(AxisScaleSegmentCollection axisSegments)
        {
            axisSegments.Clear();
            double minYValue   = 0.0;
            double maxYValue   = 0.0;
            double segmentSize = 0.0;

            double[] segmentMaxValue      = null;
            double[] segmentMinValue      = null;
            int[]    seriesDataStatistics = GetSeriesDataStatistics(totalNumberOfSegments, out minYValue, out maxYValue, out segmentSize, out segmentMaxValue, out segmentMinValue);
            if (seriesDataStatistics == null)
            {
                return;
            }
            double minimum = minYValue;
            double maximum = maxYValue;

            axis.EstimateNumberAxis(ref minimum, ref maximum, axis.StartFromZero, axis.prefferedNumberofIntervals, axis.Crossing, autoMaximum: true, autoMinimum: true);
            if (maxYValue == minYValue)
            {
                return;
            }
            double    num       = (maxYValue - minYValue) / ((maximum - minimum) / 100.0);
            ArrayList arrayList = new ArrayList();
            bool      flag      = false;

            while (!flag)
            {
                flag = true;
                int startSegment     = 0;
                int numberOfSegments = 0;
                GetLargestSequenseOfSegmentsWithNoPoints(seriesDataStatistics, out startSegment, out numberOfSegments);
                int num2 = (int)((double)minimumNumberOfEmptySegments * (100.0 / num));
                if (axisSegments.Count > 0 && numberOfSegments > 0)
                {
                    foreach (AxisScaleSegment axisSegment in axisSegments)
                    {
                        if (startSegment > 0 && startSegment + numberOfSegments <= segmentMaxValue.Length - 1 && segmentMaxValue[startSegment - 1] >= axisSegment.ScaleMinimum && segmentMinValue[startSegment + numberOfSegments] <= axisSegment.ScaleMaximum)
                        {
                            double num3 = axisSegment.ScaleMaximum - axisSegment.ScaleMinimum;
                            if ((segmentMinValue[startSegment + numberOfSegments] - segmentMaxValue[startSegment - 1]) / (num3 / 100.0) / 100.0 * axisSegment.Size > (double)num2 && (double)numberOfSegments > minSegmentSize)
                            {
                                num2 = numberOfSegments;
                            }
                        }
                    }
                }
                if (numberOfSegments >= num2)
                {
                    flag = false;
                    arrayList.Add(startSegment);
                    arrayList.Add(numberOfSegments);
                    axisSegments.Clear();
                    if (arrayList.Count > 0)
                    {
                        double num4 = double.NaN;
                        double num5 = double.NaN;
                        int    num6 = 0;
                        for (int i = 0; i < seriesDataStatistics.Length; i++)
                        {
                            bool flag2 = IsExcludedSegment(arrayList, i);
                            if (!flag2 && !double.IsNaN(segmentMinValue[i]) && !double.IsNaN(segmentMaxValue[i]))
                            {
                                num6 += seriesDataStatistics[i];
                                if (double.IsNaN(num4))
                                {
                                    num4 = segmentMinValue[i];
                                    num5 = segmentMaxValue[i];
                                }
                                else
                                {
                                    num5 = segmentMaxValue[i];
                                }
                            }
                            if (!double.IsNaN(num4) && (flag2 || i == seriesDataStatistics.Length - 1))
                            {
                                if (num5 == num4)
                                {
                                    num4 -= segmentSize;
                                    num5 += segmentSize;
                                }
                                AxisScaleSegment axisScaleSegment2 = new AxisScaleSegment();
                                axisScaleSegment2.ScaleMaximum = num5;
                                axisScaleSegment2.ScaleMinimum = num4;
                                axisScaleSegment2.Tag          = num6;
                                axisSegments.Add(axisScaleSegment2);
                                num4 = double.NaN;
                                num5 = double.NaN;
                                num6 = 0;
                            }
                        }
                    }
                    SetAxisSegmentPosition(axisSegments);
                }
                if (axisSegments.Count - 1 >= maximumNumberOfBreaks)
                {
                    flag = true;
                }
            }
        }