/// <summary> /// Draw this shape onto a bitmap. /// </summary> /// <param name="graphics">Graphics object to draw with.</param> /// <param name="cache">Gdi cache.</param> public void DrawShape(Graphics graphics, GdiCache cache) { if (!IsValid) { return; } PointF point = cache.Projection.MapToBitmap(Location); PointF anchor = point; Font font = cache.ParseFont(Font, out string _); if (font == null) { font = SystemFonts.CaptionFont; } Brush fill = new SolidBrush(Colour); SizeF size = graphics.MeasureString(Text, font); point.X -= 0.5f * size.Width; point.Y -= 0.5f * size.Height; if (!HorizontalAlignment.Equals(0.0)) { float dx = (float)HorizontalAlignment * 0.5f * size.Width; point.X += dx; } if (!VerticalAlignment.Equals(0.0)) { float dy = (float)VerticalAlignment * 0.5f * size.Height; point.Y += dy; } if (Rotation.Equals(0.0)) { graphics.DrawString(Text, font, fill, point); } else { System.Drawing.Drawing2D.Matrix matrix = graphics.Transform; System.Drawing.Drawing2D.Matrix rot = matrix.Clone(); rot.RotateAt((float)Rotation, anchor); graphics.Transform = rot; graphics.DrawString(Text, font, fill, point); graphics.Transform = matrix; } fill.Dispose(); }
public Boolean Equals(IXLRichString other) { return (Text == other.Text && Bold.Equals(other.Bold) && Italic.Equals(other.Italic) && Underline.Equals(other.Underline) && Strikethrough.Equals(other.Strikethrough) && VerticalAlignment.Equals(other.VerticalAlignment) && Shadow.Equals(other.Shadow) && FontSize.Equals(other.FontSize) && FontColor.Equals(other.FontColor) && FontName.Equals(other.FontName) && FontFamilyNumbering.Equals(other.FontFamilyNumbering) ); }