Example #1
0
 protected override void InternalOnMouseUp(MouseEventArgs e)
 {
     if (base.Plot != null)
     {
         if (this.MouseMode == PlotDataViewMouseMode.ZoomBox)
         {
             if (base.IsMouseActive && Math2.Delta(this.m_ZoomBoxStartX, this.m_ZoomBoxStopX) >= 3 && Math2.Delta(this.m_ZoomBoxStartY, this.m_ZoomBoxStopY) >= 3)
             {
                 Rectangle r = iRectangle.FromLTRB(this.m_ZoomBoxStartX, this.m_ZoomBoxStartY, this.m_ZoomBoxStopX, this.m_ZoomBoxStopY);
                 if (this.BeforeZoomBox != null)
                 {
                     PlotDataViewZoomBoxEventArgs plotDataViewZoomBoxEventArgs = new PlotDataViewZoomBoxEventArgs(this, r);
                     this.BeforeZoomBox(this, plotDataViewZoomBoxEventArgs);
                     if (plotDataViewZoomBoxEventArgs.Cancel)
                     {
                         return;
                     }
                 }
                 this.DisableAllTracking();
                 foreach (PlotAxis zoomBoxAxis in this.m_ZoomBoxAxes)
                 {
                     zoomBoxAxis.Zoom(r);
                 }
             }
         }
         else
         {
             base.IsMouseActive = false;
             foreach (PlotAxis xAxis in base.Plot.XAxes)
             {
                 if (xAxis.Visible && base.IsDocked(xAxis))
                 {
                     ((IUIInput)xAxis).MouseUp(e);
                 }
             }
             foreach (PlotAxis yAxis in base.Plot.YAxes)
             {
                 if (yAxis.Visible && base.IsDocked(yAxis))
                 {
                     ((IUIInput)yAxis).MouseUp(e);
                 }
             }
         }
     }
 }
Example #2
0
        protected void UpdateGrabHandles(Rectangle r)
        {
            double centerX = (double)(r.Left + r.Right) / 2.0;
            double centerY = (double)(r.Top + r.Bottom) / 2.0;
            double num     = (double)r.Width / 2.0;
            double num2    = (double)r.Height / 2.0;
            double num3    = Math.Atan2(num2, num) * 360.0 / 6.2831853071795862;
            double radius  = Math.Sqrt(num * num + num2 * num2);

            this.GrabHandle0.Rectangle = this.CalcGrabRect(Math2.ToRotatedPoint(180.0 + num3 + this.Rotation, radius, centerX, centerY));
            this.GrabHandle1.Rectangle = this.CalcGrabRect(Math2.ToRotatedPoint(270.0 + this.Rotation, num2, centerX, centerY));
            this.GrabHandle2.Rectangle = this.CalcGrabRect(Math2.ToRotatedPoint(0.0 - num3 + this.Rotation, radius, centerX, centerY));
            this.GrabHandle3.Rectangle = this.CalcGrabRect(Math2.ToRotatedPoint(0.0 + this.Rotation, num, centerX, centerY));
            this.GrabHandle4.Rectangle = this.CalcGrabRect(Math2.ToRotatedPoint(0.0 + num3 + this.Rotation, radius, centerX, centerY));
            this.GrabHandle5.Rectangle = this.CalcGrabRect(Math2.ToRotatedPoint(90.0 + this.Rotation, num2, centerX, centerY));
            this.GrabHandle6.Rectangle = this.CalcGrabRect(Math2.ToRotatedPoint(180.0 - num3 + this.Rotation, radius, centerX, centerY));
            this.GrabHandle7.Rectangle = this.CalcGrabRect(Math2.ToRotatedPoint(180.0 + this.Rotation, num, centerX, centerY));
        }
        private void CalculateLabelCallout(ScaleDiscreetItem item, Size textSize, double angle, int radius, Point centerPoint)
        {
            int num = radius + base.TextMargin;

            item.LinePoint1 = Math2.ToRotatedPoint(angle, (double)num, centerPoint);
            if (angle == 0.0)
            {
                num               += (int)(1.414 * (double)this.CallOutLength);
                item.LinePoint2    = Math2.ToRotatedPoint(angle, (double)num, centerPoint);
                item.TextRectangle = Math2.TextRectangleAngular(textSize, item.LinePoint2, base.TextMargin, angle);
            }
            else if (angle == 180.0)
            {
                num               += (int)(1.414 * (double)this.CallOutLength);
                item.LinePoint2    = Math2.ToRotatedPoint(angle, (double)num, centerPoint);
                item.TextRectangle = Math2.TextRectangleAngular(textSize, item.LinePoint2, base.TextMargin, angle);
            }
            else if (angle == 90.0)
            {
                num               += (int)(1.414 * (double)this.CallOutLength);
                item.LinePoint2    = Math2.ToRotatedPoint(angle, (double)num, centerPoint);
                item.TextRectangle = Math2.TextRectangleAngular(textSize, item.LinePoint2, base.TextMargin, angle);
            }
            else if (angle == 270.0)
            {
                num               += (int)(1.414 * (double)this.CallOutLength);
                item.LinePoint2    = Math2.ToRotatedPoint(angle, (double)num, centerPoint);
                item.TextRectangle = Math2.TextRectangleAngular(textSize, item.LinePoint2, base.TextMargin, angle);
            }
            else if (angle > 90.0 && angle < 270.0)
            {
                num               += this.CallOutLength;
                item.LinePoint2    = Math2.ToRotatedPoint(angle, (double)num, centerPoint);
                item.LinePoint3    = Math2.ToRotatedPoint(180.0, (double)this.CallOutLength, item.LinePoint2);
                item.TextRectangle = Math2.TextRectangleAngular(textSize, item.LinePoint3, base.TextMargin, angle);
            }
            else
            {
                num               += this.CallOutLength;
                item.LinePoint2    = Math2.ToRotatedPoint(angle, (double)num, centerPoint);
                item.LinePoint3    = Math2.ToRotatedPoint(0.0, (double)this.CallOutLength, item.LinePoint2);
                item.TextRectangle = Math2.TextRectangleAngular(textSize, item.LinePoint3, base.TextMargin, angle);
            }
        }
