Beispiel #1
0
 protected override void InitializeTickInfo(ScaleTickInfo tickInfo)
 {
     base.InitializeTickInfo(tickInfo);
     tickInfo.StartStandard    = 0.0;
     tickInfo.MinTextSpacing   = this.MinTextSpacing;
     tickInfo.DesiredIncrement = this.DesiredIncrement;
 }
Beispiel #2
0
 protected override void InitializeTickInfo(ScaleTickInfo tickInfo)
 {
     base.InitializeTickInfo(tickInfo);
     tickInfo.MajorCount     = this.MajorCount;
     tickInfo.MajorStepSize  = tickInfo.Span / (double)(this.MajorCount - 1);
     tickInfo.MinorStepSize  = tickInfo.MajorStepSize / (double)(base.MinorCount + 1);
     tickInfo.StartStandard  = tickInfo.Min;
     tickInfo.MinTextSpacing = 0.0;
 }
Beispiel #3
0
 protected virtual void Generate(PaintArgs p, ScaleTickInfo tickInfo)
 {
     if (tickInfo.ScaleType == ScaleType.Log10)
     {
         this.GenerateLog10(p, tickInfo);
     }
     else
     {
         if (tickInfo.ScaleType == ScaleType.Linear)
         {
             this.CalculateMajorTicks(tickInfo);
         }
         this.m_MinorStepSize            = tickInfo.MinorStepSize;
         tickInfo.Display.MajorIncrement = tickInfo.MajorStepSize;
         tickInfo.Display.MinorIncrement = tickInfo.MinorStepSize;
         double num       = this.GetStartValue(tickInfo);
         double stopValue = this.GetStopValue(tickInfo);
         if (tickInfo.MinorStepSize != 0.0 && num != num + tickInfo.MinorStepSize)
         {
             while (true)
             {
                 if (Math2.InRangeDelta(num, tickInfo.Min - Math.Abs(tickInfo.Max * 1E-14), tickInfo.Max + Math.Abs(tickInfo.Max * 1E-14)))
                 {
                     tickInfo.Display.AddTickMajor(num, false);
                 }
                 if (!(num < stopValue))
                 {
                     break;
                 }
                 for (int i = 0; i < tickInfo.MinorCount; i++)
                 {
                     num += tickInfo.MinorStepSize;
                     if (Math2.InRangeDelta(num, tickInfo.Min, tickInfo.Max))
                     {
                         if (tickInfo.MidIncluded && i == tickInfo.MinorCount / 2)
                         {
                             tickInfo.Display.AddTickMid(num, false);
                         }
                         else
                         {
                             tickInfo.Display.AddTickMinor(num, false);
                         }
                     }
                 }
                 num += tickInfo.MinorStepSize;
             }
         }
         else
         {
             ScaleTickMajor scaleTickMajor = tickInfo.Display.AddTickMajor(this.Display.Range.Mid, false);
             scaleTickMajor.Value = this.Display.Range.Mid;
             scaleTickMajor.Text  = "Out of Range";
         }
     }
 }
Beispiel #4
0
        private void CalcLinearTicks(ScaleTickInfo tickInfo)
        {
            double span = tickInfo.Span;
            int    num  = (int)(Math.Log10(span) - 1.0 - Math.Log10((double)tickInfo.MaxTicks));

            while (true)
            {
                double num2 = Math.Pow(10.0, (double)num);
                if (!tickInfo.LabelsFit(span, num2 * 1.0) && !tickInfo.LabelsFit(span, num2 * 2.0) && !tickInfo.LabelsFit(span, num2 * 5.0))
                {
                    num++;
                    continue;
                }
                break;
            }
        }
Beispiel #5
0
 protected override void CalculateMajorTicks(ScaleTickInfo tickInfo)
 {
     if (this.DesiredIncrement != 0.0 && tickInfo.Span / this.DesiredIncrement <= (double)tickInfo.MaxTicks)
     {
         tickInfo.MajorCount    = (int)(tickInfo.Span / this.DesiredIncrement);
         tickInfo.MajorStepSize = this.DesiredIncrement;
     }
     else if (tickInfo.TextFormatting.Style == TextFormatDoubleStyle.DateTime)
     {
         this.CalcDateTimeTicks(tickInfo);
     }
     else
     {
         this.CalcLinearTicks(tickInfo);
     }
     tickInfo.MinorStepSize = tickInfo.MajorStepSize / (double)(tickInfo.MinorCount + 1);
 }
