/// <summary> /// Renders the contour label background. /// </summary> /// <param name="rc"> /// The render context. /// </param> /// <param name="cl"> /// The contour label. /// </param> private void RenderLabelBackground(IRenderContext rc, ContourLabel cl) { if (this.LabelBackground != null) { // Calculate background polygon var size = rc.MeasureText(cl.Text, this.ActualFont, this.ActualFontSize, this.ActualFontWeight); double a = cl.Angle / 180 * Math.PI; double dx = Math.Cos(a); double dy = Math.Sin(a); double ux = dx * 0.6; double uy = dy * 0.6; double vx = -dy * 0.5; double vy = dx * 0.5; double x = cl.Position.X; double y = cl.Position.Y; var bpts = new[] { new ScreenPoint(x - (size.Width * ux) - (size.Height * vx), y - (size.Width * uy) - (size.Height * vy)), new ScreenPoint(x + (size.Width * ux) - (size.Height * vx), y + (size.Width * uy) - (size.Height * vy)), new ScreenPoint(x + (size.Width * ux) + (size.Height * vx), y + (size.Width * uy) + (size.Height * vy)), new ScreenPoint(x - (size.Width * ux) + (size.Height * vx), y - (size.Width * uy) + (size.Height * vy)) }; rc.DrawPolygon(bpts, this.LabelBackground, null); } }
/// <summary> /// Renders the contour label. /// </summary> /// <param name="rc"> /// The render context. /// </param> /// <param name="cl"> /// The contour label. /// </param> private void RenderLabel(IRenderContext rc, ContourLabel cl) { if (this.ActualFontSize > 0) { rc.DrawText( cl.Position, cl.Text, this.ActualTextColor, this.ActualFont, this.ActualFontSize, this.ActualFontWeight, cl.Angle, HorizontalTextAlign.Center, VerticalTextAlign.Middle); } }
/// <summary> /// Renders the contour label background. /// </summary> /// <param name="rc">The render context.</param> /// <param name="cl">The contour label.</param> private void RenderLabelBackground(IRenderContext rc, ContourLabel cl) { if (this.LabelBackground.IsInvisible()) { return; } // Calculate background polygon var size = rc.MeasureText(cl.Text, this.ActualFont, this.ActualFontSize, this.ActualFontWeight); double a = cl.Angle / 180 * Math.PI; double dx = Math.Cos(a); double dy = Math.Sin(a); double ux = dx * 0.6; double uy = dy * 0.6; double vx = -dy * 0.5; double vy = dx * 0.5; double x = cl.Position.X; double y = cl.Position.Y; var bpts = new[] { new ScreenPoint(x - (size.Width * ux) - (size.Height * vx), y - (size.Width * uy) - (size.Height * vy)), new ScreenPoint(x + (size.Width * ux) - (size.Height * vx), y + (size.Width * uy) - (size.Height * vy)), new ScreenPoint(x + (size.Width * ux) + (size.Height * vx), y + (size.Width * uy) + (size.Height * vy)), new ScreenPoint(x - (size.Width * ux) + (size.Height * vx), y - (size.Width * uy) + (size.Height * vy)) }; rc.DrawPolygon(bpts, this.LabelBackground, OxyColors.Undefined); }
/// <summary> /// Renders the contour label. /// </summary> /// <param name="rc">The render context.</param> /// <param name="cl">The contour label.</param> private void RenderLabel(IRenderContext rc, ContourLabel cl) { if (this.ActualFontSize > 0) { rc.DrawText( cl.Position, cl.Text, this.ActualTextColor, this.ActualFont, this.ActualFontSize, this.ActualFontWeight, cl.Angle, HorizontalAlignment.Center, VerticalAlignment.Middle); } }