public override void RecalcLayout() { if (NeedRecalcLayout == true) { base.RecalcLayout(); _LabelPoint = null; if (String.IsNullOrEmpty(_Text) == false) { if (Scale is GaugeCircularScale) CalcCircularLabelPoint(Scale as GaugeCircularScale); else if (Scale is GaugeLinearScale) CalcLinearLabelPoint(Scale as GaugeLinearScale); } } }
private bool CanDisplayLabel(LabelPoint labelPoint) { if (labelPoint.Visible == false) return (false); if (Scale.HasCustomLabels == true) { foreach (GaugeCustomLabel label in Scale.CustomLabels) { if (label.Visible == true) { if (label.Layout.Placement == Layout.Placement) { if (label.Value == Scale.MinValue + labelPoint.Interval) return (false); } } } } return (true); }
private Color GetLabelColor(LabelPoint lp) { Color labelColor = Scale.GetRangeLabelColor(lp.Interval); if (labelColor.IsEmpty == true) labelColor = Scale.GetSectionLabelColor(lp.Interval); if (labelColor.IsEmpty == true) labelColor = Layout.ForeColor; return (labelColor); }
private SolidBrush GetLabelBrush(SolidBrush br, LabelPoint lp) { Color color = GetLabelColor(lp); if (br == null || br.Color != color) { if (br != null) br.Dispose(); br = new SolidBrush(color); } return (br); }
private string GetLabelText(LabelPoint labelPoint) { double n = Scale.GetIntervalValue(labelPoint.Interval); if (String.IsNullOrEmpty(_FormatString) == false) { try { switch (_FormatString[0]) { case 'X': case 'x': return (String.Format("{0:" + _FormatString + "}", (int) n)); default: return (String.Format("{0:" + _FormatString + "}", n)); } } catch { } } return (n.ToString()); }
private void CalcVerticalLabelPoints(GaugeLinearScale scale, int n, double dpt, double labelInterval, double labelIntervalOffset) { double interval = (_ShowMinLabel == true ? 0 : labelIntervalOffset > 0 ? labelIntervalOffset : labelInterval); int x = scale.ScaleBounds.X + Offset; _LabelPoints = new LabelPoint[n]; for (int i = 0; i < n; i++) { _LabelPoints[i] = new LabelPoint(); if (interval + Scale.MinValue > Scale.MaxValue) interval = Scale.MaxValue - Scale.MinValue; int y = (scale.Reversed == true) ? (int)(Scale.Bounds.Top + dpt * interval) : (int)(Scale.Bounds.Bottom - dpt * interval); _LabelPoints[i].Point = new Point(x, y); _LabelPoints[i].Interval = interval; if (interval >= labelIntervalOffset) interval += labelInterval; else interval = labelIntervalOffset; } }
private void CalcCircularLabelPoints(GaugeCircularScale scale) { double labelInterval = (_Interval.Equals(double.NaN) ? scale.MajorTickMarks.Interval : _Interval); double labelIntervalOffset = (_IntervalOffset.Equals(double.NaN) ? scale.MajorTickMarks.IntervalOffset : _IntervalOffset); double spread = scale.MaxValue - scale.MinValue; double dpt = scale.SweepAngle / spread; int n = GetPointCount(spread, labelInterval, labelIntervalOffset); if (n > 0) { double startAngle = scale.StartAngle; double interval = (_ShowMinLabel == true ? 0 : labelIntervalOffset > 0 ? labelIntervalOffset : labelInterval); int dir = (scale.Reversed ? -1 : 1); if (scale.Reversed == true) startAngle += scale.SweepAngle; _LabelPoints = new LabelPoint[n]; for (int i = 0; i < n; i++) { _LabelPoints[i] = new LabelPoint(); if (interval + scale.MinValue > scale.MaxValue) interval = scale.MaxValue - scale.MinValue; _LabelPoints[i].Angle = (float)(startAngle + (interval * dpt) * dir); _LabelPoints[i].Point = scale.GetPoint(Radius, _LabelPoints[i].Angle); _LabelPoints[i].Interval = interval; if (interval >= labelIntervalOffset) interval += labelInterval; else interval = labelIntervalOffset; } } else { _LabelPoints = null; } }
private void CalcCircularLabelPoint(GaugeCircularScale scale) { if (Radius > 0) { _LabelPoint = new LabelPoint(); _LabelPoint.Angle = _GaugePin.Angle; _LabelPoint.Point = scale.GetPoint(Radius, _LabelPoint.Angle); } }
internal void PaintAdaptiveLabel(Graphics g, string text, Brush br, LabelPoint lp, Font font) { SizeF tw = g.MeasureString(text, font); if (Layout.Placement == DisplayPlacement.Near) tw.Width += text.Length; float c = (float)(Math.PI * _Radius * 2); if (c > 0) { float radians = (float)GetRadians(lp.Angle); float radOffset = (float)GetRadians((180 * tw.Width) / c); float radCenter = radians; radians -= radOffset; bool flip = false; if (_Layout.AutoOrientLabel == true) { flip = ((GetDegrees(radCenter) % 360) < 180); if (flip == true) radians += (radOffset * 2); } int n = (int)Math.Ceiling((double)text.Length / 32); for (int i = 0; i < n; i++) { int len = Math.Min(text.Length - (i * 32), 32); radians = PaintAdaptiveText(g, text.Substring(i * 32, len), br, font, radians, flip); } } }
private void CalcLinearLabelPoint(GaugeLinearScale scale) { _LabelPoint = new LabelPoint(); if (scale.Orientation == Orientation.Horizontal) { _LabelPoint.Point = new Point( _GaugePin.Bounds.X + _GaugePin.Bounds.Width / 2, scale.ScaleBounds.Y + Offset); } else { _LabelPoint.Point = new Point( scale.ScaleBounds.X + Offset, _GaugePin.Bounds.Y + _GaugePin.Bounds.Height / 2); } }
internal void PaintNonRotatedLabel(Graphics g, string text, Brush br, LabelPoint lp, Font font) { SizeF sz = g.MeasureString(text, font); Size size = sz.ToSize(); float fontAngle = 360 - ((lp.Angle + Layout.Angle + 90) % 360); g.TranslateTransform(lp.Point.X, lp.Point.Y); g.RotateTransform((lp.Angle + 90) % 360); g.TranslateTransform(0, GetRadiusDelta(size.Width, size.Height, fontAngle)); g.RotateTransform(fontAngle % 360); g.DrawString(text, font, br, new Point(-size.Width / 2, -size.Height / 2)); g.ResetTransform(); }
private void PaintLinearRotatedLabel(Graphics g, string text, Brush br, LabelPoint lp, Font font, GaugeLinearScale scale) { SizeF sz = g.MeasureString(text, font); Size size = sz.ToSize(); float fontAngle = Layout.Angle; g.TranslateTransform(lp.Point.X, lp.Point.Y); if (scale.Orientation == Orientation.Horizontal) g.TranslateTransform(0, -GetRadiusDelta(size.Width, size.Height, fontAngle)); else g.TranslateTransform(-GetRadiusDelta(size.Height, size.Width, fontAngle), 0); g.RotateTransform(fontAngle % 360); g.DrawString(text, font, br, new Point(-size.Width / 2, -size.Height / 2)); g.ResetTransform(); }
private void PaintCircularRotatedLabel( Graphics g, string text, Brush br, LabelPoint lp, Font font) { SizeF sz = g.MeasureString(text, font); Size size = sz.ToSize(); float fontAngle = Layout.Angle; if (Layout.AutoOrientLabel == true) { if (((fontAngle + lp.Angle) % 360) < 180) fontAngle += 180; } g.TranslateTransform(lp.Point.X, lp.Point.Y); g.RotateTransform((lp.Angle + 90) % 360); g.TranslateTransform(0, GetRadiusDelta(size.Width, size.Height, fontAngle)); g.RotateTransform(fontAngle % 360); g.DrawString(text, font, br, new Point(-size.Width / 2, -size.Height / 2)); g.ResetTransform(); }
internal void PaintRotatedLabel(Graphics g, string text, Brush br, LabelPoint lp, Font font) { if (Scale is GaugeCircularScale) PaintCircularRotatedLabel(g, text, br, lp, font); else if (Scale is GaugeLinearScale) PaintLinearRotatedLabel(g, text, br, lp, font, Scale as GaugeLinearScale); }
internal void PaintLabel(Graphics g, string text, Brush br, LabelPoint lp, Font font) { if (Scale.Style == GaugeScaleStyle.Circular) { if (Layout.AdaptiveLabel == true) { PaintAdaptiveLabel(g, text, br, lp, font); } else { if (Layout.RotateLabel == true) PaintRotatedLabel(g, text, br, lp, font); else PaintNonRotatedLabel(g, text, br, lp, font); } } else { PaintRotatedLabel(g, text, br, lp, font); } }