Exemplo n.º 1
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);
        }
Exemplo n.º 2
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)));
 }
        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);
        }
Exemplo n.º 4
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)));
 }