Example #4
0
        private Point GetTickPoint(IScaleTickBase tick, float radius)
        {
            double angle = this.I_Range.ValueToAngle(tick.Value);
            double num;

            switch ((!(tick is ScaleTickMinor)) ? ((tick is ScaleTickMid) ? (tick as ScaleTickMid).Alignment : AlignmentStyle.Near) : (tick as ScaleTickMinor).Alignment)
            {
            case AlignmentStyle.Center:
                num = (double)((float)(base.TickMajor.Length - tick.Length) / 2f);
                break;

            case AlignmentStyle.Far:
                num = (double)(base.TickMajor.Length - tick.Length);
                break;

            default:
                num = 0.0;
                break;
            }
            return(Math2.ToRotatedPoint(angle, (double)(radius + (float)this.Margin) + num, this.CenterPoint));
        }
Example #5
0
        protected override void Draw(PaintArgs p, PlotXAxis xAxis, PlotYAxis yAxis)
        {
            this.m_FillRefPixel = yAxis.ValueToPixels(this.Reference);
            this.m_XPixelMin    = xAxis.ValueToPixels(xAxis.Min);
            this.m_XPixelMax    = xAxis.ValueToPixels(xAxis.Max);
            if (this.m_XPixelMax < this.m_XPixelMin)
            {
                Math2.Switch(ref this.m_XPixelMax, ref this.m_XPixelMin);
            }
            int num = this.m_XPixelMax - this.m_XPixelMin;

            if (num < 1)
            {
                this.m_PixelYValues = null;
            }
            else
            {
                if (this.m_PixelYValues == null)
                {
                    this.m_PixelYValues = new double[num];
                }
                if (this.m_PixelYValues.Length != num)
                {
                    this.m_PixelYValues = new double[num];
                }
            }
            if (this.m_PixelYValues != null)
            {
                for (int i = 0; i < this.m_PixelYValues.Length; i++)
                {
                    this.m_PixelYValues[i] = 1E+305;
                }
            }
            if (this.Trace.Visible && this.Count > 1)
            {
                this.DrawTraceCustomAttributes(p, xAxis, yAxis);
            }
            this.DrawMarkers(p, xAxis, yAxis, this.Markers);
        }
