' Classes/System/Drawing/Pen.ab Namespace System Namespace Drawing Namespace Drawing2D Class CustomLineCap Public Function NativeCap() As *GpCustomLineCap End Function End Class End Namespace Class Pen Implements IDisposable, ICloneable Public Sub Pen(native As *GpPen) nativePen = native End Sub Sub Pen(color As Color, width = 1.0 As Single) SetStatus(GdipCreatePen1(color, width, 0 /*GraphicsUnit.World As GpUnit*/, nativePen)) End Sub Sub Pen(brush As Brush, width = 1.0 As Single) If ActiveBasic.IsNothing(brush) Then Throw New ArgumentNullException("brush") End If SetStatus(GdipCreatePen2(brush.NativeBrush, width, 0 /*GraphicsUnit.World As GpUnit*/, nativePen)) End Sub Sub Dispose() If nativePen <> 0 Then GdipDeletePen(nativePen) End If nativePen = 0 End Sub Sub ~Pen() Dispose() End Sub Function Clone() As Pen Dim cloned As *GpPen SetStatus(GdipClonePen(nativePen, cloned)) Clone = New Pen(cloned) End Function Function NativePen() As *GpPen NativePen = nativePen End Function '========================================================================= ' Properties '========================================================================= Sub Width(width As Single) SetStatus(GdipSetPenWidth(nativePen, width)) End Sub Function Width() As Single SetStatus(GdipGetPenWidth(nativePen, Width)) End Function Sub StartCap(cap As Drawing2D.LineCap) SetStatus(GdipSetPenStartCap(nativePen, cap)) End Sub /* Function StartCap() As Drawing2D.LineCap SetStatus(GdipGetPenStartCap(nativePen, StartCap)) End Function */ Sub EndCap(cap As Drawing2D.LineCap) SetStatus(GdipSetPenEndCap(nativePen, cap)) End Sub /* Function EndCap() As Drawing2D.LineCap SetStatus(GdipGetPenEndCap(nativePen, EndCap)) End Function */ Sub DashCap(cap As Drawing2D.DashCap) SetStatus(GdipSetPenDashCap197819(nativePen, cap)) End Sub /* Function DashCap() As Drawing2D.DashCap SetStatus(GdipGetPenDashCap197819(nativePen, DashCap)) End Function */ Sub LineJoin(lineJoin As Drawing2D.LineJoin) SetStatus(GdipSetPenLineJoin(nativePen, lineJoin)) End Sub /* Function LineJoin() As Drawing2D.LineJoin SetStatus(GdipGetPenLineJoin(nativePen, LineJoin)) End Function */ Sub CustomStartCap(cap As Drawing2D.CustomLineCap) SetStatus(GdipSetPenCustomStartCap(nativePen, getNativeCustomCap(cap))) End Sub /* Function CustomStartCap() As Drawing2D.CustomLineCap Dim native As *GpCustomLineCap SetStatus(GdipGetPenCustomStartCap(nativePen, native)) CustomStartCap = New Drawing2D.CustomStartCap(native) End Function */ Sub CustomEndCap(cap As Drawing2D.CustomLineCap) SetStatus(GdipSetPenCustomEndCap(nativePen, getNativeCustomCap(cap))) End Sub /* Function CustomEndCap() As Drawing2D.CustomLineCap Dim nativeCustomCap As *GpCustomLineCap SetStatus(GdipGetPenCustomEndCap(nativePen, nativeCustomCap)) CustomStartCap = New CustomStartCap(nativeCustomCap) End Function */ Sub MiterLimit(miterLimit As Single) SetStatus(GdipSetPenMiterLimit(nativePen, miterLimit)) End Sub Function MiterLimit() As Single SetStatus(GdipGetPenMiterLimit(nativePen, MiterLimit)) End Function Sub Alignment(alignment As Drawing2D.PenAlignment) SetStatus(GdipSetPenMode(nativePen, alignment)) End Sub /* Function Alignment() As Drawing2D.PenAlignment SetStatus(GdipGetPenMode(nativePen, Alignment)) End Function */ Sub Transform(m As Drawing2D.Matrix) SetStatus(GdipSetPenTransform(nativePen, m.NativeMatrix)) End Sub Function Transform() As Drawing2D.Matrix Dim native As *GpMatrix SetStatus(GdipGetPenTransform(nativePen, native)) Transform = New Matrix(native) End Function /* Function PenType() As Drawing2D.PenType SetStatus(GdipGetPenFillType(nativePen, PenType)) End Function */ Sub Color(color As Color) SetStatus(GdipSetPenColor(nativePen, color)) End Sub /* Function Color() As Color If This.PenType <> Drawing2D.PenType.SolidColor Then SetStatus(State.WrongState) End If SetStatus(GdipGetPenColor(nativePen, Color)) End Function */ Sub Brush(brush As Brush) SetStatus(GdipSetPenBrushFill(nativePen, getNativeBrush(brush))) End Sub /* Function Brush() As Brush Imports Drawing2D Dim penType = PenType Dim native As *GpBrush Select Case penType Case PenType.SolidColor SetStatus(GdipGetPenBrushFill(nativePen, native)) Brush = New SolidBrush(native) Case PenType.HatchFill SetStatus(GdipGetPenBrushFill(nativePen, native)) Brush = New HatchBrush(native) Case PenType.TextureFill SetStatus(GdipGetPenBrushFill(nativePen, native)) Brush = New TextureBrush(native) Case PenType.Gradient SetStatus(GdipGetPenBrushFill(nativePen, native)) Brush = New Brush(native) Case PenType.LinearGradient SetStatus(GdipGetPenBrushFill(nativePen, native)) Brush = New LinearGradientBrush(native) Case Else Brush = Nothing End Select End Function */ Sub DashStyle(dashStyle As Drawing2D.DashStyle) SetStatus(GdipSetPenDashStyle(nativePen, dashStyle)) End Sub /* Function DashStyle() As Drawing2D.DashStyle SetStatus(GdipGetPenDashStyle(nativePen, DashStyle)) End Function */ Sub DashOffset(dashOffset As Single) SetStatus(GdipSetPenDashOffset(nativePen, dashOffset)) End Sub Function DashOffset() As Single SetStatus(GdipGetPenDashOffset(nativePen, DashOffset)) End Function 'DashPattern 'CompoundArray '========================================================================= ' Functions '========================================================================= Sub SetLineCap(startCap As Drawing2D.LineCap, endCap As Drawing2D.LineCap, dashCap As Drawing2D.DashCap) SetStatus(GdipSetPenLineCap197819(nativePen, startCap, endCap, dashCap)) End Sub Sub ResetTransform() SetStatus(GdipResetPenTransform(nativePen)) End Sub Sub MultiplyTransform(m As Drawing2D.Matrix) Imports System.Drawing.Drawing2D MultiplyTransform(m, MatrixOrder.Prepend) End Sub Sub MultiplyTransform(m As Drawing2D.Matrix, order As Drawing2D.MatrixOrder) SetStatus(GdipMultiplyPenTransform(nativePen, m.nativeMatrix, order)) End Sub Sub TranslateTransform(dx As Single, dy As Single) Imports System.Drawing.Drawing2D TranslateTransform(dx, dy, MatrixOrder.Prepend) End Sub Sub TranslateTransform(dx As Single, dy As Single, order As Drawing2D.MatrixOrder) SetStatus(GdipTranslatePenTransform(nativePen, dx, dy, order)) End Sub Sub ScaleTransform(sx As Single, sy As Single) Imports System.Drawing.Drawing2D ScaleTransform(sx, sy, MatrixOrder.Prepend) End Sub Sub ScaleTransform(sx As Single, sy As Single, order As Drawing2D.MatrixOrder) SetStatus(GdipScalePenTransform(nativePen, sx, sy, order)) End Sub Sub RotateTransform(angle As Single) Imports System.Drawing.Drawing2D RotateTransform(angle, MatrixOrder.Prepend) End Sub Sub RotateTransform(angle As Single, order As Drawing2D.MatrixOrder) SetStatus(GdipRotatePenTransform(nativePen, angle, order)) End Sub Private nativePen As *GpPen Static Function getNativeCustomCap(cap As Drawing2D.CustomLineCap) As *GpCustomLineCap If ActiveBasic.IsNothing(cap) Then getNativeCustomCap = 0 Else getNativeCustomCap = cap.NativeCap End If End Function Static Function getNativeBrush(br As Brush) As *GpBrush If ActiveBasic.IsNothing(br) Then getNativeBrush = 0 Else getNativeBrush = br.NativeBrush End If End Function End Class End Namespace End Namespace