Beispiel #6
0
        private ScaleTickLabel GetLastTickLabel(ScaleTickInfo tickInfo)
        {
            int num = tickInfo.TickList.Count - 1;

            while (true)
            {
                if (num >= 0)
                {
                    if (tickInfo.TickList[num] is ScaleTickLabel)
                    {
                        break;
                    }
                    num--;
                    continue;
                }
                return(null);
            }
            return(tickInfo.TickList[num] as ScaleTickLabel);
        }
Beispiel #7
0
        private ScaleTickLabel GetFirstTickLabel(ScaleTickInfo tickInfo)
        {
            int num = 0;

            while (true)
            {
                if (num < tickInfo.TickList.Count)
                {
                    if (tickInfo.TickList[num] is ScaleTickLabel)
                    {
                        break;
                    }
                    num++;
                    continue;
                }
                return(null);
            }
            return(tickInfo.TickList[num] as ScaleTickLabel);
        }
Beispiel #8
0
        private void CalcDateTimeTicks(ScaleTickInfo tickInfo)
        {
            double span = tickInfo.Span;

            if (!tickInfo.LabelsFit(span, Math2.TIME_MILLISECOND * 1.0) && !tickInfo.LabelsFit(span, Math2.TIME_MILLISECOND * 2.0) && !tickInfo.LabelsFit(span, Math2.TIME_MILLISECOND * 5.0) && !tickInfo.LabelsFit(span, Math2.TIME_MILLISECOND * 10.0) && !tickInfo.LabelsFit(span, Math2.TIME_MILLISECOND * 20.0) && !tickInfo.LabelsFit(span, Math2.TIME_MILLISECOND * 50.0) && !tickInfo.LabelsFit(span, Math2.TIME_MILLISECOND * 100.0) && !tickInfo.LabelsFit(span, Math2.TIME_MILLISECOND * 200.0) && !tickInfo.LabelsFit(span, Math2.TIME_MILLISECOND * 500.0) && !tickInfo.LabelsFit(span, Math2.TIME_SECOND * 1.0) && !tickInfo.LabelsFit(span, Math2.TIME_SECOND * 2.0) && !tickInfo.LabelsFit(span, Math2.TIME_SECOND * 5.0) && !tickInfo.LabelsFit(span, Math2.TIME_SECOND * 10.0) && !tickInfo.LabelsFit(span, Math2.TIME_SECOND * 15.0) && !tickInfo.LabelsFit(span, Math2.TIME_SECOND * 20.0) && !tickInfo.LabelsFit(span, Math2.TIME_SECOND * 30.0) && !tickInfo.LabelsFit(span, Math2.TIME_MINUTE * 1.0) && !tickInfo.LabelsFit(span, Math2.TIME_MINUTE * 2.0) && !tickInfo.LabelsFit(span, Math2.TIME_MINUTE * 5.0) && !tickInfo.LabelsFit(span, Math2.TIME_MINUTE * 10.0) && !tickInfo.LabelsFit(span, Math2.TIME_MINUTE * 15.0) && !tickInfo.LabelsFit(span, Math2.TIME_MINUTE * 20.0) && !tickInfo.LabelsFit(span, Math2.TIME_MINUTE * 30.0) && !tickInfo.LabelsFit(span, Math2.TIME_HOUR * 1.0) && !tickInfo.LabelsFit(span, Math2.TIME_HOUR * 2.0) && !tickInfo.LabelsFit(span, Math2.TIME_HOUR * 4.0) && !tickInfo.LabelsFit(span, Math2.TIME_HOUR * 6.0) && !tickInfo.LabelsFit(span, Math2.TIME_HOUR * 12.0) && !tickInfo.LabelsFit(span, 1.0) && !tickInfo.LabelsFit(span, 7.0) && !tickInfo.LabelsFit(span, 14.0) && !tickInfo.LabelsFit(span, 31.0) && !tickInfo.LabelsFit(span, 61.0) && !tickInfo.LabelsFit(span, 92.0) && !tickInfo.LabelsFit(span, 182.0))
            {
                int num = 0;
                while (true)
                {
                    double num2 = Math.Pow(10.0, (double)num);
                    if (!tickInfo.LabelsFit(span, 1.0 * num2 * 365.0) && !tickInfo.LabelsFit(span, 2.0 * num2 * 365.0) && !tickInfo.LabelsFit(span, 5.0 * num2 * 365.0))
                    {
                        num++;
                        continue;
                    }
                    break;
                }
            }
        }