Example #6
0
        public static bool NeedsUpdate(IUpdateRate update)
        {
            if (update.FrameRate == 0.0)
            {
                return(false);
            }
            if (update.Active)
            {
                return(false);
            }
            if (!update.Needed)
            {
                return(false);
            }
            DateTime now = DateTime.Now;

            if (Math2.DateTimeToDouble(now) > Math2.DateTimeToDouble(update.LastRepaintTime) + 1.0 / update.FrameRate * 1.0 / 86400.0)
            {
                return(true);
            }
            return(false);
        }
 protected override void Calculate(PaintArgs p, ScaleDiscreetItemCollection items, Point centerPoint, int activeIndex, int pointerExtent)
 {
     if (base.Visible)
     {
         DrawStringFormat genericTypographic = DrawStringFormat.GenericTypographic;
         genericTypographic.LineAlignment = StringAlignment.Near;
         genericTypographic.Alignment     = StringAlignment.Near;
         for (int i = 0; i < items.Count; i++)
         {
             Font   font     = (i != activeIndex) ? base.TextInactiveFont : base.TextActiveFont;
             Size   textSize = p.Graphics.MeasureString(items[i].Text, font, true);
             double angle    = this.ScaleRange.ValueToAngle(i, items.Count);
             int    num      = pointerExtent + base.Margin;
             if (base.Markers.Style != MarkerStyleLabel.None)
             {
                 items[i].MarkerPoint = Math2.ToRotatedPoint(angle, (double)(num + base.Markers.Size), centerPoint);
                 num += 2 * base.Markers.Size;
             }
             items[i].LinePoint1 = Point.Empty;
             items[i].LinePoint2 = Point.Empty;
             items[i].LinePoint3 = Point.Empty;
             if (this.TextAlignment == StringAlignmentDiscreetAngular.Center)
             {
                 this.CalculateLabelCenter(items[i], textSize, angle, num, centerPoint);
             }
             else if (this.TextAlignment == StringAlignmentDiscreetAngular.CallOut)
             {
                 this.CalculateLabelCallout(items[i], textSize, angle, num, centerPoint);
             }
             else if (this.TextAlignment == StringAlignmentDiscreetAngular.Justified)
             {
                 this.CalculateLabelJustified(items[i], textSize, angle, num, centerPoint);
             }
         }
     }
 }
Example #8
0
        private void DrawColorBar(PaintArgs p, double start, double stop, Color color)
        {
            start = base.ValueClamped(start);
            stop  = base.ValueClamped(stop);
            int edgeRef = base.EdgeRef;
            int num     = this.ValueToPixels(stop);
            int num2    = this.ValueToPixels(start);
            int length  = base.TickMajor.Length;

            if (num2 < num)
            {
                Math2.Switch(ref num2, ref num);
            }
            if (this.Direction == SideDirection.LeftToRight)
            {
                Rectangle rect = new Rectangle(edgeRef, num, length, num2 - num);
                p.Graphics.FillRectangle(p.Graphics.Brush(color), rect);
            }
            else
            {
                Rectangle rect = new Rectangle(edgeRef - length, num, length, num2 - num);
                p.Graphics.FillRectangle(p.Graphics.Brush(color), rect);
            }
        }
Example #9
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);
            }
        }
Example #10
0
 public static Point ToRotatedPoint(double angle, double radius, Point centerPoint)
 {
     return(new Point((int)Math.Round(Math2.Cos(angle) * radius + (double)centerPoint.X, 14), (int)Math.Round(Math2.Sin(angle) * radius + (double)centerPoint.Y, 14)));
 }
