Прочетете на английски Редактиране

Споделяне чрез


Graphics.PageUnit Property

Definition

Gets or sets the unit of measure used for page coordinates in this Graphics.

C#
public System.Drawing.GraphicsUnit PageUnit { get; set; }

Property Value

One of the GraphicsUnit values other than World.

Exceptions

PageUnit is set to World, which is not a physical unit.

Examples

The following code example demonstrates the effect of changing the PageUnit property.

This example is designed to be used with Windows Forms. Paste the code into a form and call the ChangePageUnit method when handling the form's Paint event, passing e as PaintEventArgs.

C#
private void ChangePageUnit(PaintEventArgs e)
{

    // Create a rectangle.
    Rectangle rectangle1 = new Rectangle(20, 20, 50, 100);

    // Draw its outline.
    e.Graphics.DrawRectangle(Pens.SlateBlue, rectangle1);

    // Change the page scale.  
    e.Graphics.PageUnit = GraphicsUnit.Point;

    // Draw the rectangle again.
    e.Graphics.DrawRectangle(Pens.Tomato, rectangle1);
}

Remarks

The graphics unit is the unit of measure used for page coordinates in this Graphics.

Applies to

Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also