Beispiel #9
0
        protected double GetStartValue(ScaleTickInfo tickInfo)
        {
            double num = (!this.Display.StartRefEnabled) ? tickInfo.StartStandard : this.Display.StartRefValue;

            if (num < tickInfo.Min)
            {
                double num2 = Math.Round((tickInfo.Min - num) / tickInfo.MajorStepSize);
                num += num2 * tickInfo.MajorStepSize;
            }
            else if (num > tickInfo.Min)
            {
                double num2 = Math.Round((num - tickInfo.Min) / tickInfo.MajorStepSize);
                num -= (num2 + 1.0) * tickInfo.MajorStepSize;
            }
            if (num >= tickInfo.Min)
            {
                num -= tickInfo.MajorStepSize;
            }
            return(num);
        }
Beispiel #10
0
 protected override void CreateObjects()
 {
     base.CreateObjects();
     this.m_GeneratorAuto = new ScaleGeneratorAuto();
     base.AddSubClass(this.GeneratorAuto);
     this.m_GeneratorFixed = new ScaleGeneratorFixed();
     base.AddSubClass(this.GeneratorFixed);
     this.m_TickMajor = new ScaleTickMajor();
     base.AddSubClass(this.TickMajor);
     this.m_TickMid = new ScaleTickMid();
     base.AddSubClass(this.TickMid);
     this.m_TickMinor = new ScaleTickMinor();
     base.AddSubClass(this.TickMinor);
     this.TextFormatting = new TextFormatDoubleAll();
     ((IScaleGeneratorBase)this.m_GeneratorAuto).Display  = this;
     ((IScaleGeneratorBase)this.m_GeneratorFixed).Display = this;
     this.m_TickInfo = new ScaleTickInfo(this);
     ((ISubClassBase)this.TickMajor).ColorAmbientSource = AmbientColorSouce.Color;
     ((ISubClassBase)this.TickMinor).ColorAmbientSource = AmbientColorSouce.Color;
     ((ISubClassBase)this.TickMid).ColorAmbientSource   = AmbientColorSouce.Color;
     this.m_MajorIncrement   = 10.0;
     this.m_MinorIncrement   = 1.0;
     base.ColorAmbientSource = AmbientColorSouce.ForeColor;
 }
Beispiel #11
0
 protected override void Generate(PaintArgs p, ScaleTickInfo tickInfo)
 {
     base.Generate(p, tickInfo);
     if (this.FixedMinMaxMajors)
     {
         if (tickInfo.Display is ScaleDisplayLinear)
         {
             ScaleDisplayLinear scaleDisplayLinear = tickInfo.Display as ScaleDisplayLinear;
             ScaleTickLabel     firstTickLabel     = this.GetFirstTickLabel(tickInfo);
             if (firstTickLabel != null && scaleDisplayLinear.ValueToPixels(firstTickLabel.Value) - tickInfo.LabelMaxWidth < scaleDisplayLinear.PixelsMin)
             {
                 tickInfo.TickList.Remove(firstTickLabel);
             }
             firstTickLabel = this.GetLastTickLabel(tickInfo);
             if (firstTickLabel != null && scaleDisplayLinear.ValueToPixels(firstTickLabel.Value) + tickInfo.LabelMaxWidth > scaleDisplayLinear.PixelsMax)
             {
                 tickInfo.TickList.Remove(firstTickLabel);
             }
         }
         if (tickInfo.Display is ScaleDisplayAngular)
         {
             ScaleTickLabel firstTickLabel = this.GetFirstTickLabel(tickInfo);
             if (firstTickLabel != null)
             {
                 tickInfo.TickList.Remove(firstTickLabel);
             }
             firstTickLabel = this.GetLastTickLabel(tickInfo);
             if (firstTickLabel != null)
             {
                 tickInfo.TickList.Remove(firstTickLabel);
             }
         }
         tickInfo.Display.AddTickMajor(tickInfo.Display.Range.Min, false);
         tickInfo.Display.AddTickMajor(tickInfo.Display.Range.Max, false);
     }
 }