Example #11
0
        private Rectangle GetTextRect(PaintArgs p, IScaleTickLabel tick)
        {
            double    num    = Math2.AngleNormalized(this.I_Range.ValueToAngle(tick.Value));
            float     num2   = (float)tick.TextSize.Width;
            float     num3   = (float)tick.TextSize.Height;
            Size      size   = p.Graphics.MeasureString(base.TickMajor.Font);
            Point     point  = default(Point);
            Rectangle result = default(Rectangle);

            if (this.TextAlignment == StringAlignmentAngular.Center)
            {
                float num4 = (float)(this.Radius + this.Margin + base.TickMajor.Length + tick.TextMargin + tick.TextMaxSize.Width / 2);
                point  = new Point((int)(Math2.Cos(num) * (double)num4 + (double)this.CenterPoint.X), (int)(Math2.Sin(num) * (double)num4 + (double)this.CenterPoint.Y));
                result = new Rectangle((int)((float)point.X - num2 / 2f), (int)((float)point.Y - num3 / 2f), (int)num2, (int)num3);
                goto IL_0479;
            }
            if (this.TextAlignment == StringAlignmentAngular.Justified)
            {
                float num5 = (float)Math.Sqrt((double)(size.Width * size.Width + size.Height * size.Height)) / 2f;
                float num4 = (float)(this.Radius + base.TickMajor.Length + tick.TextMargin) + num5;
                point  = new Point((int)(Math2.Cos(num) * (double)num4 + (double)this.CenterPoint.X), (int)(Math2.Sin(num) * (double)num4 + (double)this.CenterPoint.Y));
                result = new Rectangle((int)((float)point.X - num2 / 2f), (int)((float)point.Y - num3 / 2f), (int)num2, (int)num3);
                if (num == 0.0)
                {
                    result.Offset((int)(num2 / 2f - (float)(size.Width / 2)), 0);
                }
                else if (num == 180.0)
                {
                    result.Offset((int)((0f - num2) / 2f + (float)(size.Width / 2)), 0);
                }
                else if (num > 0.0 && num < 90.0)
                {
                    result.Offset((int)(num2 / 2f - (float)(size.Width / 2)), 0);
                }
                else if (num > 90.0 && num < 270.0)
                {
                    result.Offset((int)((0f - num2) / 2f + (float)(size.Width / 2)), 0);
                }
                else if (num > 270.0 && num < 360.0)
                {
                    result.Offset((int)(num2 / 2f - (float)(size.Width / 2)), 0);
                }
                goto IL_0479;
            }
            Point point2 = default(Point);

            if (this.TextAlignment == StringAlignmentAngular.RadialOuter)
            {
                float num6 = (float)(this.Radius + base.TickMajor.Length + tick.TextMargin + tick.TextSize.Width / 2);
                point2 = new Point((int)(Math2.Cos(num) * (double)num6 + (double)this.CenterPoint.X), (int)(Math2.Sin(num) * (double)num6 + (double)this.CenterPoint.Y));
                result = new Rectangle(point2.X - tick.TextSize.Width / 2, point2.Y - tick.TextSize.Height / 2, tick.TextSize.Width, tick.TextSize.Height);
                goto IL_0479;
            }
            if (this.TextAlignment == StringAlignmentAngular.RadialInner)
            {
                float num6 = (float)(this.Radius - tick.TextMargin - tick.TextMaxSize.Width / 2);
                point2 = new Point((int)(Math2.Cos(num) * (double)num6 + (double)this.CenterPoint.X), (int)(Math2.Sin(num) * (double)num6 + (double)this.CenterPoint.Y));
                result = new Rectangle(point2.X - tick.TextMaxSize.Width / 2, point2.Y - tick.TextMaxSize.Height / 2, tick.TextMaxSize.Width, tick.TextMaxSize.Height);
                goto IL_0479;
            }
            result = Rectangle.Empty;
            return(result);

IL_0479:
            return(result);
        }
Example #12
0
 protected override bool GetValueOnScale(double value)
 {
     return(Math2.InRangeDelta(value, base.ScaleRange.Min, base.ScaleRange.Max));
 }
Example #13
0
        private Point GetScalePoint(double value, double radius)
        {
            double angle = this.I_Range.ValueToAngle(value);

            return(Math2.ToRotatedPoint(angle, radius, this.CenterPoint));
        }
Example #14
0
 public int AddXY(DateTime x, double y)
 {
     return(this.AddXY(Math2.DateTimeToDouble(x), y));
 }
Example #15
0
 public static double Sin(double angle)
 {
     return(Math.Sin(Math2.Radians(angle)));
 }
Example #16
0
 public int AddXY(DateTime x, double y, double width)
 {
     return(this.AddXY(Math2.DateTimeToDouble(x), y, false, false, width));
 }
