3 using System.Drawing.Drawing2D;
4 using System.Collections;
7 using image = java.awt.image;
8 using geom = java.awt.geom;
11 namespace System.Drawing
13 public abstract class Brush : MarshalByRefObject, ICloneable, IDisposable, awt.Paint {
14 protected abstract java.awt.Paint NativeObject {
18 awt.PaintContext awt.Paint.createContext (image.ColorModel cm,
19 awt.Rectangle deviceBounds, geom.Rectangle2D userBounds, geom.AffineTransform xform,
20 awt.RenderingHints hints) {
22 return createContextInternal(cm, deviceBounds, userBounds, xform, hints);
25 protected virtual awt.PaintContext createContextInternal (image.ColorModel cm,
26 awt.Rectangle deviceBounds, geom.Rectangle2D userBounds, geom.AffineTransform xform,
27 awt.RenderingHints hints) {
29 Matrix.Multiply(xform, _brushTransform.NativeObject, MatrixOrder.Append);
30 return NativeObject.createContext (cm, deviceBounds, userBounds, xform, hints);
33 int awt.Transparency.getTransparency () {
34 return NativeObject.getTransparency ();
37 abstract public object Clone ();
39 public void Dispose () {
43 protected virtual void Dispose (bool disposing) {
46 #region Brush transform
48 private readonly Matrix _brushTransform = new Matrix();
50 protected Matrix BrushTransform {
51 get { return _brushTransform.Clone(); }
54 throw new ArgumentNullException("matrix");
56 value.CopyTo( _brushTransform );
60 protected void BrushTranslateTransform (float dx, float dy) {
61 BrushTranslateTransform(dx, dy, MatrixOrder.Prepend);
63 protected void BrushTranslateTransform (float dx, float dy, MatrixOrder order) {
64 _brushTransform.Translate(dx,dy,order);
66 protected void BrushResetTransform () {
67 _brushTransform.Reset();
69 protected void BrushRotateTransform (float angle) {
70 BrushRotateTransform(angle, MatrixOrder.Prepend);
72 protected void BrushRotateTransform (float angle, MatrixOrder order) {
73 _brushTransform.Rotate(angle, order);
75 protected void BrushScaleTransform (float sx, float sy) {
76 BrushScaleTransform(sx, sy, MatrixOrder.Prepend);
78 protected void BrushScaleTransform (float sx, float sy, MatrixOrder order) {
79 _brushTransform.Scale(sx, sy, order);
81 protected void BrushMultiplyTransform (Matrix matrix) {
82 BrushMultiplyTransform(matrix, MatrixOrder.Prepend);
84 protected void BrushMultiplyTransform (Matrix matrix, MatrixOrder order) {
86 throw new ArgumentNullException("matrix");
\r
87 _brushTransform.Multiply(matrix, order);
92 // TODO: implement transform methods.