public ScaleTickMid AddTickMid(double value, bool permanent) { if (this.Range.ScaleType != 0 && value <= 0.0) { return(null); } ScaleTickMid scaleTickMid = new ScaleTickMid(); scaleTickMid.Value = value; scaleTickMid.Color = this.TickMid.Color; scaleTickMid.ForeColor = this.TickMid.ForeColor; scaleTickMid.Font = this.TickMid.Font; scaleTickMid.Thickness = this.TickMid.Thickness; scaleTickMid.Length = this.TickMid.Length; scaleTickMid.TextVisible = this.TickMid.TextVisible; scaleTickMid.TextMargin = this.TickMid.TextMargin; scaleTickMid.Alignment = this.TickMid.Alignment; scaleTickMid.Permanent = permanent; if (this.DegreeModeEnabled) { scaleTickMid.Text = this.TextFormatting.GetText(Math2.AngleNormalized(scaleTickMid.Value)); } else { scaleTickMid.Text = this.TextFormatting.GetText(scaleTickMid.Value); } ((ISubClassBase)scaleTickMid).AmbientOwner = this; ((IScaleTickBase)scaleTickMid).Display = this; this.TickList.Add(scaleTickMid); return(scaleTickMid); }
public ScaleTickMajor AddTickMajor(double value, bool permanent) { if (this.Range.ScaleType == ScaleType.Log10 && value <= 0.0) { return(null); } if (this.Range.ScaleType == ScaleType.SplitLinearLog10 && value >= this.Range.SplitStart && value <= 0.0) { return(null); } ScaleTickMajor scaleTickMajor = new ScaleTickMajor(); scaleTickMajor.Value = value; scaleTickMajor.Color = this.TickMajor.Color; scaleTickMajor.ForeColor = this.TickMajor.ForeColor; scaleTickMajor.Font = this.TickMajor.Font; scaleTickMajor.Thickness = this.TickMajor.Thickness; scaleTickMajor.Length = this.TickMajor.Length; scaleTickMajor.TextVisible = this.TickMajor.TextVisible; scaleTickMajor.TextMargin = this.TickMajor.TextMargin; scaleTickMajor.Permanent = permanent; if (this.DegreeModeEnabled) { scaleTickMajor.Text = this.TextFormatting.GetText(Math2.AngleNormalized(scaleTickMajor.Value)); } else { scaleTickMajor.Text = this.TextFormatting.GetText(scaleTickMajor.Value); } ((ISubClassBase)scaleTickMajor).AmbientOwner = this; ((IScaleTickBase)scaleTickMajor).Display = this; this.TickList.Add(scaleTickMajor); return(scaleTickMajor); }
public double ValueToAngle(int value, int count) { if (count < 2) { return(this.AngleMin); } if (!this.Reverse) { return(Math2.AngleNormalized(360.0 - (this.AngleMin - (double)value * this.AngleSpan / (double)(count - 1)))); } return(Math2.AngleNormalized(360.0 - (this.AngleMax + (double)value * this.AngleSpan / (double)(count - 1)))); }
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); }
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))))); }