Example #17
0
 public int AddYElapsedSeconds(double y)
 {
     return(this.AddXY((Math2.DateTimeToDouble(DateTime.Now) - Math2.DateTimeToDouble(this.ElapsedStartTime)) * 24.0 * 60.0 * 60.0, y));
 }
Example #18
0
 public void AddDataArray(DateTime startX, TimeSpan interval, Array yArray)
 {
     this.AddDataArray(Math2.DateTimeToDouble(startX), Math2.TimeSpanToDouble(interval), yArray);
 }
        private void CalculateLabelCenter(ScaleDiscreetItem item, Size textSize, double angle, int radius, Point centerPoint)
        {
            int   num   = radius + base.TextMargin + (int)Math.Abs(Math2.Cos(angle) * (double)textSize.Width / 2.0) + (int)Math.Abs(Math2.Sin(angle) * (double)textSize.Height / 2.0);
            Point point = Math2.ToRotatedPoint(angle, (double)num, centerPoint);

            item.TextRectangle = new Rectangle(point.X - textSize.Width / 2, point.Y - textSize.Height / 2, textSize.Width + 1, textSize.Height + 1);
        }
Example #20
0
 public void AddDataArray(DateTime startX, double interval, Array yArray)
 {
     this.AddDataArray(Math2.DateTimeToDouble(startX), interval, yArray);
 }
Example #21
0
 public int AddEmpty(DateTime x)
 {
     return(this.AddEmpty(Math2.DateTimeToDouble(x)));
 }
Example #22
0
 public int AddNull(DateTime x)
 {
     return(this.AddNull(Math2.DateTimeToDouble(x)));
 }
Example #23
0
 public int AddYUTC(double y)
 {
     return(this.AddXY(Math2.DateTimeToDouble(DateTime.UtcNow), y));
 }
Example #24
0
 public static double PointToAngle(Point centerPoint, int x, int y)
 {
     return(Math2.AngleNormalized(Math2.ToAngle(Math.Atan2((double)(y - centerPoint.Y), (double)(x - centerPoint.X)))));
 }
Example #25
0
 public int AddYElapsedTime(double y)
 {
     return(this.AddXY(Math2.DateTimeToDouble(DateTime.Now) - Math2.DateTimeToDouble(this.ElapsedStartTime), y));
 }
Example #26
0
        protected override void Draw(PaintArgs p, PlotXAxis xAxis, PlotYAxis yAxis)
        {
            this.m_FillRefPixel = yAxis.ValueToPixels(this.Reference);
            this.m_XPixelMin    = xAxis.ValueToPixels(xAxis.Min);
            this.m_XPixelMax    = xAxis.ValueToPixels(xAxis.Max);
            if (this.m_XPixelMax < this.m_XPixelMin)
            {
                Math2.Switch(ref this.m_XPixelMax, ref this.m_XPixelMin);
            }
            int num = this.m_XPixelMax - this.m_XPixelMin;

            if (num < 1)
            {
                this.m_PixelYValues = null;
            }
            else
            {
                if (this.m_PixelYValues == null)
                {
                    this.m_PixelYValues = new double[num];
                }
                if (this.m_PixelYValues.Length != num)
                {
                    this.m_PixelYValues = new double[num];
                }
            }
            if (this.m_PixelYValues != null)
            {
                for (int i = 0; i < this.m_PixelYValues.Length; i++)
                {
                    this.m_PixelYValues[i] = 1E+305;
                }
            }
            if (this.Trace.Visible && this.Count > 1)
            {
                int j    = 0;
                int num2 = 0;
                int num3 = 0;
                for (; j < this.Count; j++)
                {
                    if (this[j].Null)
                    {
                        if (num3 - num2 > 1)
                        {
                            this.SplineCalculations(num3 - num2 + 1, num2, num2 + 1, num3, num3 - 1);
                            this.DrawTraceCustomAttributes(p, xAxis, yAxis, num2, num3);
                            num2 = j + 1;
                            num3 = num2;
                        }
                    }
                    else
                    {
                        num3 = j;
                    }
                }
                if (num3 - num2 > 1)
                {
                    this.SplineCalculations(num3 - num2 + 1, num2, num2 + 1, num3, num3 - 1);
                    this.DrawTraceCustomAttributes(p, xAxis, yAxis, num2, num3);
                }
            }
            this.DrawMarkers(p, xAxis, yAxis, this.Markers);
        }
