Attached patch adds ShouldSerializePROPERTYNAME for several properties
in order to prevent default value serialization during design time
serialization. ChangeLog entry included. Please review.
--
Ivan N. Zlatev
Web: http://www.i-nZ.net
"It's all some kind of whacked out conspiracy."
Index: mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
===================================================================
--- mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs (revision 82206)
+++ mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs (working copy)
@@ -2049,7 +2049,7 @@
#if NET_2_0
[Browsable (false)]
- [DefaultValue ("{X=0,Y=0}")]
+ [DefaultValue (typeof (Point), "0, 0")]
[EditorBrowsable (EditorBrowsableState.Advanced)]
public virtual Point AutoScrollOffset {
get {
@@ -2102,6 +2102,11 @@
}
}
+ internal bool ShouldSerializeMaximumSize ()
+ {
+ return this.MaximumSize != DefaultMaximumSize;
+ }
+
public virtual Size MinimumSize {
get {
return minimum_size;
@@ -2113,6 +2118,11 @@
}
}
}
+
+ internal bool ShouldSerializeMinimumSize ()
+ {
+ return this.MinimumSize != DefaultMinimumSize;
+ }
#endif // NET_2_0
[DispId(-501)]
@@ -2144,6 +2154,11 @@
}
}
+ internal bool ShouldSerializeBackColor ()
+ {
+ return this.BackColor != DefaultBackColor;
+ }
+
[Localizable(true)]
[DefaultValue(null)]
[MWFCategory("Appearance")]
@@ -2460,6 +2475,10 @@
}
}
+ internal bool ShouldSerializeCursor ()
+ {
+ return this.Cursor != Cursors.Default;
+ }
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[ParenthesizePropertyName(true)]
@@ -2596,6 +2615,11 @@
}
}
+ internal bool ShouldSerializeEnabled ()
+ {
+ return this.Enabled != true;
+ }
+
[EditorBrowsable(EditorBrowsableState.Advanced)]
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
@@ -2635,6 +2659,11 @@
}
}
+ internal bool ShouldSerializeFont ()
+ {
+ return !this.Font.Equals (DefaultFont);
+ }
+
[DispId(-513)]
[MWFCategory("Appearance")]
public virtual Color ForeColor {
@@ -2657,6 +2686,11 @@
}
}
+ internal bool ShouldSerializeForeColor ()
+ {
+ return this.ForeColor != DefaultForeColor;
+ }
+
[DispId(-515)]
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
@@ -2724,6 +2758,11 @@
}
}
+ internal bool ShouldSerializeImeMode ()
+ {
+ return this.ImeMode != ImeMode.NoControl;
+ }
+
[EditorBrowsable(EditorBrowsableState.Advanced)]
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
@@ -2822,6 +2861,11 @@
}
}
+ internal bool ShouldSerializeLocation ()
+ {
+ return this.Location != new Point (0, 0);
+ }
+
#if NET_2_0
[Localizable (true)]
public Padding Margin {
@@ -2833,6 +2877,11 @@
}
}
}
+
+ internal bool ShouldSerializeMargin ()
+ {
+ return this.Margin != DefaultMargin;
+ }
#endif
[Browsable(false)]
@@ -2866,6 +2915,11 @@
}
}
}
+
+ internal bool ShouldSerializePadding ()
+ {
+ return this.Padding != DefaultPadding;
+ }
#endif
[Browsable(false)]
@@ -2996,6 +3050,11 @@
}
}
+ internal bool ShouldSerializeRightToLeft ()
+ {
+ return this.RightToLeft != RightToLeft.No;
+ }
+
[EditorBrowsable(EditorBrowsableState.Advanced)]
public override ISite Site {
get {
@@ -3017,6 +3076,11 @@
}
}
+ internal bool ShouldSerializeSite ()
+ {
+ return false;
+ }
+
[Localizable(true)]
[MWFCategory("Layout")]
public Size Size {
@@ -3029,6 +3093,11 @@
}
}
+ internal virtual bool ShouldSerializeSize ()
+ {
+ return this.Size != DefaultSize;
+ }
+
[Localizable(true)]
[MergableProperty(false)]
[MWFCategory("Behavior")]
@@ -3101,7 +3170,7 @@
}
}
}
-
+
internal virtual void UpdateWindowText ()
{
if (!IsHandleCreated) {
@@ -3177,6 +3246,11 @@
}
}
+ internal bool ShouldSerializeVisible ()
+ {
+ return this.Visible != true;
+ }
+
[EditorBrowsable(EditorBrowsableState.Always)]
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
Index: mcs/class/Managed.Windows.Forms/System.Windows.Forms/ButtonBase.cs
===================================================================
--- mcs/class/Managed.Windows.Forms/System.Windows.Forms/ButtonBase.cs (revision 82206)
+++ mcs/class/Managed.Windows.Forms/System.Windows.Forms/ButtonBase.cs (working copy)
@@ -209,6 +209,11 @@
}
}
+ internal bool ShouldSerializeImage ()
+ {
+ return this.Image != null;
+ }
+
[Localizable(true)]
[DefaultValue(ContentAlignment.MiddleCenter)]
[MWFDescription("Sets the alignment of the image to be displayed on button face"), MWFCategory("Appearance")]
Index: mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog (revision 82283)
+++ mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog (working copy)
@@ -1,3 +1,9 @@
+2007-07-19 Ivan N. Zlatev <[EMAIL PROTECTED]>
+
+ * Control.cs, Form.cs, ContainerControl.cs,
+ ScrollableControl.cs, ButtonBase.cs: Added ShouldSerialize
+ for misc properties.
+
2007-07-18 Jonathan Pobst <[EMAIL PROTECTED]>
* ToolStripContentPanel.cs: Support System renderer.
Index: mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
===================================================================
--- mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs (revision 82206)
+++ mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs (working copy)
@@ -507,6 +507,11 @@
}
}
+ internal bool ShouldSerializeAutoScroll ()
+ {
+ return this.AutoScroll != false;
+ }
+
#if NET_2_0
[Browsable (true)]
[EditorBrowsable (EditorBrowsableState.Always)]
@@ -520,6 +525,11 @@
}
}
}
+
+ internal bool ShouldSerializeAutoSize ()
+ {
+ return this.AutoSize != false;
+ }
[Browsable (true)]
[Localizable (true)]
@@ -693,6 +703,11 @@
}
}
+ internal bool ShouldSerializeIcon ()
+ {
+ return this.Icon != default_icon;
+ }
+
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool IsMdiChild {
@@ -786,7 +801,7 @@
}
}
- [DefaultValue("{Width=0, Height=0}")]
+ [DefaultValue(typeof (Size),"0, 0")]
[Localizable(true)]
[RefreshProperties(RefreshProperties.Repaint)]
[MWFCategory("Layout")]
@@ -1223,6 +1238,11 @@
}
}
+ internal bool ShouldSerializeTransparencyKey ()
+ {
+ return this.TransparencyKey != Color.Empty;
+ }
+
[DefaultValue(FormWindowState.Normal)]
[MWFCategory("Layout")]
public FormWindowState WindowState {
Index: mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContainerControl.cs
===================================================================
--- mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContainerControl.cs (revision 82206)
+++ mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContainerControl.cs (working copy)
@@ -588,6 +588,11 @@
}
}
+ internal bool ShouldSerializeAutoValidate ()
+ {
+ return this.AutoValidate != AutoValidate.Inherit;
+ }
+
static object OnValidateChanged = new object ();
protected virtual void OnAutoValidateChanged (EventArgs e)
Index: mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollableControl.cs
===================================================================
--- mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollableControl.cs (revision 82206)
+++ mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollableControl.cs (working copy)
@@ -334,6 +334,11 @@
}
}
+ internal bool ShouldSerializeAutoScrollMargin ()
+ {
+ return this.AutoScrollMargin != new Size (0, 0);
+ }
+
[Localizable(true)]
[MWFCategory("Layout")]
public Size AutoScrollMinSize {
@@ -349,6 +354,11 @@
}
}
+ internal bool ShouldSerializeAutoScrollMinSize ()
+ {
+ return this.AutoScrollMinSize != new Size (0, 0);
+ }
+
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public Point AutoScrollPosition {
_______________________________________________
Mono-winforms-list maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-winforms-list