Beispiel #12
0
 void IScaleGeneratorBase.Generate(PaintArgs p, ScaleTickInfo tickInfo)
 {
     this.Generate(p, tickInfo);
 }
Beispiel #13
0
 void IScaleGeneratorBase.InitializeTickInfo(ScaleTickInfo tickInfo)
 {
     this.InitializeTickInfo(tickInfo);
 }
Beispiel #14
0
        protected void GenerateLog10(PaintArgs p, ScaleTickInfo tickInfo)
        {
            int num  = (int)Math.Log10(tickInfo.Span);
            int num2 = 1;
            int num3;

            if (num / 1 > tickInfo.MaxTicks)
            {
                if (num / num2 > tickInfo.MaxTicks)
                {
                    num2 = 1;
                }
                if (num / num2 > tickInfo.MaxTicks)
                {
                    num2 = 2;
                }
                if (num / num2 > tickInfo.MaxTicks)
                {
                    num2 = 5;
                }
                if (num / num2 > tickInfo.MaxTicks)
                {
                    num2 = 10;
                }
                if (num / num2 > tickInfo.MaxTicks)
                {
                    num2 = 20;
                }
                if (num / num2 > tickInfo.MaxTicks)
                {
                    num2 = 50;
                }
                if (num / num2 > tickInfo.MaxTicks)
                {
                    num2 = 100;
                }
                if (num / num2 > tickInfo.MaxTicks)
                {
                    num2 = 200;
                }
                if (num / num2 > tickInfo.MaxTicks)
                {
                    num2 = 200;
                }
                num3 = (int)Math.Log10(tickInfo.Min);
            }
            else
            {
                num3 = (int)Math.Log10(tickInfo.Min);
            }
            tickInfo.MajorStepSize = Math.Pow(10.0, (double)num2);
            tickInfo.MinorStepSize = tickInfo.MajorStepSize / (double)(tickInfo.MinorCount + 1);
            this.m_MinorStepSize   = tickInfo.MinorStepSize;
            double num4 = Math.Pow(10.0, (double)num3);
            double num5 = this.GetStopValue(tickInfo);

            if (!this.Display.SlidingScale)
            {
                num5 = this.Display.Range.Max;
            }
            while (true)
            {
                if (Math2.InRangeDelta(num4, tickInfo.Min, tickInfo.Max) && num4 > 0.0)
                {
                    tickInfo.Display.AddTickMajor(num4, false);
                }
                if (!(num4 < num5))
                {
                    break;
                }
                tickInfo.MinorStepSize = num4 * 10.0 / (double)(tickInfo.MinorCount + 1);
                for (int i = 1; i <= 9; i++)
                {
                    double num6 = num4 * (double)i;
                    if (!(num6 <= num5))
                    {
                        return;
                    }
                    if (Math2.InRangeDelta(num4, tickInfo.Min, tickInfo.Max) && num4 > 0.0)
                    {
                        if (tickInfo.MidIncluded && i == tickInfo.MinorCount / 2)
                        {
                            tickInfo.Display.AddTickMid(num6, false);
                        }
                        else
                        {
                            tickInfo.Display.AddTickMinor(num6, false);
                        }
                    }
                }
                num3++;
                num4 = Math.Pow(10.0, (double)num3);
            }
        }
Beispiel #15
0
 protected virtual void InitializeTickInfo(ScaleTickInfo tickInfo)
 {
     tickInfo.MinorCount  = this.GetMinorCount();
     tickInfo.MidIncluded = this.MidIncluded;
 }
Beispiel #16
0
 protected virtual void CalculateMajorTicks(ScaleTickInfo tickInfo)
 {
 }
Beispiel #17
0
 protected double GetStopValue(ScaleTickInfo tickInfo)
 {
     return(tickInfo.Max + tickInfo.MajorStepSize);
 }