// and ColorDepth that are treated as bugs and MS.NET 2.0 behavior is
// implemented.
//
-// MS.NET 2.0 initializes TransparentColor to Color.Transparent in
-// constructors but ResetTransparentColor and ShouldSerializeTransparentColor
-// default to Color.LightGray that is treated as a bug.
-//
// MS.NET 2.0 does not clear keys when handle is destroyed that is treated as
// a bug.
//
#if NET_2_0
private object tag;
#endif
- private EventHandler recreateHandle;
private readonly ImageCollection images;
#endregion // Private Fields
#region Private Instance Methods
private void OnRecreateHandle()
{
- if (this.recreateHandle != null)
- this.recreateHandle(this, EventArgs.Empty);
+ EventHandler eh = (EventHandler)(Events [RecreateHandleEvent]);
+ if (eh != null)
+ eh (this, EventArgs.Empty);
}
-#if NET_2_0
- // For use in Designers
- private void ResetColorDepth()
- {
- this.ColorDepth = DefaultColorDepth;
- }
-
- // For use in Designers
- private void ResetImageSize()
- {
- this.ImageSize = DefaultImageSize;
- }
+ // MS's TypeDescriptor stuff apparently uses
+ // non-public ShouldSerialize* methods, because it
+ // picks up this behavior even though the methods
+ // aren't public. we can't make them private, though,
+ // without adding compiler warnings. so, make then
+ // internal instead.
- // For use in Designers
- private void ResetTransparentColor()
+ internal bool ShouldSerializeTransparentColor ()
{
- this.TransparentColor = DefaultTransparentColor;
+ return this.TransparentColor != Color.LightGray;
}
- // For use in Designers
- private bool ShouldSerializeColorDepth()
+ internal bool ShouldSerializeColorDepth()
{
// ColorDepth is serialized in ImageStream when non-empty.
// It is serialized even if it has its default value when empty.
return images.Empty;
- }
+ }
- // For use in Designers
- private bool ShouldSerializeImageSize()
+ internal bool ShouldSerializeImageSize()
{
// ImageSize is serialized in ImageStream when non-empty.
// It is serialized even if it has its default value when empty.
+#if NET_2_0
return images.Empty;
+#else
+ return this.ImageSize != DefaultImageSize;
+#endif
}
- // For use in Designers
- private bool ShouldSerializeTransparentColor()
+
+ internal void ResetColorDepth ()
{
- return this.TransparentColor != DefaultTransparentColor;
+ this.ColorDepth = DefaultColorDepth;
+ }
+
+#if NET_2_0
+ internal void ResetImageSize ()
+ {
+ this.ImageSize = DefaultImageSize;
+ }
+
+ internal void ResetTransparentColor ()
+ {
+ this.TransparentColor = Color.LightGray;
}
#endif
#endregion // Private Instance Methods
#endregion // Protected Instance Methods
#region Events
+ static object RecreateHandleEvent = new object ();
+
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public event EventHandler RecreateHandle {
- add {
- this.recreateHandle += value;
- }
-
- remove {
- this.recreateHandle -= value;
- }
+ add { Events.AddHandler (RecreateHandleEvent, value); }
+ remove { Events.RemoveHandler (RecreateHandleEvent, value); }
}
#endregion // Events
}