From 38d49b91765f381551751ea3a0f434e46f58c7bc Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Wed, 8 Nov 2006 17:15:08 +0000 Subject: [PATCH] add a test for a propertygrid displaying an array, and make the Makefile a bit more sane/extensible svn path=/trunk/winforms/; revision=67545 --- propertygrid/Makefile | 23 +++++++--- propertygrid/swf-propertygrid-array.cs | 63 ++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 6 deletions(-) create mode 100644 propertygrid/swf-propertygrid-array.cs diff --git a/propertygrid/Makefile b/propertygrid/Makefile index 200b36d..322d505 100644 --- a/propertygrid/Makefile +++ b/propertygrid/Makefile @@ -1,10 +1,21 @@ -all: mono +EXE= swf-propertygrid.exe \ + swf-propertygrid-array.exe -mono: swf-propertygrid.cs - mcs swf-propertygrid.cs /r:System.Windows.Forms.dll /r:System.Drawing.dll +MDB= -dotnet: swf-propertygrid.cs - csc swf-propertygrid.cs /r:System.Windows.Forms.dll /r:System.Drawing.dll +CSC=mcs + +all: $(EXE) + +mono: + make all CSC=mcs + +dotnet: + make all CSC=csc clean: - rm swf-propertygrid.exe -r -f + rm -f $(EXE) $(EXE:%.exe=%.exe.mdb) + +%.exe: %.cs + $(CSC) -out:$@ -debug $< /r:System.Windows.Forms.dll /r:System.Drawing.dll + diff --git a/propertygrid/swf-propertygrid-array.cs b/propertygrid/swf-propertygrid-array.cs new file mode 100644 index 0000000..83716ad --- /dev/null +++ b/propertygrid/swf-propertygrid-array.cs @@ -0,0 +1,63 @@ +using System; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; + +namespace MWFTestApplication { + class MainWindow : System.Windows.Forms.Form { + static MainWindow main_window; + static Control active; + + PropertyGrid propertygrid; + + public MainWindow() { + ClientSize = new System.Drawing.Size (520, 520); + Text = "Property Grid Array Test"; + + int[] testarray = new int[10]; + for (int i = 0; i < testarray.Length; i ++) + testarray[i] = 10-i; + + + TypeConverter cvt = TypeDescriptor.GetConverter (testarray); + PropertyDescriptorCollection props = cvt.GetProperties (testarray); + PropertyDescriptorCollection tdprops = TypeDescriptor.GetProperties (testarray); + Console.WriteLine ("Converter is {0}", cvt.GetType()); + Console.WriteLine ("converter properties length = {0}", props.Count); + Console.WriteLine ("typedescriptor properties length = {0}", tdprops.Count); + foreach (PropertyDescriptor prop in props) { + Console.WriteLine ("{0} : {1}", prop.Name, prop.GetType()); + Console.WriteLine (" + {0} {1} {2} {3}", prop.PropertyType, prop.ComponentType, prop.CanResetValue (testarray), prop.ShouldSerializeValue (testarray)); + } + + Console.WriteLine (testarray[5]); + + propertygrid = new PropertyGrid(); + propertygrid.CommandsVisibleIfAvailable = true; + propertygrid.Dock = DockStyle.Fill; + propertygrid.TabIndex = 2; + propertygrid.Text = "Property Grid"; + propertygrid.Dock = DockStyle.Fill; + + this.Controls.Add(propertygrid); + + propertygrid.SelectedObject = testarray; + + propertygrid.PropertyValueChanged += delegate (object o, PropertyValueChangedEventArgs e) { + //Console.WriteLine (Environment.StackTrace); + }; + + propertygrid.SelectedGridItemChanged += delegate (object o, SelectedGridItemChangedEventArgs e) { + //Console.WriteLine (Environment.StackTrace); + }; + } + + public static int Main(string[] args) { + main_window = new MainWindow(); + active = main_window; + + Application.Run(main_window); + return 0; + } + } +}