2 // FlatButtonAppearance.cs
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 // Copyright (c) 2006 Daniel Nauck
26 // Daniel Nauck (dna(at)mono-project(dot)de)
30 using System.ComponentModel;
32 using System.Windows.Forms;
33 using System.Globalization;
35 namespace System.Windows.Forms
37 [TypeConverter (typeof (FlatButtonAppearanceConverter))]
38 public class FlatButtonAppearance
40 private Color borderColor = Color.Empty;
41 private int borderSize = 1;
42 private Color checkedBackColor = Color.Empty;
43 private Color mouseDownBackColor = Color.Empty;
44 private Color mouseOverBackColor = Color.Empty;
45 private ButtonBase owner = null;
47 internal FlatButtonAppearance (ButtonBase owner)
52 [EditorBrowsable(EditorBrowsableState.Always)]
53 [DefaultValue(typeof(Color), "")]
54 [NotifyParentProperty(true)]
56 public Color BorderColor
58 get { return borderColor; }
60 if(borderColor == value)
63 if (value == Color.Transparent)
64 throw new NotSupportedException ("Cannot have a Transparent border.");
73 [EditorBrowsable(EditorBrowsableState.Always)]
75 [NotifyParentProperty(true)]
79 get { return borderSize; }
81 if(borderSize == value)
85 throw new ArgumentOutOfRangeException ("value", string.Format ("'{0}' is not a valid value for 'BorderSize'. 'BorderSize' must be greater or equal than {1}.", value, 0));
94 [EditorBrowsable(EditorBrowsableState.Always)]
95 [DefaultValue(typeof(Color), "")]
96 [NotifyParentProperty(true)]
98 public Color CheckedBackColor
100 get { return checkedBackColor; }
102 if(checkedBackColor == value)
105 checkedBackColor = value;
112 [EditorBrowsable(EditorBrowsableState.Always)]
113 [DefaultValue(typeof(Color), "")]
115 [NotifyParentProperty(true)]
116 public Color MouseDownBackColor
118 get { return mouseDownBackColor; }
120 if(mouseDownBackColor == value)
123 mouseDownBackColor = value;
130 [EditorBrowsable(EditorBrowsableState.Always)]
131 [DefaultValue(typeof(Color), "")]
132 [NotifyParentProperty(true)]
134 public Color MouseOverBackColor
136 get { return mouseOverBackColor; }
138 if(mouseOverBackColor == value)
141 mouseOverBackColor = value;
149 internal class FlatButtonAppearanceConverter : ExpandableObjectConverter
151 public override object ConvertTo (ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
153 if (destinationType == typeof (string))
155 return base.ConvertTo (context, culture, value, destinationType);
158 public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
160 if (destinationType == typeof (string))
162 return base.CanConvertTo (context, destinationType);