[Mono-dev] Win Patches for Datagrid (first here) then idle
Rob Wilkens
robwilkens at gmail.com
Tue Jun 19 11:49:45 UTC 2012
I took someone's suggestion on formatting code, and that was to run it
through the monodevelop code formatter.
This changed one or two lines outside of my own code, but let me know if
this one looks ok to you.
Attached is revised DataGridTest.cs patch.
-Rob
On 06/19/2012 05:54 AM, Stifu wrote:
> By the way, make sure to fix the coding style.
>
> OnMouseDown(me); -> OnMouseDown (me);
> if( disposing ) -> if (disposing)
> base.Dispose( disposing ); -> base.Dispose (disposing);
>
> etc
-------------- next part --------------
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTest.cs
index f49ecd8..2dce886 100644
--- a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTest.cs
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTest.cs
@@ -23,7 +23,6 @@
// Jordi Mas i Hernandez <jordi at ximian.com>
//
//
-
using System;
using System.Collections;
using System.ComponentModel;
@@ -32,14 +31,14 @@ using System.Windows.Forms;
using System.Xml;
using NUnit.Framework;
using System.Data;
+using System.Xml;
namespace MonoTests.System.Windows.Forms
{
// Helper classes
-
- class TestDataGrid : DataGrid
+ class TestDataGrid : DataGrid
{
- public TestDataGrid ()
+ public TestDataGrid ()
{
}
@@ -56,7 +55,6 @@ namespace MonoTests.System.Windows.Forms
{
private bool eventhandled;
-
[Test]
public void TestDefaultValues ()
{
@@ -111,7 +109,7 @@ namespace MonoTests.System.Windows.Forms
{
DataGrid dg = new DataGrid ();
eventhandled = false;
- dg.BackgroundColorChanged += new EventHandler (OnEventHandler);
+ dg.BackgroundColorChanged += new EventHandler (OnEventHandler);
dg.BackgroundColor = Color.Red;
Assert.AreEqual (true, eventhandled, "A1");
}
@@ -121,7 +119,7 @@ namespace MonoTests.System.Windows.Forms
{
DataGrid dg = new DataGrid ();
eventhandled = false;
- dg.BorderStyleChanged += new EventHandler (OnEventHandler);
+ dg.BorderStyleChanged += new EventHandler (OnEventHandler);
dg.BorderStyle = BorderStyle.None;
Assert.AreEqual (true, eventhandled, "A1");
}
@@ -204,13 +202,12 @@ namespace MonoTests.System.Windows.Forms
Assert.AreSame (dg.HeaderFont, dg.Font, "#5");
}
-
[Test]
public void TestParentRowsLabelStyleChangedEvent ()
{
DataGrid dg = new DataGrid ();
eventhandled = false;
- dg.ParentRowsLabelStyleChanged += new EventHandler (OnEventHandler);
+ dg.ParentRowsLabelStyleChanged += new EventHandler (OnEventHandler);
dg.ParentRowsLabelStyle = DataGridParentRowsLabelStyle.None;
Assert.AreEqual (true, eventhandled, "A1");
}
@@ -220,7 +217,7 @@ namespace MonoTests.System.Windows.Forms
{
DataGrid dg = new DataGrid ();
eventhandled = false;
- dg.ParentRowsVisibleChanged += new EventHandler (OnEventHandler);
+ dg.ParentRowsVisibleChanged += new EventHandler (OnEventHandler);
dg.ParentRowsVisible = !dg.ParentRowsVisible;
Assert.AreEqual (true, eventhandled, "A1");
}
@@ -230,7 +227,7 @@ namespace MonoTests.System.Windows.Forms
{
DataGrid dg = new DataGrid ();
eventhandled = false;
- dg.ReadOnlyChanged += new EventHandler (OnEventHandler);
+ dg.ReadOnlyChanged += new EventHandler (OnEventHandler);
dg.ReadOnly = !dg.ReadOnly;
Assert.AreEqual (true, eventhandled, "A1");
}
@@ -384,6 +381,7 @@ namespace MonoTests.System.Windows.Forms
}
int data_source_changed_count = 0;
+
void OnDataSourceChanged (object sender, EventArgs e)
{
data_source_changed_count ++;
@@ -603,7 +601,7 @@ namespace MonoTests.System.Windows.Forms
DataSet ds = new DataSet ("DataSet");
DataTable dt = new DataTable ("MyTable");
- dt.Columns.Add ("A", typeof (string));
+ dt.Columns.Add ("A", typeof(string));
dt.NewRow ();
ds.Tables.Add (dt);
@@ -619,5 +617,96 @@ namespace MonoTests.System.Windows.Forms
Assert.AreEqual (1, table_style.GridColumnStyles.Count, "#B1");
}
+
+ public class ClickableDataGrid : DataGrid
+ {
+ public void ClickGrid (int X, int Y)
+ {
+ MouseEventArgs me = new MouseEventArgs (
+ MouseButtons.Left,
+ 1, /*# of clicks*/
+ X, Y, 0);
+ OnMouseDown (me);
+ OnClick (me);
+ OnMouseUp (me);
+ }
+ }
+
+ public class Form5487 : Form
+ {
+ private ClickableDataGrid dataGrid1;
+ private Container components = null;
+
+ public Form5487 ()
+ {
+ InitializeComponent ();
+ }
+
+ protected override void Dispose (bool disposing)
+ {
+ if (disposing) {
+ if (components != null) {
+ components.Dispose ();
+ }
+ }
+ base.Dispose (disposing);
+ }
+
+ private void InitializeComponent ()
+ {
+ this.dataGrid1 = new ClickableDataGrid ();
+ ((ISupportInitialize)(this.dataGrid1)).BeginInit ();
+ this.SuspendLayout ();
+ this.dataGrid1.DataMember = "";
+ this.dataGrid1.HeaderForeColor = SystemColors.ControlText;
+ this.dataGrid1.Location = new Point (16, 16);
+ this.dataGrid1.Name = "dataGrid1";
+ this.dataGrid1.Size = new Size (624, 440);
+ this.dataGrid1.TabIndex = 0;
+ this.AutoScaleBaseSize = new Size (5, 13);
+ this.ClientSize = new Size (656, 470);
+ this.Controls.Add (this.dataGrid1);
+ this.Name = "Form1";
+ this.Text = "Form1";
+ this.Shown += new EventHandler (this.Form1_Load);
+ ((ISupportInitialize)(this.dataGrid1)).EndInit ();
+ this.ResumeLayout (false);
+
+ }
+
+ private void Form1_Load (object sender, EventArgs e)
+ {
+ DataSet ds = new DataSet ();
+ String XMLString = "";
+ XmlTextReader XMLTR;
+
+ XMLString += "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
+ XMLString += "<pa><pb><pc><pd><id>1</id>";
+ XMLString += "</pd></pc><pc><pd><id>1</id>";
+ XMLString += "</pd><pd><id>1</id></pd><pd>";
+ XMLString += "<id>1</id></pd><pd><id>1</id>";
+ XMLString += "</pd><pd><id>1</id></pd><pd>";
+ XMLString += "<id>1</id></pd><pd><id>1</id>";
+ XMLString += "</pd><pd><id>1</id></pd></pc>";
+ XMLString += "</pb></pa>";
+ XMLTR = new XmlTextReader (XMLString,
+ XmlNodeType.Document, null);
+ XMLTR.ReadOuterXml ();
+ ds.ReadXml (XMLTR);
+ this.dataGrid1.DataSource = ds;
+ this.dataGrid1.ClickGrid (25, 45);
+ Application.DoEvents ();
+ this.dataGrid1.ClickGrid (46, 73);
+ Application.DoEvents ();
+ this.dataGrid1.NavigateBack ();
+ Close ();
+ }
+ }
+ [Test]
+ public void Bug5487AndRelated ()
+ {
+ //this should crash on fail
+ Application.Run (new Form5487 ());
+ }
}
}
More information about the Mono-devel-list
mailing list