fab8ae2a36f0ad78414c153502a356503175a5a0
[mono.git] / mcs / class / System.Drawing / System.Drawing / SolidBrush.cs
1 //
2 // System.Drawing.SolidBrush.cs
3 //
4 // Author:
5 //   Dennis Hayes (dennish@Raytek.com)
6 //   Alexandre Pigolkine(pigolkine@gmx.de)
7 //
8 // (C) 2002 Ximian, Inc
9 //
10 using System;
11
12 namespace System.Drawing
13 {
14         public sealed class SolidBrush : Brush {
15                 
16                 internal bool isModifiable = true;
17                 Color color;
18
19                 internal SolidBrush (IntPtr ptr)
20                         : base (ptr)
21                 {
22                         int val;
23                         GDIPlus.GdipGetSolidFillColor (ptr, out val);
24                         color = Color.FromArgb (val);
25                 }
26
27                 public SolidBrush (Color color)
28                 {
29                         this.Color = color;
30                         int brush;
31                         GDIPlus.GdipCreateSolidFill (color.ToArgb (), out brush);
32                         nativeObject = (IntPtr) brush;
33                 }
34
35                 public Color Color {
36                         get {
37                                 return color;
38                         }
39                         set {
40                                 if (isModifiable)
41                                         color = value;
42                                 else
43                                         throw new ArgumentException ("You may not change this Brush because it does not belong to you.");
44                         }
45                 }
46                 
47                 public override object Clone()
48                 {
49                         return new SolidBrush (color);
50                 }
51                 
52                 protected override void Dispose (bool disposing)
53                 {
54                         if (isModifiable)
55                                 GDIPlus.GdipDeleteBrush (nativeObject);
56                         else
57                                 throw new ArgumentException ("You may not change this Brush because it does not belong to you.");
58                 }
59         }
60 }
61