This documentation is for the old version. Go to the latest Graphics Mill docs

Font.HorizontalAlignment Property

Gets/sets horizontal text alignment, i.e. value specifying how to locate the text string relatively X-coordinate of the point of text output (which is retrieved to DrawString(String, Font, Pen, Brush, Int32, Int32) method).

Namespace: Aurigma.GraphicsMill.Drawing
Assembly: Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)

Syntax

Visual Basic
Public Property HorizontalAlignment As HorizontalAlignment
C#
public HorizontalAlignment HorizontalAlignment { get; set; }

Property Value

HorizontalAlignment value specifying horizontal alignment.

Remarks

Default value is Left.

Examples

Visual Basic
'Create Bitmap object
Dim bitmap As New Aurigma.GraphicsMill.Bitmap( _
 Aurigma.GraphicsMill.RgbColor.White, 100, 100, _
 Aurigma.GraphicsMill.PixelFormat.Format24bppRgb)

Dim graphics As Aurigma.GraphicsMill.Drawing.GdiGraphics = bitmap.GetGdiGraphics

Dim pen As New Aurigma.GraphicsMill.Drawing.Pen(Aurigma.GraphicsMill.RgbColor.Red, 1)

graphics.DrawLine(pen, 50, 0, 50, 100)

Dim brush As New Aurigma.GraphicsMill.Drawing.SolidBrush( _
 Aurigma.GraphicsMill.RgbColor.Black)

' Adjust font settings
Dim font As New Aurigma.GraphicsMill.Drawing.Font("Arial", 20, False, False)

'Draw text with different horizontal alignments        
font.HorizontalAlignment = Aurigma.GraphicsMill.Drawing.HorizontalAlignment.Left
graphics.DrawString("Left", font, brush, 50, 0)

font.HorizontalAlignment = Aurigma.GraphicsMill.Drawing.HorizontalAlignment.Center
graphics.DrawString("Center", font, brush, 50, 33)

font.HorizontalAlignment = Aurigma.GraphicsMill.Drawing.HorizontalAlignment.Right
graphics.DrawString("Right", font, brush, 50, 63)
C#
Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap(
    Aurigma.GraphicsMill.RgbColor.White, 100, 100, 
    Aurigma.GraphicsMill.PixelFormat.Format24bppRgb);

Aurigma.GraphicsMill.Drawing.GdiGraphics graphics = bitmap.GetGdiGraphics();

Aurigma.GraphicsMill.Drawing.Pen pen = new Aurigma.GraphicsMill.Drawing.Pen(
    Aurigma.GraphicsMill.RgbColor.Red, 1);

graphics.DrawLine(pen, 50, 0, 50, 100);

Aurigma.GraphicsMill.Drawing.SolidBrush brush = 
    new Aurigma.GraphicsMill.Drawing.SolidBrush(Aurigma.GraphicsMill.RgbColor.Black);

//Adjust font settings
Aurigma.GraphicsMill.Drawing.Font font = 
    new Aurigma.GraphicsMill.Drawing.Font("Arial", 20, false, false);

//Draw text with different horizontal alignments        
font.HorizontalAlignment = Aurigma.GraphicsMill.Drawing.HorizontalAlignment.Left;
graphics.DrawString("Left", font, brush, 50, 0);

font.HorizontalAlignment = Aurigma.GraphicsMill.Drawing.HorizontalAlignment.Center;
graphics.DrawString("Center", font, brush, 50, 33);

font.HorizontalAlignment = Aurigma.GraphicsMill.Drawing.HorizontalAlignment.Right;
graphics.DrawString("Right", font, brush, 50, 63);

See Also

Reference