CustomLineCap クラス

定義

カスタム ユーザー定義の行キャップをカプセル化します。

public ref class CustomLineCap : MarshalByRefObject, ICloneable, IDisposable
public class CustomLineCap : MarshalByRefObject, ICloneable, IDisposable
type CustomLineCap = class
    inherit MarshalByRefObject
    interface ICloneable
    interface IDisposable
Public Class CustomLineCap
Inherits MarshalByRefObject
Implements ICloneable, IDisposable
継承
CustomLineCap
派生
実装

次の例では、 CustomLineCap クラスの使用方法を示します。 この例を実行するには、コードを Windows フォームに貼り付けます。 フォームのPaint イベントを処理し、フォームのDrawCapsイベント処理メソッドからPaintを呼び出し、ePaintEventArgsとして渡します。


protected void DrawCaps(PaintEventArgs e)
{
    GraphicsPath hPath = new GraphicsPath();

    // Create the outline for our custom end cap.
    hPath.AddLine(new Point(0, 0), new Point(0, 5));
    hPath.AddLine(new Point(0, 5), new Point(5, 1));
    hPath.AddLine(new Point(5, 1), new Point(3, 1));

    // Construct the hook-shaped end cap.
    CustomLineCap HookCap = new CustomLineCap(null, hPath);

    // Set the start cap and end cap of the HookCap to be rounded.
    HookCap.SetStrokeCaps(LineCap.Round, LineCap.Round);

    // Create a pen and set end custom start and end
    // caps to the hook cap.
    Pen customCapPen = new Pen(Color.Black, 5);
    customCapPen.CustomStartCap = HookCap;
    customCapPen.CustomEndCap = HookCap;

    // Create a second pen using the start and end caps from
    // the hook cap.
    Pen capPen = new Pen(Color.Red, 10);
    LineCap startCap;
    LineCap endCap;
    HookCap.GetStrokeCaps(out startCap, out endCap);
    capPen.StartCap = startCap;
    capPen.EndCap = endCap;

    // Create a line to draw.
    Point[] points = { new Point(100, 100), new Point(200, 50), 
        new Point(250, 300) };

    // Draw the lines.
    e.Graphics.DrawLines(capPen, points);
    e.Graphics.DrawLines(customCapPen, points);
}
Protected Sub DrawCaps(ByVal e As PaintEventArgs)
    Dim hPath As New GraphicsPath()

    ' Create the outline for our custom end cap.
    hPath.AddLine(New Point(0, 0), New Point(0, 5))
    hPath.AddLine(New Point(0, 5), New Point(5, 1))
    hPath.AddLine(New Point(5, 1), New Point(3, 1))

    ' Construct the hook-shaped end cap.
    Dim HookCap As New CustomLineCap(Nothing, hPath)

    ' Set the start cap and end cap of the HookCap to be rounded.
    HookCap.SetStrokeCaps(LineCap.Round, LineCap.Round)

    ' Create a pen and set end custom start and end
    ' caps to the hook cap.
    Dim customCapPen As New Pen(Color.Black, 5)
    customCapPen.CustomStartCap = HookCap
    customCapPen.CustomEndCap = HookCap

    ' Create a second pen using the start and end caps from
    ' the hook cap.
    Dim capPen As New Pen(Color.Red, 10)
    Dim startCap As LineCap
    Dim endCap As LineCap
    HookCap.GetStrokeCaps(startCap, endCap)
    capPen.StartCap = startCap
    capPen.EndCap = endCap

    ' Create a line to draw.
    Dim points As Point() = {New Point(100, 100), New Point(200, 50), _
        New Point(250, 300)}

    ' Draw the lines.
    e.Graphics.DrawLines(capPen, points)
    e.Graphics.DrawLines(customCapPen, points)

End Sub

注釈

線のキャップは、GDI+ Pen オブジェクトによって描画される線または曲線の始点と終点で使用されます。 GDI+ では、いくつかの定義済みのキャップ スタイルがサポートされ、ユーザーは独自のキャップ スタイルを定義することもできます。 このクラスは、カスタム キャップ スタイルを作成するために使用されます。

Note

.NET 6 以降のバージョンでは、この種類を含む System.Drawing.Common パッケージは、Windows オペレーティング システムでのみサポートされています。 クロスプラットフォーム アプリでこの種類を使用すると、コンパイル時の警告と実行時の例外が発生します。 詳細については、「System.Drawing.Common が Windows でしかサポートされない」を参照してください。

コンストラクター

名前 説明
CustomLineCap(GraphicsPath, GraphicsPath, LineCap, Single)

指定したアウトライン、塗りつぶし、およびインセットを使用して、指定した既存のCustomLineCap列挙体からLineCap クラスの新しいインスタンスを初期化します。

CustomLineCap(GraphicsPath, GraphicsPath, LineCap)

指定したアウトラインと塗りつぶしを使用して、指定した既存のCustomLineCap列挙体からLineCap クラスの新しいインスタンスを初期化します。

CustomLineCap(GraphicsPath, GraphicsPath)

指定したアウトラインと塗りつぶしを使用して、 CustomLineCap クラスの新しいインスタンスを初期化します。

プロパティ

名前 説明
BaseCap

このLineCapの基になるCustomLineCap列挙体を取得または設定します。

BaseInset

キャップと線の間の距離を取得または設定します。

StrokeJoin

このLineJoin オブジェクトを構成する行の結合方法を決定するCustomLineCap列挙体を取得または設定します。

WidthScale

CustomLineCap オブジェクトの幅に対して、この Pen Class オブジェクトをスケーリングする量を取得または設定します。

メソッド

名前 説明
Clone()

この CustomLineCapの正確なコピーを作成します。

CreateObjRef(Type)

リモート オブジェクトとの通信に使用されるプロキシの生成に必要なすべての関連情報を含むオブジェクトを作成します。

(継承元 MarshalByRefObject)
Dispose()

この CustomLineCap オブジェクトで使用されているすべてのリソースを解放します。

Dispose(Boolean)

CustomLineCapによって使用されるアンマネージ リソースを解放し、必要に応じてマネージド リソースを解放します。

Equals(Object)

指定したオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
Finalize()

CustomLineCapがガベージ コレクションによって回収される前に、CustomLineCapがリソースを解放し、その他のクリーンアップ操作を実行できるようにします。

GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetLifetimeService()
古い.

このインスタンスの有効期間ポリシーを制御する現在の有効期間サービス オブジェクトを取得します。

(継承元 MarshalByRefObject)
GetStrokeCaps(LineCap, LineCap)

このカスタム キャップを構成する開始行と終了行に使用されるキャップを取得します。

GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
InitializeLifetimeService()
古い.

このインスタンスの有効期間ポリシーを制御する有効期間サービス オブジェクトを取得します。

(継承元 MarshalByRefObject)
MemberwiseClone()

現在の Objectの簡易コピーを作成します。

(継承元 Object)
MemberwiseClone(Boolean)

現在の MarshalByRefObject オブジェクトの簡易コピーを作成します。

(継承元 MarshalByRefObject)
SetStrokeCaps(LineCap, LineCap)

このカスタム キャップを構成する開始線と終了線に使用するキャップを設定します。

ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象