Example #27
0
 public DateTime GetXInDateTime(int index)
 {
     return(Math2.DoubleToDateTime(this.GetX(index)));
 }
Example #28
0
        public override string GetText(double value)
        {
            double num  = Math.Abs(value);
            int    num2 = (!(num < 1.0)) ? ((int)Math.Log10(Math.Abs(value)) + 1) : 0;

            if (num2 < 12 && !double.IsInfinity(value) && !double.IsNaN(value))
            {
                value = Math.Round(value, 12 - num2);
            }
            switch (this.Style)
            {
            default:
                return("Error");

            case TextFormatDoubleStyle.Number:
            {
                if (base.PrecisionStyle == PrecisionStyle.None)
                {
                    return(string.Format(CultureInfo.CurrentCulture, "{0:G}" + base.UnitsText, new object[1]
                        {
                            value
                        }));
                }
                string actualPrecisionString = this.GetActualPrecisionString(value);
                return(string.Format(CultureInfo.CurrentCulture, "{0:f" + actualPrecisionString + "}" + base.UnitsText, new object[1]
                    {
                        value
                    }));
            }

            case TextFormatDoubleStyle.Thousands:
            {
                string actualPrecisionString = this.GetActualPrecisionString(value);
                return(string.Format(CultureInfo.CurrentCulture, "{0:n" + actualPrecisionString + "}" + base.UnitsText, new object[1]
                    {
                        value
                    }));
            }

            case TextFormatDoubleStyle.Prefix:
            {
                int num3 = (int)(Math.Log10(Math.Abs(value)) / 3.0) * 3;
                num = value / Math.Pow(10.0, (double)num3);
                string actualPrecisionString = this.GetActualPrecisionString(num);
                switch (num3)
                {
                case -21:
                    return(string.Format(CultureInfo.CurrentCulture, "{0:f" + actualPrecisionString + "} z" + base.UnitsText, new object[1]
                        {
                            num
                        }));

                case -24:
                    return(string.Format(CultureInfo.CurrentCulture, "{0:f" + actualPrecisionString + "} y" + base.UnitsText, new object[1]
                        {
                            num
                        }));

                case -15:
                    return(string.Format(CultureInfo.CurrentCulture, "{0:f" + actualPrecisionString + "} f" + base.UnitsText, new object[1]
                        {
                            num
                        }));

                case -18:
                    return(string.Format(CultureInfo.CurrentCulture, "{0:f" + actualPrecisionString + "} a" + base.UnitsText, new object[1]
                        {
                            num
                        }));

                case -9:
                    return(string.Format(CultureInfo.CurrentCulture, "{0:f" + actualPrecisionString + "} n" + base.UnitsText, new object[1]
                        {
                            num
                        }));

                case -12:
                    return(string.Format(CultureInfo.CurrentCulture, "{0:f" + actualPrecisionString + "} p" + base.UnitsText, new object[1]
                        {
                            num
                        }));

                case -3:
                    return(string.Format(CultureInfo.CurrentCulture, "{0:f" + actualPrecisionString + "} m" + base.UnitsText, new object[1]
                        {
                            num
                        }));

                case -6:
                    return(string.Format(CultureInfo.CurrentCulture, "{0:f" + actualPrecisionString + "} µ" + base.UnitsText, new object[1]
                        {
                            num
                        }));

                case 3:
                    return(string.Format(CultureInfo.CurrentCulture, "{0:f" + actualPrecisionString + "} K" + base.UnitsText, new object[1]
                        {
                            num
                        }));

                case 0:
                    return(string.Format(CultureInfo.CurrentCulture, "{0:f" + actualPrecisionString + "}" + base.UnitsText, new object[1]
                        {
                            num
                        }));

                case 9:
                    return(string.Format(CultureInfo.CurrentCulture, "{0:f" + actualPrecisionString + "} G" + base.UnitsText, new object[1]
                        {
                            num
                        }));

                case 6:
                    return(string.Format(CultureInfo.CurrentCulture, "{0:f" + actualPrecisionString + "} M" + base.UnitsText, new object[1]
                        {
                            num
                        }));

                case 15:
                    return(string.Format(CultureInfo.CurrentCulture, "{0:f" + actualPrecisionString + "} P" + base.UnitsText, new object[1]
                        {
                            num
                        }));

                case 12:
                    return(string.Format(CultureInfo.CurrentCulture, "{0:f" + actualPrecisionString + "} T" + base.UnitsText, new object[1]
                        {
                            num
                        }));

                case 24:
                    return(string.Format(CultureInfo.CurrentCulture, "{0:f" + actualPrecisionString + "} Y" + base.UnitsText, new object[1]
                        {
                            num
                        }));

                default:
                    return(string.Format(CultureInfo.CurrentCulture, "{0:e" + actualPrecisionString + "}" + base.UnitsText, new object[1]
                        {
                            value
                        }));

                case 21:
                    return(string.Format(CultureInfo.CurrentCulture, "{0:f" + actualPrecisionString + "} Z" + base.UnitsText, new object[1]
                        {
                            num
                        }));

                case 18:
                    return(string.Format(CultureInfo.CurrentCulture, "{0:f" + actualPrecisionString + "} E" + base.UnitsText, new object[1]
                        {
                            num
                        }));
                }
            }

            case TextFormatDoubleStyle.Exponent:
            {
                string actualPrecisionString = this.GetActualPrecisionString(value);
                return(string.Format(CultureInfo.CurrentCulture, "{0:e" + actualPrecisionString + "}" + base.UnitsText, new object[1]
                    {
                        value
                    }));
            }

            case TextFormatDoubleStyle.ExponentShort:
            {
                string actualPrecisionString = this.GetActualPrecisionString(value);
                string text = string.Format(CultureInfo.CurrentCulture, "{0:e" + actualPrecisionString + "}" + base.UnitsText, new object[1]
                    {
                        value
                    });
                int num4 = text.IndexOf('+');
                if (num4 != -1)
                {
                    if (text.Substring(num4 + 1, 2) == "00")
                    {
                        text = text.Substring(0, num4 + 1) + text.Substring(num4 + 3, 1);
                    }
                    else if (text.Substring(num4 + 1, 1) == "0")
                    {
                        text = text.Substring(0, num4 + 1) + text.Substring(num4 + 2, 2);
                    }
                }
                return(text);
            }

            case TextFormatDoubleStyle.Price32nds:
            {
                double num5  = value - (double)(int)value;
                int    num6  = (int)(num5 * 32.0);
                int    num7  = (int)((num5 - (double)num6 / 32.0) * 256.0);
                string text2 = num6.ToString("d", CultureInfo.CurrentCulture);
                string text3 = num7.ToString("d", CultureInfo.CurrentCulture);
                if (text2.Length < 2)
                {
                    text2 = "0" + text2;
                }
                return(string.Format(CultureInfo.CurrentCulture, "{0:f0}." + text2 + text3 + " " + base.UnitsText, new object[1]
                    {
                        (int)(value + 0.0)
                    }));
            }

            case TextFormatDoubleStyle.DateTime:
            {
                DateTime dateTime2 = Math2.DoubleToDateTime(value);
                if (this.DateTimeFormat.IndexOf('f') != -1)
                {
                    return(dateTime2.ToString(this.DateTimeFormat, CultureInfo.CurrentCulture));
                }
                return(dateTime2.AddMilliseconds(5.0).ToString(this.DateTimeFormat, CultureInfo.CurrentCulture));
            }

            case TextFormatDoubleStyle.DateTimeUTC:
            {
                DateTime dateTime = Math2.DoubleToDateTime(value).ToLocalTime();
                if (this.DateTimeFormat.IndexOf('f') != -1)
                {
                    return(dateTime.ToString(this.DateTimeFormat, CultureInfo.CurrentCulture));
                }
                return(dateTime.AddMilliseconds(5.0).ToString(this.DateTimeFormat, CultureInfo.CurrentCulture));
            }
            }
        }
Example #29
0
 public static Point ToRotatedPoint(double angle, double radius, double centerX, double centerY)
 {
     return(new Point((int)Math.Round(Math2.Cos(angle) * radius + centerX), (int)Math.Round(Math2.Sin(angle) * radius + centerY)));
 }
Example #30
0
 public static double Cos(double angle)
 {
     return(Math.Cos(Math2.Radians(angle)));
 }