/// <summary> /// Set a specific layout. /// </summary> /// <param name="font">Font to use.</param> /// <param name="text">The text to write.</param> /// <param name="area">The area in which the text should be written.</param> /// <param name="color">The color of the text.</param> /// <param name="alignment">How the text should be aligned within the text area.</param> /// <param name="layoutMode">How the engine should handle multiple lines.</param> /// <param name="layoutOptions">Different options for the layout engine.</param> public void Set(Font font, string text, RectangleF area, Color color, AlignmentType alignment = AlignmentType.NorthWest, LayoutModeType layoutMode = LayoutModeType.WordWrap, LayoutOptionsType layoutOptions = 0) { if (this.font != font || textString != text || !MathTools.Equals(position, area.TopLeft) || !MathTools.Equals(size, area.Size) || this.color != color || this.alignment != alignment || this.layoutMode != layoutMode || this.layoutOptions != layoutOptions) { this.font = font; textString = text; position = area.TopLeft; size = area.Size; this.color = color; this.alignment = alignment; this.layoutMode = layoutMode; this.layoutOptions = layoutOptions; UpdateLayout(); } }
/// <summary> /// Create a new layout instance with all settings preset. /// </summary> /// <param name="font">Font to use.</param> /// <param name="text">The text to write.</param> /// <param name="area">The area in which the text should be written.</param> /// <param name="color">The color of the text.</param> /// <param name="alignment">How the text should be aligned within the text area.</param> /// <param name="layoutMode">How the engine should handle multiple lines.</param> /// <param name="layoutOptions">Different options for the layout engine.</param> public FontLayout(Font font, string text, RectangleF area, Color color, AlignmentType alignment = AlignmentType.NorthWest, LayoutModeType layoutMode = LayoutModeType.WordWrap, LayoutOptionsType layoutOptions = 0) : this() { Set(font, text, area, color, alignment, layoutMode, layoutOptions); }