英語で読む

次の方法で共有


Graphics.PageScale プロパティ

定義

この Graphics のワールド単位とパージ単位の間のスケーリングを取得または設定します。

public float PageScale { get; set; }

プロパティ値

このプロパティは、この Graphics のワールド単位とパージ単位の間のスケーリングの値を指定します。

次のコード例では、 メンバーと TranslateTransform メンバーを使用PageScaleして、四角形を描画するときにスケールと原点を変更する方法を示します。

この例は、Windows フォームで使用するように設計されています。 フォームにコードを貼り付け、フォームのイベントをChangePageScaleAndTranslateTransform処理するときに メソッドをPaint呼び出し、 を としてPaintEventArgs渡しますe

private void ChangePageScaleAndTranslateTransform(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.PageScale = 2.0F;

    // Call TranslateTransform to change the origin of the
    //  Graphics object.
    e.Graphics.TranslateTransform(10.0F, 10.0F);

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

    // Set the page scale and origin back to their original values.
    e.Graphics.PageScale = 1.0F;
    e.Graphics.ResetTransform();

    SolidBrush transparentBrush = new SolidBrush(Color.FromArgb(50,
        Color.Yellow));

    // Create a new rectangle with the coordinates you expect
    // after setting PageScale and calling TranslateTransform:
    // x = (10 + 20) * 2
    // y = (10 + 20) * 2
    // Width = 50 * 2
    // Length = 100 * 2
    Rectangle newRectangle = new Rectangle(60, 60, 100, 200);

    // Fill in the rectangle with a semi-transparent color.
    e.Graphics.FillRectangle(transparentBrush, newRectangle);
}

適用対象

製品 バージョン
.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
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

こちらもご覧ください