From fdf09f0b8233b63d6d956f8fe91c4ce9e1a2e7c9 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Sun, 24 Dec 2006 03:20:21 +0000 Subject: [PATCH] In Test/System.Windows.Forms.Layout: 2006-12-23 Chris Toshok * TableLayoutSettingsTypeConverterTest.cs: new tests, including one meaty one which is NotWorking on mono. In .: 2006-12-23 Chris Toshok * System.Windows.Forms_test.dll.sources: add System.Windows.Forms.Layout/TableLayoutSettingsTypeConverterTest.cs. * System.Windows.Forms.dll.sources: add System.Windows.Forms.Layout/TableLayoutSettingsTypeConverter.cs. * *.csproj: sync with new file. In System.Windows.Forms.Layout: * TableLayoutSettingsTypeConverter.cs: new file, a skeleton. 2006-12-23 Chris Toshok In System.Windows.Forms: * TableLayoutSettings.cs: finish up the corcompare work for this class. 2006-12-23 Chris Toshok svn path=/trunk/mcs/; revision=70006 --- mcs/class/Managed.Windows.Forms/ChangeLog | 10 +++ mcs/class/Managed.Windows.Forms/SWF.csproj | 5 ++ mcs/class/Managed.Windows.Forms/SWF2k5.csproj | 1 + .../System.Windows.Forms.Layout/ChangeLog | 4 + .../TableLayoutSettingsTypeConverter.cs | 69 +++++++++++++++ .../System.Windows.Forms.dll.sources | 1 + .../System.Windows.Forms/ChangeLog | 5 ++ .../System.Windows.Forms/TableLayoutSettings.cs | 10 ++- .../System.Windows.Forms_test.dll.sources | 1 + .../Test/System.Windows.Forms.Layout/ChangeLog | 5 ++ .../TableLayoutSettingsTypeConverterTest.cs | 97 ++++++++++++++++++++++ mcs/class/Managed.Windows.Forms/build-csproj | 2 +- 12 files changed, 208 insertions(+), 2 deletions(-) create mode 100644 mcs/class/Managed.Windows.Forms/System.Windows.Forms.Layout/TableLayoutSettingsTypeConverter.cs create mode 100644 mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms.Layout/ChangeLog create mode 100644 mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms.Layout/TableLayoutSettingsTypeConverterTest.cs diff --git a/mcs/class/Managed.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/ChangeLog index 94fe4fc290b..9c719ea7e04 100644 --- a/mcs/class/Managed.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/ChangeLog @@ -1,3 +1,13 @@ +2006-12-23 Chris Toshok + + * System.Windows.Forms_test.dll.sources: add + System.Windows.Forms.Layout/TableLayoutSettingsTypeConverterTest.cs. + + * System.Windows.Forms.dll.sources: add + System.Windows.Forms.Layout/TableLayoutSettingsTypeConverter.cs. + + * *.csproj: sync with new file. + 2006-12-23 Daniel Nauck * System.Windows.Forms_test.dll.sources: Add diff --git a/mcs/class/Managed.Windows.Forms/SWF.csproj b/mcs/class/Managed.Windows.Forms/SWF.csproj index 06a137af6d4..cdf15d2412f 100644 --- a/mcs/class/Managed.Windows.Forms/SWF.csproj +++ b/mcs/class/Managed.Windows.Forms/SWF.csproj @@ -3899,6 +3899,11 @@ BuildAction = "Compile" /> + + diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Layout/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Layout/ChangeLog index 026138cbd74..0c35be712cd 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Layout/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Layout/ChangeLog @@ -1,5 +1,9 @@ 2006-12-23 Chris Toshok + * TableLayoutSettingsTypeConverter.cs: new file, a skeleton. + +2006-12-23 Chris Toshok + * DefaultLayout.cs: include this in 1.1, and make use of SetImplicitBounds like the Control.PerformLayout code does. diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Layout/TableLayoutSettingsTypeConverter.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Layout/TableLayoutSettingsTypeConverter.cs new file mode 100644 index 00000000000..b22948b6a7e --- /dev/null +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Layout/TableLayoutSettingsTypeConverter.cs @@ -0,0 +1,69 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2006 Novell, Inc. +// + +#if NET_2_0 + +using System; +using System.ComponentModel; +using System.Drawing; +using System.Globalization; +using System.Xml; + +namespace System.Windows.Forms.Layout +{ + public class TableLayoutSettingsTypeConverter : TypeConverter + { + public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType) + { + if (sourceType == typeof(string)) + return true; + + return base.CanConvertFrom (context, sourceType); + } + + public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType) + { + if (destinationType == typeof(string)) + return true; + + return base.CanConvertTo (context, destinationType); + } + + public override object ConvertFrom (ITypeDescriptorContext context, + CultureInfo culture, + object value) + { + throw new NotImplementedException (); + } + + public override object ConvertTo (ITypeDescriptorContext context, + CultureInfo culture, + object value, + Type destinationType) + { + throw new NotImplementedException (); + } + + } +} + +#endif diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources index 63dde96d233..c667ba6aa10 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources @@ -751,6 +751,7 @@ System.Windows.Forms.Layout/ArrangedElementCollection.cs System.Windows.Forms.Layout/DefaultLayout.cs System.Windows.Forms.Layout/FlowLayout.cs System.Windows.Forms.Layout/TableLayout.cs +System.Windows.Forms.Layout/TableLayoutSettingsTypeConverter.cs System.Windows.Forms.VisualStyles/BackgroundType.cs System.Windows.Forms.VisualStyles/BooleanProperty.cs System.Windows.Forms.VisualStyles/BorderType.cs diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index c7ff439feea..ffdf35cade7 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -1,5 +1,10 @@ 2006-12-23 Chris Toshok + * TableLayoutSettings.cs: finish up the corcompare work for this + class. + +2006-12-23 Chris Toshok + * Control.cs: make SetImplicitBounds internal, do some futzing with LayoutEngine so that it's available in 1.1, and remove the entire duplicated code mess from PerformLayout. Use diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutSettings.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutSettings.cs index 536080160c0..630143e33f1 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutSettings.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutSettings.cs @@ -36,6 +36,7 @@ using System.Runtime.Serialization; namespace System.Windows.Forms { [Serializable] + [TypeConverter (typeof (TableLayoutSettingsTypeConverter))] public sealed class TableLayoutSettings : LayoutSettings, ISerializable { private TableLayoutColumnStyleCollection column_styles; @@ -77,10 +78,12 @@ namespace System.Windows.Forms } } + [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)] public TableLayoutColumnStyleCollection ColumnStyles { get { return this.column_styles; } } + [DefaultValue (TableLayoutPanelGrowStyle.AddRows)] public TableLayoutPanelGrowStyle GrowStyle { get { return this.grow_style; } set { @@ -105,12 +108,14 @@ namespace System.Windows.Forms } } + [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)] public TableLayoutRowStyleCollection RowStyles { get { return row_styles; } } #endregion #region Public Methods + [DefaultValue (-1)] public TableLayoutPanelCellPosition GetCellPosition (Object control) { if (control == null) @@ -127,6 +132,7 @@ namespace System.Windows.Forms return new TableLayoutPanelCellPosition (column, row); } + [DefaultValue (-1)] public int GetColumn (Object control) { if (control == null) @@ -153,6 +159,7 @@ namespace System.Windows.Forms return 1; } + [DefaultValue (-1)] public int GetRow (Object control) { if (control == null) @@ -179,6 +186,7 @@ namespace System.Windows.Forms return 1; } + [DefaultValue (-1)] public void SetCellPosition (Object control, TableLayoutPanelCellPosition cellPosition) { if (control == null) @@ -230,9 +238,9 @@ namespace System.Windows.Forms #endregion #region ISerializable Members - [MonoTODO ("Not Implemented")] void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context) { + throw new NotImplementedException (); } #endregion } diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources b/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources index 76ec4a091bd..c02b7af9ff5 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources @@ -86,6 +86,7 @@ System.Windows.Forms/TreeNodeTest.cs System.Windows.Forms/TreeViewTest.cs System.Windows.Forms/UpDownTest.cs System.Windows.Forms/UserControlTest.cs +System.Windows.Forms.Layout/TableLayoutSettingsTypeConverterTest.cs System.Resources/CompatTest.cs System.Resources/CultureTest.cs System.Resources/WriterTest.cs diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms.Layout/ChangeLog b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms.Layout/ChangeLog new file mode 100644 index 00000000000..f899abdc7e4 --- /dev/null +++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms.Layout/ChangeLog @@ -0,0 +1,5 @@ +2006-12-23 Chris Toshok + + * TableLayoutSettingsTypeConverterTest.cs: new tests, including + one meaty one which is NotWorking on mono. + diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms.Layout/TableLayoutSettingsTypeConverterTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms.Layout/TableLayoutSettingsTypeConverterTest.cs new file mode 100644 index 00000000000..f17207c077a --- /dev/null +++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms.Layout/TableLayoutSettingsTypeConverterTest.cs @@ -0,0 +1,97 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Copyright (c) 2006 Novell, Inc. +// + +#if NET_2_0 + +using System; +using System.ComponentModel; +using System.Globalization; +using System.Windows.Forms; +using System.Windows.Forms.Layout; + +using NUnit.Framework; + +namespace MonoTests.System.Windows.Forms.Layout { + + [TestFixture] + public class TableLayoutSettingsTypeConverterTest { + + [Test] + public void CanConvertFrom () + { + TableLayoutSettingsTypeConverter c = new TableLayoutSettingsTypeConverter (); + + Assert.IsTrue (c.CanConvertFrom (null, typeof (string)), "1"); + Assert.IsFalse (c.CanConvertFrom (null, typeof (int)), "2"); + Assert.IsFalse (c.CanConvertFrom (null, typeof (float)), "3"); + Assert.IsFalse (c.CanConvertFrom (null, typeof (object)), "4"); + } + + [Test] + public void CanConvertTo () + { + TableLayoutSettingsTypeConverter c = new TableLayoutSettingsTypeConverter (); + + Assert.IsTrue (c.CanConvertTo (null, typeof (string)), "1"); + Assert.IsFalse (c.CanConvertTo (null, typeof (int)), "2"); + Assert.IsFalse (c.CanConvertTo (null, typeof (float)), "3"); + Assert.IsFalse (c.CanConvertTo (null, typeof (object)), "4"); + } + + [Test] + [Category ("NotWorking")] + public void Roundtrip () + { + TableLayoutSettingsTypeConverter c = new TableLayoutSettingsTypeConverter (); + object result; + + string sv = @""; + + result = c.ConvertFrom (null, null, sv); + + Assert.AreEqual (typeof (TableLayoutSettings), result.GetType(), "1"); + + TableLayoutSettings ts = (TableLayoutSettings)result; + + Assert.AreEqual (2, ts.ColumnStyles.Count, "2"); + Assert.AreEqual (SizeType.AutoSize, ts.ColumnStyles[0].SizeType, "3"); + Assert.AreEqual (0.0f, ts.ColumnStyles[0].Width, "4"); + Assert.AreEqual (SizeType.Percent, ts.ColumnStyles[1].SizeType, "5"); + Assert.AreEqual (100.0f, ts.ColumnStyles[1].Width, "6"); + + Assert.AreEqual (3, ts.RowStyles.Count, "7"); + + Assert.AreEqual (SizeType.AutoSize, ts.RowStyles[0].SizeType, "8"); + Assert.AreEqual (0.0f, ts.RowStyles[0].Height, "9"); + Assert.AreEqual (SizeType.AutoSize, ts.RowStyles[1].SizeType, "10"); + Assert.AreEqual (0.0f, ts.RowStyles[1].Height, "11"); + Assert.AreEqual (SizeType.AutoSize, ts.RowStyles[2].SizeType, "12"); + Assert.AreEqual (0.0f, ts.RowStyles[2].Height, "13"); + + string rv = (string)c.ConvertTo (null, null, ts, typeof (string)); + + Assert.AreEqual (sv, rv, "roundtrip"); + } + } +} + +#endif diff --git a/mcs/class/Managed.Windows.Forms/build-csproj b/mcs/class/Managed.Windows.Forms/build-csproj index e2a742a49e5..1d4f0cd5919 100755 --- a/mcs/class/Managed.Windows.Forms/build-csproj +++ b/mcs/class/Managed.Windows.Forms/build-csproj @@ -177,7 +177,7 @@ SWFresourcelist() { cat $Resource | while read SRC; do SRC=`echo $SRC | $tr '/' '\\\\'` -SRC=`echo $SRC | $tr '/' '\\\\' | sed 's/-resource://' | awk -F , '{print " RelPath = \"" $1 "\"\n CustomToolNameSpace = \"" $2 "\""}' | fgrep -v \"\"` +SRC=`echo $SRC | sed 's/-resource://' | gawk -F , '{print " RelPath = \"" $1 "\"\n CustomToolNameSpace = \"" $2 "\""}' | fgrep -v \"\"` cat << EOT