' Classes/System/Drawing/Brush.ab Namespace System Namespace Drawing Class Brush Implements IDisposable, ICloneable Public Sub Dispose() GdipDeleteBrush(nativeBrush) nativeBrush = 0 End Sub Sub ~Brush() Dispose() End Sub Function Clone() As Brush Dim brush As *GpBrush SetStatus(GdipCloneBrush(nativeBrush, brush)) Try Clone = New Brush(brush) Catch e As Exception GdipDeleteBrush(brush) Throw e End Try End Function Function GetType() As BrushType GetType = -1 As BrushType SetStatus(GdipGetBrushType(nativeBrush, GetType)) End Function Function NativeBrush() As *GpBrush NativeBrush = nativeBrush End Function Sub Brush(native As *GpBrush) nativeBrush = native End Sub Private nativeBrush As *GpBrush End Class Class SolidBrush Inherits Brush Public Sub SolidBrush(c As Color) Brush(CreateSolidBrush(c)) End Sub Function Color() As Color SetStatus(GdipGetSolidFillColor(nativeBrush As *GpSolidFill, Color)) End Function Sub SetColor(c As Color) SetStatus(GdipSetSolidFillColor(nativeBrush As *GpSolidFill, c)) End Sub Private Static Function CreateSolidBrush(c As Color) As *GpBrush SetStatus(GdipCreateSolidFill(c, CreateSolidBrush)) End Function End Class Class TextureBrush Inherits Brush Public Sub TextureBrush(image As Image) 'Žb’è Brush(CreateTexture(image.NativeImage, System.Drawing.Drawing2D.WrapMode.Tile) As *GpBrush) End Sub Sub TextureBrush(image As Image, wrapMode /*= WrapMode.Tile*/ As Drawing2D.WrapMode) Brush(CreateTexture(image.NativeImage, wrapMode) As *GpBrush) End Sub Static Function CreateTexture(image As *GpImage, wrapMode As Drawing2D.WrapMode) As *GpTexture SetStatus(GdipCreateTexture(image, wrapMode, CreateTexture)) End Function Sub TextureBrush(image As Image, wrapMode As Drawing2D.WrapMode, ByRef dstRect As Rectangle) Brush(CreateTexture2I(image.NativeImage, wrapMode, dstRect) As *GpBrush) End Sub Static Function CreateTexture2I(image As *GpImage, wrapMode As Drawing2D.WrapMode, ByRef rc As Rectangle) As *GpTexture SetStatus(GdipCreateTexture2I(image, wrapMode, rc.X, rc.Y, rc.Width, rc.Height, CreateTexture2I)) End Function Sub TextureBrush(image As Image, wrapMode As Drawing2D.WrapMode, ByRef dstRect As RectangleF) Brush(CreateTexture2(image.NativeImage, wrapMode, dstRect) As *GpBrush) End Sub Static Function CreateTexture2(image As *GpImage, wrapMode As Drawing2D.WrapMode, ByRef rc As RectangleF) As *GpTexture SetStatus(GdipCreateTexture2(image, wrapMode, rc.X, rc.Y, rc.Width, rc.Height, CreateTexture2)) End Function Sub TextureBrush(image As Image, ByRef dstRect As Rectangle, imageAttributes = Nothing As ImageAttributes) Brush(CreateTextureIAI(image.NativeImage, dstRect, getNativeImageAttributes(imageAttributes)) As *GpBrush) End Sub Static Function CreateTextureIAI(image As *GpImage, ByRef rc As Rectangle, imageAttr = 0 As *GpImageAttributes) As *GpTexture SetStatus(GdipCreateTextureIAI(image, imageAttr, rc.X, rc.Y, rc.Width, rc.Height, CreateTextureIAI)) End Function Sub TextureBrush(image As Image, ByRef dstRect As RectangleF, imageAttributes = Nothing As ImageAttributes) Brush(CreateTextureIA(image.NativeImage, dstRect, getNativeImageAttributes(imageAttributes)) As *GpBrush) End Sub Static Function CreateTextureIA(image As *GpImage, ByRef rc As RectangleF, imageAttr = 0 As *GpImageAttributes) As *GpTexture SetStatus(GdipCreateTextureIA(image, imageAttr, rc.X, rc.Y, rc.Width, rc.Height, CreateTextureIA)) End Function Sub Transform(matrix As Drawing2D.Matrix) SetStatus(GdipSetTextureTransform(nativeBrush As *GpTexture, matrix.NativeMatrix)) End Sub Function Transform() As Drawing2D.Matrix Dim matrix As *GpMatrix SetStatus(GdipGetTextureTransform(nativeBrush As *GpTexture, matrix)) Transform = New Matrix(matrix) End Function Sub ResetTransform() SetStatus(GdipResetTextureTransform(nativeBrush As *GpTexture)) End Sub Sub MultiplyTransform(matrix As Drawing2D.Matrix, order /*= Drawing2D.MatrixOrder.Prepend*/ As Drawing2D.MatrixOrder) SetStatus(GdipMultiplyTextureTransform(nativeBrush As *GpTexture, matrix.NativeMatrix, order)) End Sub Sub TranslateTransform(dx As Single, dy As Single, order /*= Drawing2D.MatrixOrder.Prepend*/ As Drawing2D.MatrixOrder) SetStatus(GdipTranslateTextureTransform(nativeBrush As *GpTexture, dx, dy, order)) End Sub Sub ScaleTransform(sx As Single, sy As Single, order /*= Drawing2D.MatrixOrder.Prepend*/ As Drawing2D.MatrixOrder) SetStatus(GdipScaleTextureTransform(nativeBrush As *GpTexture, sx, sy, order)) End Sub Sub RotateTransform(angle As Single, order /*= Drawing2D.MatrixOrder.Prepend*/ As Drawing2D.MatrixOrder) SetStatus(GdipRotateTextureTransform(nativeBrush As *GpTexture, angle, order)) End Sub Sub WrapMode(wrapMode As Drawing2D.WrapMode) SetStatus(GdipSetTextureWrapMode(nativeBrush As *GpTexture, wrapMode)) End Sub /* Function WrapMode() As Drawing2D.WrapMode SetStatus(GdipGetTextureWrapMode(nativeBrush As *GpTexture, WrapMode)) End Function */ Function GetImage() As Image Dim image As *GpImage SetStatus(GdipGetTextureImage(nativeBrush As *GpTexture, image)) GetImage = New Image(image) End Function Private Static Function getNativeImageAttributes(imageAttr As ImageAttributes) As *GpImageAttributes If ActiveBasic.IsNothing(imageAttr) Then getNativeImageAttributes = 0 Else getNativeImageAttributes = imageAttr.nativeImage End If End Function End Class Namespace Drawing2D Class HatchBrush Inherits Brush Public Sub HatchBrush(hatchStyle As HatchStyle, foreColor As Color, backColor = 0 As Color) Brush(CreateHatchBrush(hatchStyle, foreColor, backColor) As *GpBrush) End Sub /* Function HatchStyle() As HatchStyle SetStatus(GdipGetHatchStyle(NativeBrush As *GpHatch, HatchStyle)) End Function */ Function ForegroundColor() As Color SetStatus(GdipGetHatchForegroundColor(NativeBrush As *GpHatch, ForegroundColor)) End Function Function BackgroundColor() As Color SetStatus(GdipGetHatchBackgroundColor(NativeBrush As *GpHatch, BackgroundColor)) End Function Private Static Function CreateHatchBrush(hatchStyle As HatchStyle, foreColor As ARGB, backColor As ARGB) As *GpHatch SetStatus(GdipCreateHatchBrush(hatchStyle, foreColor, backColor, CreateHatchBrush)) End Function End Class Class LinearGradientBrush Inherits Brush Public Sub LinearGradientBrush(ByRef pt1 As Point, ByRef pt2 As Point, c1 As Color, c2 As Color) Brush(CreateLineBrush(pt1, pt2, c1, c2) As *GpBrush) End Sub Sub LinearGradientBrush(ByRef pt1 As PointF, ByRef pt2 As PointF, c1 As Color, c2 As Color) Brush(CreateLineBrush(pt1, pt2, c1, c2) As *GpBrush) End Sub Sub LinearGradientBrush(ByRef rc As Rectangle, c1 As Color, c2 As Color, mode As LinearGradientMode) Brush(CreateLineBrushFromRect(rc, c1, c2, mode) As *GpBrush) End Sub Sub LinearGradientBrush(ByRef rc As RectangleF, c1 As Color, c2 As Color, mode As LinearGradientMode) Brush(CreateLineBrushFromRect(rc, c1, c2, mode) As *GpBrush) End Sub Sub LinearGradientBrush(ByRef rc As Rectangle, c1 As Color, c2 As Color, angle As Single, isAngleScalable = False As Boolean) Brush(CreateLineBrushFromRectWithAngle(rc, c1, c2, angle, isAngleScalable) As *GpBrush) End Sub Sub LinearGradientBrush(ByRef rc As RectangleF, c1 As Color, c2 As Color, angle As Single, isAngleScalable = False As Boolean) Brush(CreateLineBrushFromRectWithAngle(rc, c1, c2, angle, isAngleScalable) As *GpBrush) End Sub Static Function CreateLineBrush(ByRef pt1 As Point, ByRef pt2 As Point, c1 As ARGB, c2 As ARGB) As *GpLineGradient SetStatus(GdipCreateLineBrushI(pt1, pt2, c1, c2, WrapMode.Tile, CreateLineBrush)) End Function Static Function CreateLineBrush(ByRef pt1 As PointF, ByRef pt2 As PointF, c1 As ARGB, c2 As ARGB) As *GpLineGradient SetStatus(GdipCreateLineBrush(pt1, pt2, c1, c2, WrapMode.Tile, CreateLineBrush)) End Function Static Function CreateLineBrushFromRect(ByRef rc As Rectangle, c1 As ARGB, c2 As ARGB, mode As LinearGradientMode) As *GpLineGradient SetStatus(GdipCreateLineBrushFromRectI(rc, c1, c2, mode, 0 /*WrapMode.Tile*/, CreateLineBrushFromRect)) End Function Static Function CreateLineBrushFromRect(ByRef rc As RectangleF, c1 As ARGB, c2 As ARGB, mode As LinearGradientMode) As *GpLineGradient SetStatus(GdipCreateLineBrushFromRect(rc, c1, c2, mode, 0 /*WrapMode.Tile*/, CreateLineBrushFromRect)) End Function Static Function CreateLineBrushFromRectWithAngle(ByRef rc As Rectangle, c1 As ARGB, c2 As ARGB, angle As Single, isAngleScalable As Boolean) As *GpLineGradient SetStatus(GdipCreateLineBrushFromRectWithAngleI(rc, c1, c2, angle, isAngleScalable, 0 /*WrapMode.Tile*/ , CreateLineBrushFromRectWithAngle)) End Function Static Function CreateLineBrushFromRectWithAngle(ByRef rc As RectangleF, c1 As ARGB, c2 As ARGB, angle As Single, isAngleScalable As Boolean) As *GpLineGradient SetStatus(GdipCreateLineBrushFromRectWithAngle(rc, c1, c2, angle, isAngleScalable, 0 /*WrapMode.Tile*/, CreateLineBrushFromRectWithAngle)) End Function 'LinearColors - GdipGetLineColors/GdipSetLineColors Function Rectangle() As RectangleF SetStatus(GdipGetLineRect(nativeBrush As *GpLineGradient, Rectangle)) End Function Sub GammaCorrection(gammaCorrection As Boolean) SetStatus(GdipSetLineGammaCorrection(nativeBrush As *GpLineGradient, gammaCorrection)) End Sub Function GammaCorrection() As Boolean Dim gammaCorrection As BOOL SetStatus(GdipGetLineGammaCorrection(nativeBrush As *GpLineGradient, gammaCorrection)) GammaCorrection = gammaCorrection As Boolean End Function 'Blend - GdipGetLineBlend/GdipSetLineBlend 'InterpolationColors - GdipGetLinePresetBlend/GdipSetLinePresetBlend Sub SetBlendBellShape(focus As Single, scale = 1.0 As Single) SetStatus(GdipSetLineSigmaBlend(nativeBrush As *GpLineGradient, focus, scale)) End Sub Sub SetBlendTriangularShape(focus As Single, scale = 1.0 As Single) SetStatus(GdipSetLineLinearBlend(nativeBrush As *GpLineGradient, focus, scale)) End Sub Sub Transform(matrix As Matrix) SetStatus(GdipSetLineTransform(nativeBrush As *GpLineGradient, matrix.NativeMatrix)) End Sub Function Transform() As Matrix Dim matrix As *GpMatrix SetStatus(GdipGetLineTransform(nativeBrush As *GpLineGradient, matrix)) Transform = New Matrix(matrix) End Function Sub ResetTransform() SetStatus(GdipResetLineTransform(nativeBrush As *GpLineGradient)) End Sub Sub MultiplyTransform(matrix As Drawing2D.Matrix, order /*= MatrixOrder.Prepend*/ As MatrixOrder) SetStatus(GdipMultiplyLineTransform(nativeBrush As *GpLineGradient, matrix.NativeMatrix, order)) End Sub Sub TranslateTransform(dx As Single, dy As Single, order /*= MatrixOrder.Prepend*/ As MatrixOrder) SetStatus(GdipTranslateLineTransform(nativeBrush As *GpLineGradient, dx, dy, order)) End Sub Sub ScaleTransform(sx As Single, sy As Single, order /*= MatrixOrder.Prepend*/ As MatrixOrder) SetStatus(GdipScaleLineTransform(nativeBrush As *GpLineGradient, sx, sy, order)) End Sub Sub RotateTransform(angle As Single, order /*= MatrixOrder.Prepend*/ As MatrixOrder) SetStatus(GdipRotateLineTransform(nativeBrush As *GpLineGradient, angle, order)) End Sub Sub WrapMode(wrapMode As WrapMode) SetStatus(GdipSetLineWrapMode(nativeBrush As *GpLineGradient, wrapMode)) End Sub /* Function WrapMode() As WrapMode SetStatus(GdipGetLineWrapMode(nativeBrush As *GpLineGradient, WrapMode)) End Function */ End Class Class PathGradientBrush Inherits Brush Public Sub PathGradientBrush(points As *PointF, count As Long, wrapMode /*= WrapMode.Clamp*/ As WrapMode) Brush(CreatePathGradient(points, count, wrapMode)) End Sub Sub PathGradientBrush(points As *Point, count As Long, wrapMode /*= WrapMode.Clamp*/ As WrapMode) Brush(CreatePathGradientI(points, count, wrapMode)) End Sub Sub PathGradientBrush(path As GraphicsPath) Brush(CreatePathGradientFromPath(path.NativePath As *GpBrush)) End Sub Sub CenterColor(c As Color) SetStatus(GdipSetPathGradientCenterColor(nativeBrush As *GpPathGradient, c)) End Sub Function CenterColor() As Color SetStatus(GdipGetPathGradientCenterColor(nativeBrush As *GpPathGradient, CenterColor)) End Function 'SurroundColors - GdipGetPathGradientSurroundColorsWithCount/GdipSetPathGradientSurroundColorsWithCount/GdipGetPathGradientSurroundColorCount Sub GraphicsPath(path As GraphicsPath) If ActiveBasic.IsNothing(path) Then Throw New System.ArgumentNullException("path") End If SetStatus(GdipSetPathGradientPath(nativeBrush As *GpPathGradient, path.NativePath)) End Sub Function GraphicsPath() As GraphicsPath Dim path As *GpPath SetStatus(GdipGetPathGradientPath(nativeBrush As *GpPathGradient, path)) GraphicsPath = New GraphicsPath(path) End Function Sub CenterPoint(ByRef pt As PointF) SetStatus(GdipSetPathGradientCenterPoint(nativeBrush As *GpPathGradient, pt)) End Sub Function CenterPoint() As PointF SetStatus(GdipSetPathGradientCenterPoint(nativeBrush As *GpPathGradient, CenterPoint)) End Function Function Rectangle() As RectangleF SetStatus(GdipGetPathGradientRect(nativeBrush As *GpPathGradient, Rectangle)) End Function Sub GammaCorrection(gammaCorrection As Boolean) SetStatus(GdipSetPathGradientGammaCorrection(nativeBrush As *GpPathGradient, gammaCorrection)) End Sub Function GammaCorrection() As Boolean Dim gammaCorrection As BOOL SetStatus(GdipGetPathGradientGammaCorrection(nativeBrush As *GpPathGradient, gammaCorrection)) GammaCorrection = gammaCorrection As Boolean End Function ' Blend - GdipGetPathGradientBlend/GdipSetPathGradientBlend/GdipGetPathGradientBlendCount ' InterpolationColors - GdipGetPathGradientPresetBlend/GdipSetPathGradientPresetBlend/GdipGetPathGradientPresetBlendCount Sub SetBlendBellShape(focus As Single, scale = 1.0 As Single) SetStatus(GdipSetPathGradientSigmaBlend(nativeBrush As *GpPathGradient, focus, scale)) End Sub Sub SetBlendTriangularShape(focus As Single, scale = 1.0 As Single) SetStatus(GdipSetPathGradientLinearBlend(nativeBrush As *GpPathGradient, focus, scale)) End Sub Sub Transform(matrix As Matrix) SetStatus(GdipSetPathGradientTransform(nativeBrush As *GpPathGradient, matrix.NativeMatrix)) End Sub Function Transform() As Matrix Dim matrix As *GpMatrix SetStatus(GdipGetPathGradientTransform(nativeBrush As *GpPathGradient, matrix)) Transform = New Matrix(matrix) End Function Sub ResetTransform() SetStatus(GdipResetPathGradientTransform(nativeBrush As *GpPathGradient)) End Sub Sub MultiplyTransform(matrix As Drawing2D.Matrix, order /*= MatrixOrder.Prepend*/ As MatrixOrder) SetStatus(GdipMultiplyPathGradientTransform(nativeBrush As *GpPathGradient, matrix.NativeMatrix, order)) End Sub Sub TranslateTransform(dx As Single, dy As Single, order /*= MatrixOrder.Prepend*/ As MatrixOrder) SetStatus(GdipTranslatePathGradientTransform(nativeBrush As *GpPathGradient, dx, dy, order)) End Sub Sub ScaleTransform(sx As Single, sy As Single, order /*= MatrixOrder.Prepend*/ As MatrixOrder) SetStatus(GdipScalePathGradientTransform(nativeBrush As *GpPathGradient, sx, sy, order)) End Sub Sub RotateTransform(angle As Single, order /*= MatrixOrder.Prepend*/ As MatrixOrder) SetStatus(GdipRotatePathGradientTransform(nativeBrush As *GpPathGradient, angle, order)) End Sub Function FocusScales() As PointF SetStatus(GdipGetPathGradientFocusScales(nativeBrush As *GpPathGradient, FocusScales.X, FocusScales.Y)) End Function Sub FocusScales(scale As PointF) SetStatus(GdipSetPathGradientFocusScales(nativeBrush As *GpPathGradient, scale.X, scale.Y)) End Sub Sub WrapMode(wrapMode As WrapMode) SetStatus(GdipSetPathGradientWrapMode(nativeBrush As *GpPathGradient, wrapMode)) End Sub /* Function WrapMode() As WrapMode SetStatus(GdipGetPathGradientWrapMode(nativeBrush As *GpPathGradient, WrapMode)) End Function */ Private Static Function CreatePathGradient(points As *PointF, count As Long, wrapMode As WrapMode) As *GpPathGradient SetStatus(GdipCreatePathGradient(points, count, wrapMode, CreatePathGradient)) End Function Static Function CreatePathGradientI(points As *Point, count As Long, wrapMode As WrapMode) As *GpPathGradient SetStatus(GdipCreatePathGradientI(points, count, wrapMode, CreatePathGradientI)) End Function Static Function CreatePathGradientFromPath(path As *GpPath) As *GpPathGradient SetStatus(GdipCreatePathGradientFromPath(path, CreatePathGradientFromPath)) End Function End Class End Namespace End Namespace End Namespace