Author: jordi Date: 2005-04-05 04:51:13 -0400 (Tue, 05 Apr 2005) New Revision: 42551
Added: trunk/winforms/datagrid/Makefile trunk/winforms/datagrid/classes/DataGridCellTests.cs trunk/winforms/datagrid/swf-datagrid-realsample.cs trunk/winforms/datagrid/swf-datagrid-styles.cs trunk/winforms/datagrid/swf-datagrid-tablenav.cs trunk/winforms/datagrid/swf-datagrid-testproperties.cs trunk/winforms/datagrid/swf-datagrid.cs Modified: trunk/winforms/datagrid/classes/DataGridBoolColumnTests.cs trunk/winforms/datagrid/classes/DataGridTableStylesTests.cs trunk/winforms/datagrid/classes/GridColumnStylesCollectionTests.cs trunk/winforms/datagrid/classes/GridTableStylesCollectionTests.cs trunk/winforms/datagrid/classes/Makefile Log: Datagrid samples Added: trunk/winforms/datagrid/Makefile =================================================================== --- trunk/winforms/datagrid/Makefile 2005-04-05 07:44:13 UTC (rev 42550) +++ trunk/winforms/datagrid/Makefile 2005-04-05 08:51:13 UTC (rev 42551) @@ -0,0 +1,9 @@ +all: mono + +mono: swf-datagrid.cs + mcs swf-datagrid.cs swf-datagrid-realsample.cs swf-datagrid-testproperties.cs swf-datagrid-tablenav.cs swf-datagrid-styles.cs /r:System.Windows.Forms.dll /r:System.Drawing.dll /r:System.Data.dll + +dotnet: swf-datagrid.cs + +clean: + rm swf-datagrid.exe -r -f Modified: trunk/winforms/datagrid/classes/DataGridBoolColumnTests.cs =================================================================== --- trunk/winforms/datagrid/classes/DataGridBoolColumnTests.cs 2005-04-05 07:44:13 UTC (rev 42550) +++ trunk/winforms/datagrid/classes/DataGridBoolColumnTests.cs 2005-04-05 08:51:13 UTC (rev 42551) @@ -20,7 +20,7 @@ // Copyright (c) 2005 Novell, Inc. (http://www.novell.com) // // Author: -// Jordi Mas i Hernadez <[EMAIL PROTECTED]> +// Jordi Mas i Hernandez <[EMAIL PROTECTED]> // // Added: trunk/winforms/datagrid/classes/DataGridCellTests.cs =================================================================== --- trunk/winforms/datagrid/classes/DataGridCellTests.cs 2005-04-05 07:44:13 UTC (rev 42550) +++ trunk/winforms/datagrid/classes/DataGridCellTests.cs 2005-04-05 08:51:13 UTC (rev 42551) @@ -0,0 +1,56 @@ +// 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) 2005 Novell, Inc. (http://www.novell.com) +// +// Author: +// Jordi Mas i Hernandez <[EMAIL PROTECTED]> +// +// + +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace DatagridTests +{ + class DataGridCellTests + { + public DataGridCellTests () + { + DataGridCell dg = new DataGridCell (); + Console.WriteLine ("DataGridCell default --- "); + Console.WriteLine ("Column {0}", dg.RowNumber); + Console.WriteLine ("Row {0}", dg.ColumnNumber); + + dg.RowNumber = 10; + dg.ColumnNumber = 5; + + Console.WriteLine ("ToString {0}", dg.ToString ()); + Console.WriteLine ("GetHashCode {0}", dg.GetHashCode ()); + } + + public static void Main (string[] args) + { + new DataGridCellTests (); + } + + + } +} Modified: trunk/winforms/datagrid/classes/DataGridTableStylesTests.cs =================================================================== --- trunk/winforms/datagrid/classes/DataGridTableStylesTests.cs 2005-04-05 07:44:13 UTC (rev 42550) +++ trunk/winforms/datagrid/classes/DataGridTableStylesTests.cs 2005-04-05 08:51:13 UTC (rev 42551) @@ -20,7 +20,7 @@ // Copyright (c) 2005 Novell, Inc. (http://www.novell.com) // // Author: -// Jordi Mas i Hernadez <[EMAIL PROTECTED]> +// Jordi Mas i Hernandez <[EMAIL PROTECTED]> // // Tests DataGridTableStyles class implementation // Modified: trunk/winforms/datagrid/classes/GridColumnStylesCollectionTests.cs =================================================================== --- trunk/winforms/datagrid/classes/GridColumnStylesCollectionTests.cs 2005-04-05 07:44:13 UTC (rev 42550) +++ trunk/winforms/datagrid/classes/GridColumnStylesCollectionTests.cs 2005-04-05 08:51:13 UTC (rev 42551) @@ -20,7 +20,7 @@ // Copyright (c) 2005 Novell, Inc. (http://www.novell.com) // // Author: -// Jordi Mas i Hernadez <[EMAIL PROTECTED]> +// Jordi Mas i Hernandez <[EMAIL PROTECTED]> // // Modified: trunk/winforms/datagrid/classes/GridTableStylesCollectionTests.cs =================================================================== --- trunk/winforms/datagrid/classes/GridTableStylesCollectionTests.cs 2005-04-05 07:44:13 UTC (rev 42550) +++ trunk/winforms/datagrid/classes/GridTableStylesCollectionTests.cs 2005-04-05 08:51:13 UTC (rev 42551) @@ -20,7 +20,7 @@ // Copyright (c) 2005 Novell, Inc. (http://www.novell.com) // // Author: -// Jordi Mas i Hernadez <[EMAIL PROTECTED]> +// Jordi Mas i Hernandez <[EMAIL PROTECTED]> // // Modified: trunk/winforms/datagrid/classes/Makefile =================================================================== --- trunk/winforms/datagrid/classes/Makefile 2005-04-05 07:44:13 UTC (rev 42550) +++ trunk/winforms/datagrid/classes/Makefile 2005-04-05 08:51:13 UTC (rev 42551) @@ -1,10 +1,17 @@ all: mono -mono: DataGridTableStylesTests.cs DataGridBoolColumnTests.cs GridColumnStylesCollectionTests.cs GridTableStylesCollectionTests.cs +mono: DataGridTableStylesTests.cs DataGridBoolColumnTests.cs GridColumnStylesCollectionTests.cs GridTableStylesCollectionTests.cs DataGridCellTests.cs mcs DataGridTableStylesTests.cs /r:System.Windows.Forms.dll /r:System.Drawing.dll mcs DataGridBoolColumnTests.cs /r:System.Windows.Forms.dll /r:System.Drawing.dll mcs GridColumnStylesCollectionTests.cs /r:System.Windows.Forms.dll /r:System.Drawing.dll mcs GridTableStylesCollectionTests.cs /r:System.Windows.Forms.dll /r:System.Drawing.dll - + mcs DataGridTests.cs /r:System.Windows.Forms.dll /r:System.Drawing.dll + mcs DataGridCellTests.cs /r:System.Windows.Forms.dll /r:System.Drawing.dll + clean: - rm swf-datagrid.exe -r -f + rm DataGridBoolColumnTests.exe -r -f + rm DataGridTableStylesTests.exe -r -f + rm DataGridTests.exe -r -f + rm GridColumnStylesCollectionTests.exe -r -f + rm GridTableStylesCollectionTests.exe -r -f + rm DataGridCellTests.exe -r -f Added: trunk/winforms/datagrid/swf-datagrid-realsample.cs =================================================================== --- trunk/winforms/datagrid/swf-datagrid-realsample.cs 2005-04-05 07:44:13 UTC (rev 42550) +++ trunk/winforms/datagrid/swf-datagrid-realsample.cs 2005-04-05 08:51:13 UTC (rev 42551) @@ -0,0 +1,114 @@ +// 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) 2005 Novell, Inc. (http://www.novell.com) +// +// Author: +// Jordi Mas i Hernandez <[EMAIL PROTECTED]> +// +// + + +using System; +using System.Windows.Forms; +using System.Data; + +namespace DatagridSamples +{ + class DataGridRealSample : Form + { + private DataGrid dataGrid; + private DataSet dsSource = new DataSet (); + + public DataGridRealSample () + { + InitializeComponent (); + } + + + void InitializeComponent () + { + dataGrid = new DataGrid (); + SuspendLayout (); + + // + // dataGrid + // + dataGrid.DataMember = ""; + dataGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText; + dataGrid.Location = new System.Drawing.Point (10, 50); + dataGrid.Name = "dataGrid"; + dataGrid.Size = new System.Drawing.Size (600, 500); + + + // + // MainForm + // + AutoScaleBaseSize = new System.Drawing.Size (5, 13); + ClientSize = new System.Drawing.Size (700, 600); + Controls.Add (dataGrid); + Text = "SWF-Datagrid RealSample"; + Name = "MainForm"; + Load += new System.EventHandler (MainFormLoad); + ResumeLayout (false); + } + + /* + public static void Main(string[] args) + { + Application.Run(new DatagridSample1()); + }*/ + + void MainFormLoad (object sender, System.EventArgs e) + { + ((System.ComponentModel.ISupportInitialize)(dataGrid)).BeginInit(); + FillDataSet (); + ((System.ComponentModel.ISupportInitialize)(dataGrid)).EndInit(); + } + + private void FillDataSet() + { + + //ReadSchemaFromXmlTextReader + // Create a FileStream object with the file path and name. + System.IO.FileStream myFileStream = new System.IO.FileStream ("programes.xsd",System.IO.FileMode.Open); + + // Create a new XmlTextReader object with the FileStream. + System.Xml.XmlTextReader myXmlTextReader= + new System.Xml.XmlTextReader(myFileStream); + // Read the schema into the DataSet and close the reader. + dsSource.ReadXmlSchema(myXmlTextReader); + myXmlTextReader.Close(); + + + // Read the XML document back in. + // Create new FileStream to read schema with. + System.IO.FileStream fsReadXml = new System.IO.FileStream + ("programes.xml", System.IO.FileMode.Open); + + System.Xml.XmlTextReader myXmlReader = new System.Xml.XmlTextReader(fsReadXml); + + dsSource.ReadXml (myXmlReader); + myXmlReader.Close(); + + dataGrid.DataSource = dsSource.Tables["programes"]; + } + + } +} Added: trunk/winforms/datagrid/swf-datagrid-styles.cs =================================================================== --- trunk/winforms/datagrid/swf-datagrid-styles.cs 2005-04-05 07:44:13 UTC (rev 42550) +++ trunk/winforms/datagrid/swf-datagrid-styles.cs 2005-04-05 08:51:13 UTC (rev 42551) @@ -0,0 +1,120 @@ +// 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) 2005 Novell, Inc. (http://www.novell.com) +// +// Author: +// Jordi Mas i Hernandez <[EMAIL PROTECTED]> +// +// + +using System; +using System.Windows.Forms; +using System.Data; +using System.Drawing; + +namespace DatagridSamples +{ + class DataGridStyles : Form + { + private DataGrid dataGrid; + private DataSet dsSource = new DataSet (); + + public DataGridStyles () + { + InitializeComponent (); + } + + + void InitializeComponent () + { + SuspendLayout (); + + // + // dataGrid + // + dataGrid = new DataGrid(); + dataGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText; + dataGrid.Location = new System.Drawing.Point (10, 10); + dataGrid.Name = "dataGrid"; + dataGrid.Size = new System.Drawing.Size (600, 600); + + + // + // MainForm + // + Text = "SWF-Datagrid Styles"; + ClientSize = new System.Drawing.Size (700, 600); + Controls.Add(dataGrid); + Load += new System.EventHandler(MainFormLoad); + ResumeLayout (false); + } + + /* + public static void Main(string[] args) + { + Application.Run(new DatagridSample1()); + }*/ + + void MainFormLoad (object sender, System.EventArgs e) + { + FillDataSet (); + + // Tick used by many apps to get the table's styles + DataGridTableStyle tablestyles = new DataGridTableStyle (); + tablestyles.MappingName = "Programes"; + dataGrid.TableStyles.Add (tablestyles); + + Console.WriteLine ("Table Styles {0}", tablestyles.GridColumnStyles.Count); + + tablestyles.SelectionBackColor = Color.Black; + tablestyles.SelectionForeColor = Color.White; + + for (int i = 0; i < tablestyles.GridColumnStyles.Count; i++) + Console.WriteLine (" Styles {0}", tablestyles.GridColumnStyles[i].MappingName); + + // Column styles + tablestyles.GridColumnStyles["ID"].Width = 30; + tablestyles.GridColumnStyles["ID"].ReadOnly = true; + tablestyles.GridColumnStyles["vilaweb"].Width = 30; + tablestyles.GridColumnStyles["versio"].Alignment = HorizontalAlignment.Right; + tablestyles.GridColumnStyles["versio"].HeaderText = "HeaderText: version"; + + } + + private void FillDataSet () + { + // Create a FileStream object with the file path and name. + System.IO.FileStream myFileStream = new System.IO.FileStream ("programes.xsd",System.IO.FileMode.Open); + System.Xml.XmlTextReader myXmlTextReader = new System.Xml.XmlTextReader (myFileStream); + dsSource.ReadXmlSchema (myXmlTextReader); + myXmlTextReader.Close (); + + // Read the XML document back in. + System.IO.FileStream fsReadXml = new System.IO.FileStream ("programes.xml", System.IO.FileMode.Open); + + System.Xml.XmlTextReader myXmlReader = new System.Xml.XmlTextReader(fsReadXml); + + dsSource.ReadXml (myXmlReader); + myXmlReader.Close (); + dataGrid.DataSource = dsSource.Tables["programes"]; + } + + } +} Added: trunk/winforms/datagrid/swf-datagrid-tablenav.cs =================================================================== --- trunk/winforms/datagrid/swf-datagrid-tablenav.cs 2005-04-05 07:44:13 UTC (rev 42550) +++ trunk/winforms/datagrid/swf-datagrid-tablenav.cs 2005-04-05 08:51:13 UTC (rev 42551) @@ -0,0 +1,177 @@ +// 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) 2005 Novell, Inc. (http://www.novell.com) +// +// Author: +// Jordi Mas i Hernandez <[EMAIL PROTECTED]> +// +// + +using System; +using System.Windows.Forms; +using System.Data; + +namespace DatagridSamples +{ + class DataGridTableNavigation : Form + { + private DataGrid dataGrid; + private DataSet dsSource = new DataSet(); + + public DataGridTableNavigation () + { + InitializeComponent (); + } + + void InitializeComponent () + { + dataGrid = new DataGrid (); + dataGrid.DataSource = dsSource; + SuspendLayout (); + + + // + // dataGrid + // + dataGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText; + dataGrid.Location = new System.Drawing.Point (10, 10); + dataGrid.Name = "dataGrid"; + dataGrid.Size = new System.Drawing.Size (400, 400); + + // + // MainForm + // + AutoScaleBaseSize = new System.Drawing.Size (5, 13); + ClientSize = new System.Drawing.Size (700, 600); + Controls.Add (dataGrid); + Name = "MainForm"; + Text = "SWF-Datagrid Table Navigation"; + Load += new System.EventHandler (MainFormLoad); + ResumeLayout(false); + } + + /* + public static void Main(string[] args) + { + Application.Run(new DatagridSample1()); + }*/ + + void MainFormLoad (object sender, System.EventArgs e) + { + ((System.ComponentModel.ISupportInitialize)(dataGrid)).BeginInit(); + FillDataSet (); + ((System.ComponentModel.ISupportInitialize)(dataGrid)).EndInit(); + } + + + private void FillDataSet () + { + + DataTable users = dsSource.Tables.Add ("Users"); + DataTable zipcodes = dsSource.Tables.Add ("ZipCodes"); + DataTable countries = dsSource.Tables.Add ("Countries"); + DataColumn users_id, zip_zipid, col; + + // Countries + col = countries.Columns.Add ("name", Type.GetType ("System.String")); + col.Caption = "Available Countries"; + + // Zipcodes + zip_zipid = zipcodes.Columns.Add ("zipID", Type.GetType ("System.Int32")); + zip_zipid.AutoIncrement = true; + zipcodes.Columns.Add ("area", Type.GetType ("System.String")); + zipcodes.Columns.Add ("zipcode", Type.GetType ("System.String")); + zipcodes.PrimaryKey = new DataColumn [] {zip_zipid}; + + // Users + users_id = users.Columns.Add ("userID", Type.GetType ("System.Int32")); + users_id.AutoIncrement = true; + users.Columns.Add ("name", Type.GetType ("System.String")); + users.Columns.Add ("address", Type.GetType ("System.String")); + users.Columns.Add ("zipcode", Type.GetType ("System.Int32")); + users.PrimaryKey = new DataColumn [] {users_id}; + + + DataRelation rel = new DataRelation ("relation", + new DataColumn [] {zipcodes.Columns["zipID"]}, // parent + new DataColumn [] {users.Columns["zipcode"]}); // child, consumer + + dsSource.Relations.Add (rel); + + + // Zip codes + DataRow tempRow = zipcodes.NewRow (); + tempRow["area"] = "Eixample"; + tempRow["zipcode"] = "08039"; + zipcodes.Rows.Add(tempRow); + + tempRow = zipcodes.NewRow (); + tempRow["area"] = "Clot"; + tempRow["zipcode"] = "08026"; + zipcodes.Rows.Add(tempRow); + + // Users + tempRow = users.NewRow (); + tempRow["name"] = "Joan"; + tempRow["address"] = "Balmes 152"; + tempRow["zipcode"] = "1"; + users.Rows.Add(tempRow); + + tempRow = users.NewRow (); + tempRow["name"] = "Pere"; + tempRow["address"] = "Provenca 55"; + tempRow["zipcode"] = "1"; + users.Rows.Add(tempRow); + + tempRow = users.NewRow (); + tempRow["name"] = "Jordi"; + tempRow["address"] = "Londres 16"; + tempRow["zipcode"] = "1"; + users.Rows.Add(tempRow); + + tempRow = users.NewRow (); + tempRow["name"] = "Marta"; + tempRow["address"] = "Padilla 210"; + tempRow["zipcode"] = "0"; + users.Rows.Add(tempRow); + + // Countries + tempRow = countries.NewRow (); + tempRow["name"] = "France"; + countries.Rows.Add(tempRow); + + tempRow = countries.NewRow (); + tempRow["name"] = "Spain"; + countries.Rows.Add(tempRow); + + tempRow = countries.NewRow (); + tempRow["name"] = "Italy"; + countries.Rows.Add(tempRow); + + for (int i = 0; i < dsSource.Tables.Count; i++) { + Console.WriteLine ("table->{0} ChildRel {1}, ParentRel {2}, Columns {3}", dsSource.Tables[i], + dsSource.Tables[i].ChildRelations.Count, + dsSource.Tables[i].ParentRelations.Count, + dsSource.Tables[i].Columns.Count); + } + } + + } +} Added: trunk/winforms/datagrid/swf-datagrid-testproperties.cs =================================================================== --- trunk/winforms/datagrid/swf-datagrid-testproperties.cs 2005-04-05 07:44:13 UTC (rev 42550) +++ trunk/winforms/datagrid/swf-datagrid-testproperties.cs 2005-04-05 08:51:13 UTC (rev 42551) @@ -0,0 +1,230 @@ +// 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) 2005 Novell, Inc. (http://www.novell.com) +// +// Author: +// Jordi Mas i Hernadez <[EMAIL PROTECTED]> +// +// +using System; +using System.Windows.Forms; +using System.Drawing; +using System.Data; + +namespace DatagridSamples +{ + class DataGridTestProperties : Form + { + private DataGrid dataGrid; + private DataSet dsSource; + + public DataGridTestProperties () + { + InitializeComponent (); + } + + private void checkbox_allownavChecked (object sender, System.EventArgs e) + { + dataGrid.AllowNavigation = !dataGrid.AllowNavigation; + } + + private void checkbox_allowsortingChecked (object sender, System.EventArgs e) + { + dataGrid.AllowSorting = !dataGrid.AllowSorting; + } + + private void checkbox_columnvisibileChecked (object sender, System.EventArgs e) + { + dataGrid.ColumnHeadersVisible = !dataGrid.ColumnHeadersVisible; + } + + private void checkbox_captionvisibleChecked (object sender, System.EventArgs e) + { + dataGrid.CaptionVisible = !dataGrid.CaptionVisible; + } + + private void checkbox_gridlinestyleChecked (object sender, System.EventArgs e) + { + if (dataGrid.GridLineStyle == DataGridLineStyle.None) { + dataGrid.GridLineStyle = DataGridLineStyle.Solid; + } else { + dataGrid.GridLineStyle = DataGridLineStyle.None; + } + } + + private void checkbox_flatmodeChecked (object sender, System.EventArgs e) + { + dataGrid.FlatMode = !dataGrid.FlatMode; + } + + private void parentrowsvisibleChecked (object sender, System.EventArgs e) + { + dataGrid.ParentRowsVisible = !dataGrid.ParentRowsVisible ; + } + + private void readonlyChecked (object sender, System.EventArgs e) + { + dataGrid.ReadOnly = !dataGrid.ReadOnly; + } + + private void rowshdrsvisibleChecked (object sender, System.EventArgs e) + { + dataGrid.RowHeadersVisible = !dataGrid.RowHeadersVisible; + } + + + void InitializeComponent () + { + dsSource = new DataSet (); + dataGrid = new DataGrid (); + + SuspendLayout (); + + dataGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText; + dataGrid.Location = new System.Drawing.Point (10, 50); + dataGrid.Name = "dataGrid"; + dataGrid.Size = new System.Drawing.Size (500, 500); + + CheckBox checkbox_allownav = new CheckBox (); + checkbox_allownav.Location = new System.Drawing.Point (430 + 100, 100); + checkbox_allownav.Text = "AllowNavigation"; + checkbox_allownav.Click += new System.EventHandler (checkbox_allownavChecked); + checkbox_allownav.Checked = dataGrid.AllowNavigation; + Controls.Add (checkbox_allownav); + + CheckBox checkbox_allowsorting = new CheckBox (); + checkbox_allowsorting.Location = new System.Drawing.Point (430 + 240, 100); + checkbox_allowsorting.Text = "AllowSorting"; + checkbox_allowsorting.Click += new System.EventHandler (checkbox_allowsortingChecked); + checkbox_allowsorting.Checked = dataGrid.AllowSorting; + Controls.Add (checkbox_allowsorting); + + CheckBox checkbox_captionvisible = new CheckBox (); + checkbox_captionvisible.Location = new System.Drawing.Point (430 + 100, 130); + checkbox_captionvisible.Text = "CaptionVisible"; + checkbox_captionvisible.Click += new System.EventHandler (checkbox_captionvisibleChecked); + checkbox_captionvisible.Checked = dataGrid.CaptionVisible; + Controls.Add (checkbox_captionvisible); + + CheckBox checkbox_columnvisibile = new CheckBox (); + checkbox_columnvisibile.Location = new System.Drawing.Point (430 + 240, 130); + checkbox_columnvisibile.Text = "ColHdrVisible"; + checkbox_columnvisibile.Click += new System.EventHandler (checkbox_columnvisibileChecked); + checkbox_columnvisibile.Checked = dataGrid.ColumnHeadersVisible; + Controls.Add (checkbox_columnvisibile); + + CheckBox checkbox_flatmode = new CheckBox (); + checkbox_flatmode.Location = new System.Drawing.Point (430 + 100, 160); + checkbox_flatmode.Text = "FlatMode"; + checkbox_flatmode.Click += new System.EventHandler (checkbox_flatmodeChecked); + checkbox_flatmode.Checked = dataGrid.FlatMode; + Controls.Add (checkbox_flatmode); + + CheckBox checkbox_gridlinestyle = new CheckBox (); + checkbox_gridlinestyle.Location = new System.Drawing.Point (430 + 240, 160); + checkbox_gridlinestyle.Text = "GridLineStyle"; + checkbox_gridlinestyle.Click += new System.EventHandler (checkbox_gridlinestyleChecked); + Controls.Add (checkbox_gridlinestyle); + + if (dataGrid.GridLineStyle == DataGridLineStyle.None) { + checkbox_gridlinestyle.Checked = false; + } else { + checkbox_gridlinestyle.Checked = true; + } + + + CheckBox checkbox_parentrowsvisible = new CheckBox (); + checkbox_parentrowsvisible.Location = new System.Drawing.Point (430 + 100, 190); + checkbox_parentrowsvisible.Text = "ParentRowsVisible"; + checkbox_parentrowsvisible.Size = new Size (140, 20); + checkbox_parentrowsvisible.Click += new System.EventHandler (parentrowsvisibleChecked); + checkbox_parentrowsvisible.Checked = dataGrid.ParentRowsVisible; + Controls.Add (checkbox_parentrowsvisible); + + CheckBox checkbox_readonly = new CheckBox (); + checkbox_readonly.Location = new System.Drawing.Point (430 + 240, 190); + checkbox_readonly.Text = "ReadOnly"; + checkbox_readonly.Click += new System.EventHandler (readonlyChecked); + checkbox_readonly.Checked = dataGrid.ReadOnly; + Controls.Add (checkbox_readonly); + + CheckBox checkbox_rowshdrsvisible = new CheckBox (); + checkbox_rowshdrsvisible.Location = new System.Drawing.Point (430 + 100, 220); + checkbox_rowshdrsvisible.Text = "RowHeadersVisible"; + checkbox_rowshdrsvisible.Size = new Size (140, 20); + checkbox_rowshdrsvisible.Click += new System.EventHandler (rowshdrsvisibleChecked); + checkbox_rowshdrsvisible.Checked = dataGrid.RowHeadersVisible; + Controls.Add (checkbox_rowshdrsvisible); + + + // + // MainForm + // + AutoScaleBaseSize = new System.Drawing.Size (5, 13); + ClientSize = new System.Drawing.Size (800, 700); + Controls.Add (dataGrid); + Text = "DataGridTestProperties"; + Load += new System.EventHandler(MainFormLoad); + ResumeLayout (false); + } + + /* + public static void Main(string[] args) + { + Application.Run(new DatagridSample1()); + }*/ + + void MainFormLoad (object sender, System.EventArgs e) + { + ((System.ComponentModel.ISupportInitialize)(dataGrid)).BeginInit(); + FillDataSet (); + ((System.ComponentModel.ISupportInitialize)(dataGrid)).EndInit(); + } + + private void FillDataSet () + { + + // Create a FileStream object with the file path and name. + System.IO.FileStream myFileStream = new System.IO.FileStream ("programes.xsd",System.IO.FileMode.Open); + + // Create a new XmlTextReader object with the FileStream. + System.Xml.XmlTextReader myXmlTextReader= + new System.Xml.XmlTextReader(myFileStream); + // Read the schema into the DataSet and close the reader. + dsSource.ReadXmlSchema(myXmlTextReader); + myXmlTextReader.Close(); + + + // Read the XML document back in. + // Create new FileStream to read schema with. + System.IO.FileStream fsReadXml = new System.IO.FileStream + ("programes.xml", System.IO.FileMode.Open); + + System.Xml.XmlTextReader myXmlReader = new System.Xml.XmlTextReader(fsReadXml); + + dsSource.ReadXml (myXmlReader); + myXmlReader.Close(); + + dataGrid.DataSource = dsSource.Tables["programes"]; + + } + + } +} Added: trunk/winforms/datagrid/swf-datagrid.cs =================================================================== --- trunk/winforms/datagrid/swf-datagrid.cs 2005-04-05 07:44:13 UTC (rev 42550) +++ trunk/winforms/datagrid/swf-datagrid.cs 2005-04-05 08:51:13 UTC (rev 42551) @@ -0,0 +1,93 @@ +// 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) 2005 Novell, Inc. (http://www.novell.com) +// +// Author: +// Jordi Mas i Hernandez <[EMAIL PROTECTED]> +// +// + +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace DatagridSamples +{ + class DataGridSamples : Form + { + class OurButton : Button + { + public Form form = null; + + public OurButton (Form f) + { + form = f; + } + } + + public DataGridSamples () + { + InitializeComponent (); + } + + public void CreateSampleEntry (string description, Form form, ref int y) + { + Label label = new Label (); + label.Text = description; + label.Location = new Point (10, y + 5); + label.AutoSize = true; + Controls.Add (label); + + OurButton button = new OurButton (form); + button.Text = "Run sample"; + button.Location = new Point (180, y); + button.Click += new System.EventHandler (this.label2_Click); + Controls.Add (button); + + y += 30; + } + + private void label2_Click (object sender, System.EventArgs e) + { + ((OurButton)sender).form.ShowDialog (this); + } + + + void InitializeComponent () + { + int y = 10; + + CreateSampleEntry ("With real data ", new DataGridRealSample (), ref y); + CreateSampleEntry ("Properties testing", new DataGridTestProperties (), ref y); + CreateSampleEntry ("Properties table navigation", new DataGridTableNavigation (), ref y); + CreateSampleEntry ("Table and column styles", new DataGridStyles (), ref y); + Text = "SWF-Datagrid app"; + Name = "MainForm"; + ClientSize = new Size (300, 300); + } + + + public static void Main (string[] args) + { + Application.Run (new DataGridSamples ()); + } + + } +} _______________________________________________ Mono-patches maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-patches
