Author: toshok Date: 2006-05-30 16:14:21 -0400 (Tue, 30 May 2006) New Revision: 61286
Added: trunk/winforms/datagrid/swf-datagrid-editinfo.cs trunk/winforms/datagrid/swf-datagrid-relations.cs Modified: trunk/winforms/datagrid/Makefile trunk/winforms/datagrid/swf-datagrid.cs Log: add a test that basically spews a bunch of stuff while editing (swf-datagrid-editinfo.cs), and one that contains a relation so we can navigate between the datatables (swf-datagrid-relations.cs) Modified: trunk/winforms/datagrid/Makefile =================================================================== --- trunk/winforms/datagrid/Makefile 2006-05-30 20:14:15 UTC (rev 61285) +++ trunk/winforms/datagrid/Makefile 2006-05-30 20:14:21 UTC (rev 61286) @@ -1,7 +1,7 @@ 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 + mcs /debug swf-datagrid.cs swf-datagrid-realsample.cs swf-datagrid-testproperties.cs swf-datagrid-tablenav.cs swf-datagrid-styles.cs swf-datagrid-editinfo.cs swf-datagrid-relations.cs /r:System.Windows.Forms.dll /r:System.Drawing.dll /r:System.Data.dll dotnet: swf-datagrid.cs Added: trunk/winforms/datagrid/swf-datagrid-editinfo.cs =================================================================== --- trunk/winforms/datagrid/swf-datagrid-editinfo.cs 2006-05-30 20:14:15 UTC (rev 61285) +++ trunk/winforms/datagrid/swf-datagrid-editinfo.cs 2006-05-30 20:14:21 UTC (rev 61286) @@ -0,0 +1,218 @@ +// 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. (http://www.novell.com) +// +// Author: +// Chris Toshok <[EMAIL PROTECTED]> +// +// + +using System; +using System.Windows.Forms; +using System.Data; +using System.Drawing; +using System.ComponentModel; + +namespace DatagridSamples +{ + class MyDataGridColumn : DataGridTextBoxColumn + { + public MyDataGridColumn (PropertyDescriptor prop, bool isDefault) + : base (prop, isDefault) + { + } + + protected override void ColumnStartedEditing (Control editingControl) + { + Console.WriteLine ("ColumnStartedEditing {0} {1}\n{2}", editingControl.GetType (), editingControl.Bounds, Environment.StackTrace); + base.ColumnStartedEditing (editingControl); + } + + protected override void ConcedeFocus () + { + Console.WriteLine ("ConcedeFocus {0}", Environment.StackTrace); + base.ConcedeFocus (); + } + + protected override bool Commit (CurrencyManager dataSource, int rowNum) + { + // Console.WriteLine ("Commit (rowNum = {0})\n{1}", rowNum, Environment.StackTrace); + return base.Commit (dataSource, rowNum); + } + + protected override void Edit (CurrencyManager source, int rowNum, Rectangle bounds, bool readOnly, string instantText, bool cellIsVisible) + { + Console.WriteLine ("Edit\n{0}", Environment.StackTrace); + base.Edit (source, rowNum, bounds, readOnly, instantText, cellIsVisible); + } + + protected override void EnterNullValue () + { + Console.WriteLine ("EnterNullValue\n{0}", Environment.StackTrace); + base.EnterNullValue (); + } + + protected override object GetColumnValueAtRow (CurrencyManager source, int rowNum) + { + // Console.WriteLine ("GetColumnValueAtRow (rowNum = {0})\n{1}", rowNum, Environment.StackTrace); + return base.GetColumnValueAtRow (source, rowNum); + } + + protected override void Invalidate () + { + Console.WriteLine ("Invalidate\n{0}", Environment.StackTrace); + base.Invalidate (); + } + + protected override void UpdateUI (CurrencyManager source, int rowNum, string instantText) + { + Console.WriteLine ("UpdateUI ({0}, {1})\n{2}", rowNum, instantText, Environment.StackTrace); + base.UpdateUI (source, rowNum, instantText); + } + } + + class MyDataGridTableStyle : DataGridTableStyle { + public MyDataGridTableStyle () + { + MappingName = "programes"; + } + + + protected override DataGridColumnStyle CreateGridColumn (PropertyDescriptor prop, bool isDefault) + { + if (prop.PropertyType == typeof (bool)) + return new DataGridBoolColumn (prop, isDefault); + return new MyDataGridColumn (prop, isDefault); + } + + } + + class MyDataGrid : DataGrid { + protected override void CancelEditing () + { + // Console.WriteLine ("in CancelEditing {0}", Environment.StackTrace); + base.CancelEditing (); + } + + protected override void ColumnStartedEditing (Control editingControl) + { + // Console.WriteLine ("in ColumnStartedEditing {0} {1}", editingControl.GetType (), Environment.StackTrace); + base.ColumnStartedEditing (editingControl); + } + + protected override void ColumnStartedEditing (Rectangle bounds) + { + // Console.WriteLine ("in ColumnStartedEditing {0} {1}", bounds, Environment.StackTrace); + base.ColumnStartedEditing (bounds); + } + + protected override string GetOutputTextDelimiter () + { + // Console.WriteLine ("GetOutputTextDelimiter {0}", Environment.StackTrace); + return base.GetOutputTextDelimiter (); + } + } + + class DataGridEditInfo : Form + { + private DataGrid dataGrid; + private DataSet dsSource = new DataSet (); + private DataTable programs; + private DataTable applications; + private DataTable utilities; + + public DataGridEditInfo () + { + InitializeComponent (); + } + + void InitializeComponent () + { + SuspendLayout (); + + // + // dataGrid + // + dataGrid = new MyDataGrid (); + 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); + dataGrid.TableStyles.Add (new MyDataGridTableStyle ()); + // + // MainForm + // + Text = "SWF-Datagrid Styles"; + ClientSize = new System.Drawing.Size (850, 650); + Controls.Add(dataGrid); + Load += new System.EventHandler(MainFormLoad); + ResumeLayout (false); + } + + void MainFormLoad (object sender, System.EventArgs e) + { + FillDataSet (); + dataGrid.ReadOnly = false; + dataGrid.Layout += new LayoutEventHandler (doing_layout); + return; + } + + 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 (); + + programs = dsSource.Tables["programes"].Copy (); + + applications = dsSource.Tables["programes"].Copy (); + applications.TableName = "applications"; + applications.Columns.RemoveAt (0); + + utilities = dsSource.Tables["programes"].Copy (); + utilities.TableName = "utilities"; + utilities.Columns.RemoveAt (2); + utilities.Columns.RemoveAt (3); + utilities.Columns.RemoveAt (4); + + DataSet dataset = new DataSet (); + dataset.Tables.Add (applications); + dataset.Tables.Add (utilities); + dataset.Tables.Add (programs); + dataGrid.DataSource = dataset; + dataGrid.DataMember = "programes"; + } + + void doing_layout (object sender, LayoutEventArgs a) + { + Console.WriteLine ("laying out"); + } + } +} Added: trunk/winforms/datagrid/swf-datagrid-relations.cs =================================================================== --- trunk/winforms/datagrid/swf-datagrid-relations.cs 2006-05-30 20:14:15 UTC (rev 61285) +++ trunk/winforms/datagrid/swf-datagrid-relations.cs 2006-05-30 20:14:21 UTC (rev 61286) @@ -0,0 +1,250 @@ +// 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: +// Chris Toshok <[EMAIL PROTECTED]> +// +// +using System; +using System.Windows.Forms; +using System.Drawing; +using System.Data; +using System.Xml; + +namespace DatagridSamples +{ + class DataGridTestRelations : Form + { + private DataGrid dataGrid; + private Label label_backcolor; + private Label label_altbackcolor; + private Label label_backgroundcolor; + + public DataGridTestRelations () + { + InitializeComponent (); + } + + 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; + } + + private void button_backcolorClick (object sender, System.EventArgs e) + { + ColorDialog colorDialog = new ColorDialog (); + + if (DialogResult.OK == colorDialog.ShowDialog ()) { + dataGrid.BackColor = colorDialog.Color; + label_backcolor.Text = "Back color: " + dataGrid.BackColor; + } + } + + private void button_altbackcolorClick (object sender, System.EventArgs e) + { + ColorDialog colorDialog = new ColorDialog (); + + if (DialogResult.OK == colorDialog.ShowDialog ()) { + dataGrid.AlternatingBackColor = colorDialog.Color; + label_altbackcolor.Text = "Alt Background color: " + dataGrid.AlternatingBackColor; + } + } + + private void button_backgroundcolorClick (object sender, System.EventArgs e) + { + ColorDialog colorDialog = new ColorDialog (); + + if (DialogResult.OK == colorDialog.ShowDialog ()) { + dataGrid.BackgroundColor = colorDialog.Color; + label_backgroundcolor.Text = "Background color: " + dataGrid.BackgroundColor; + } + } + + void InitializeComponent () + { + 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_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); + + label_backcolor = new Label (); + label_backcolor.Location = new System.Drawing.Point (430 + 210, 300); + label_backcolor.Text = "Back color: " + dataGrid.BackColor; + label_backcolor.Size = new Size (160, 30); + Controls.Add (label_backcolor); + + Button button_backcolor = new Button (); + button_backcolor.Location = new System.Drawing.Point (430 + 100, 300); + button_backcolor.Text = "Set Back Color"; + button_backcolor.Size = new Size (100, 30); + button_backcolor.Click += new System.EventHandler (button_backcolorClick); + Controls.Add (button_backcolor); + + label_altbackcolor = new Label (); + label_altbackcolor.Location = new System.Drawing.Point (430 + 210, 340); + label_altbackcolor.Text = "Alt Background color: " + dataGrid.BackColor; + label_altbackcolor.Size = new Size (160, 30); + Controls.Add (label_altbackcolor); + + Button button_altbackcolor = new Button (); + button_altbackcolor.Location = new System.Drawing.Point (430 + 100, 340); + button_altbackcolor.Text = "Set Alt Back Color"; + button_altbackcolor.Size = new Size (100, 30); + button_altbackcolor.Click += new System.EventHandler (button_altbackcolorClick); + Controls.Add (button_altbackcolor); + + label_backgroundcolor = new Label (); + label_backgroundcolor.Location = new System.Drawing.Point (430 + 210, 380); + label_backgroundcolor.Text = "Background color: " + dataGrid.BackColor; + label_backgroundcolor.Size = new Size (160, 30); + Controls.Add (label_backgroundcolor); + + Button button_backgroundcolor = new Button (); + button_backgroundcolor.Location = new System.Drawing.Point (430 + 100, 380); + button_backgroundcolor.Text = "Set Background Color"; + button_backgroundcolor.Size = new Size (100, 30); + button_backgroundcolor.Click += new System.EventHandler (button_backgroundcolorClick); + Controls.Add (button_backgroundcolor); + + + // + // 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(); + FillDataSetLarge (); + ((System.ComponentModel.ISupportInitialize)(dataGrid)).EndInit(); + } + + private void FillDataSetLarge () + { + DataSet dataset = new DataSet ("CustomerSet"); + DataTable dt1 = new DataTable ("Customers"); + DataTable dt2 = new DataTable ("Orders"); + DataColumn column; + + column = new DataColumn ("CustomerID"); + column.DataType = typeof (int); + column.Unique = true; + dt1.Columns.Add (column); + + column = new DataColumn ("CustomerName"); + column.DataType = typeof (string); + column.Unique = false; + dt1.Columns.Add (column); + + column = new DataColumn ("OrderID"); + column.DataType = typeof (int); + column.Unique = true; + dt2.Columns.Add (column); + + column = new DataColumn ("ItemName"); + column.DataType = typeof (string); + column.Unique = false; + dt2.Columns.Add (column); + + column = new DataColumn ("CustomerID"); + column.DataType = typeof (int); + column.Unique = false; + dt2.Columns.Add (column); + + for (int i = 0; i < 10; i ++) { + DataRow row = dt1.NewRow (); + row["CustomerID"] = i; + row["CustomerName"] = String.Format ("Customer Name #{0}", i); + dt1.Rows.Add (row); + } + + int ordernum = 0; + for (int i = 0; i < 10; i ++) { + for (int j = 0; j < 4; j ++) { + DataRow row = dt2.NewRow (); + row["OrderID"] = ordernum++; + row["ItemName"] = String.Format ("Item order #{0}", j); + row["CustomerID"] = 9-i; + dt2.Rows.Add (row); + } + } + + dataset.Tables.Add (dt1); + dataset.Tables.Add (dt2); + dataset.Relations.Add ("Customer_Order", dt1.Columns["CustomerID"], dt2.Columns["CustomerID"]); + + dataGrid.DataSource = dataset; + dataGrid.DataMember = "Customers"; + dataGrid.AllowNavigation = true; + } + + } +} Modified: trunk/winforms/datagrid/swf-datagrid.cs =================================================================== --- trunk/winforms/datagrid/swf-datagrid.cs 2006-05-30 20:14:15 UTC (rev 61285) +++ trunk/winforms/datagrid/swf-datagrid.cs 2006-05-30 20:14:21 UTC (rev 61286) @@ -78,6 +78,8 @@ CreateSampleEntry ("Properties testing", new DataGridTestProperties (), ref y); CreateSampleEntry ("Properties table navigation", new DataGridTableNavigation (), ref y); CreateSampleEntry ("Table and column styles", new DataGridStyles (), ref y); + CreateSampleEntry ("Relations", new DataGridTestRelations (), ref y); + CreateSampleEntry ("Edit info", new DataGridEditInfo (), ref y); Text = "SWF-Datagrid app"; Name = "MainForm"; ClientSize = new Size (300, 300); _______________________________________________ Mono-patches maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-patches
