public void PaintRotatedLabel(Graphics g, string text, LabelLayout layout, int height, Brush br, Font font) { SizeF sz = g.MeasureString(text, font); Size size = sz.ToSize(); Point pt = new Point(0, 0); switch (layout.Placement) { case DisplayPlacement.Far: pt.Y = -height / 2; break; case DisplayPlacement.Near: pt.Y = height / 2; break; } g.TranslateTransform(_Point.X, _Point.Y); g.RotateTransform((_Angle + 90) % 360); g.TranslateTransform(pt.X, pt.Y); float fontAngle = layout.Angle; if (layout.AutoOrientLabel == true) { if (((_Angle + layout.Angle) % 360) < 180) fontAngle += 180; } g.RotateTransform(fontAngle); g.DrawString(text, font, br, new Point(-size.Width / 2, -size.Height / 2)); g.ResetTransform(); }
public GaugeBaseLabel() { _Layout = new LabelLayout(); HookEvents(true); }
internal virtual void CopyToItem(LabelLayout copy) { copy.AdaptiveLabel = _AdaptiveLabel; copy.Angle = _Angle; copy.AutoOrientLabel = _AutoOrientLabel; copy.AutoSize = _AutoSize; if (_Font != null) copy.Font = (Font)_Font.Clone(); copy.ForeColor = _ForeColor; copy.Placement = _Placement; copy.RotateLabel = _RotateLabel; copy.ScaleOffset = _ScaleOffset; }
public void PaintNonRotatedLabel(Graphics g, string text, LabelLayout layout, Point center, int radius, Brush br, Font font) { SizeF sz = g.MeasureString(text, font); int x = _Point.X - center.X; int y = _Point.Y - center.Y; Point pt = new Point(); switch (layout.Placement) { case DisplayPlacement.Far: { int dx = (int)(((float)(x - radius) / (radius * 2)) * sz.Width); int dy = (int)(((float)(y - radius) / (radius * 2)) * sz.Height); pt = new Point(_Point.X + dx, _Point.Y + dy); } break; case DisplayPlacement.Near: { int dx = (int)(((float)(x + radius) / (radius * 2)) * sz.Width); int dy = (int)(((float)(y + radius) / (radius * 2)) * sz.Height); pt = new Point(_Point.X - dx, _Point.Y - dy); } break; case DisplayPlacement.Center: { int dx = (int)(sz.Width / 2); int dy = (int)(sz.Height / 2); pt = new Point(_Point.X - dx, _Point.Y - dy); } break; } g.DrawString(text, font, br, pt); }
public virtual object Clone() { LabelLayout copy = new LabelLayout(); CopyToItem(copy); return (copy); }