Author: jordi
Date: 2005-07-06 14:01:46 -0400 (Wed, 06 Jul 2005)
New Revision: 47015
Removed:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataSourceHelper.cs
Modified:
trunk/mcs/class/Managed.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/SWF.csproj
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridDrawingLogic.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTextBoxColumn.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridColumnStylesCollection.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridTableStylesCollection.cs
Log:
In .:
2005-07-06 Jordi Mas i Hernandez <[EMAIL PROTECTED]>
* DataGridTextBoxColumn.cs: default value
* GridColumnStylesCollection.cs: fixes event firing, checking
MappingName
* GridTableStylesCollection.cs: fixes checking MappingName
* DataGridDrawingLogic.cs: fixes drawing logic issues
* DataSourceHelper.cs: rewritten to make compatible with more data
sources
* DataGrid.cs: fixes
In System.Windows.Forms:
2005-07-06 Jordi Mas i Hernandez <[EMAIL PROTECTED]>
* DataGridTextBoxColumn.cs: default value
* GridColumnStylesCollection.cs: fixes event firing, checking
MappingName
* GridTableStylesCollection.cs: fixes checking MappingName
* DataGridDrawingLogic.cs: fixes drawing logic issues
* DataSourceHelper.cs: rewritten to make compatible with more data
sources
* DataGrid.cs: fixes
Modified: trunk/mcs/class/Managed.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/ChangeLog 2005-07-06 17:48:25 UTC
(rev 47014)
+++ trunk/mcs/class/Managed.Windows.Forms/ChangeLog 2005-07-06 18:01:46 UTC
(rev 47015)
@@ -1,4 +1,13 @@
+2005-07-06 Jordi Mas i Hernandez <[EMAIL PROTECTED]>
+ * DataGridTextBoxColumn.cs: default value
+ * GridColumnStylesCollection.cs: fixes event firing, checking
MappingName
+ * GridTableStylesCollection.cs: fixes checking MappingName
+ * DataGridDrawingLogic.cs: fixes drawing logic issues
+ * DataSourceHelper.cs: rewritten to make compatible with more data
sources
+ * DataGrid.cs: fixes
+
+
2005-07-04 Ritvik Mayank <[EMAIL PROTECTED]>
* System.Windows.Forms_test.dll.sources : Added ListBoxTest.cs and
Modified: trunk/mcs/class/Managed.Windows.Forms/SWF.csproj
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/SWF.csproj 2005-07-06 17:48:25 UTC
(rev 47014)
+++ trunk/mcs/class/Managed.Windows.Forms/SWF.csproj 2005-07-06 18:01:46 UTC
(rev 47015)
@@ -549,11 +549,6 @@
BuildAction = "Compile"
/>
<File
- RelPath = "System.Windows.Forms\DataSourceHelper.cs"
- SubType = "Code"
- BuildAction = "Compile"
- />
- <File
RelPath = "System.Windows.Forms\DateBoldEventArgs.cs"
SubType = "Code"
BuildAction = "Compile"
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2005-07-06 17:48:25 UTC (rev 47014)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2005-07-06 18:01:46 UTC (rev 47015)
@@ -1,3 +1,12 @@
+2005-07-06 Jordi Mas i Hernandez <[EMAIL PROTECTED]>
+
+ * DataGridTextBoxColumn.cs: default value
+ * GridColumnStylesCollection.cs: fixes event firing, checking
MappingName
+ * GridTableStylesCollection.cs: fixes checking MappingName
+ * DataGridDrawingLogic.cs: fixes drawing logic issues
+ * DataSourceHelper.cs: rewritten to make compatible with more data
sources
+ * DataGrid.cs: fixes
+
2005-07-06 Alexander Olk <[EMAIL PROTECTED]>
* MimeGenerated.cs: Use case sensitive comparer for
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs
2005-07-06 17:48:25 UTC (rev 47014)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs
2005-07-06 18:01:46 UTC (rev 47015)
@@ -150,7 +150,7 @@
private Color link_hovercolor;
private Color parentrowsback_color;
private Color parentrowsfore_color;
- internal bool parentrows_visible;
+ private bool parentrows_visible;
private int preferredcolumn_width;
private int preferredrow_height;
private bool _readonly;
@@ -215,7 +215,7 @@
link_hovercolor = def_link_hovercolor;
parentrowsback_color = def_parentrowsback_color;
parentrowsfore_color = def_parentrowsfore_color;
- parentrows_visible = false; // should be true (temp)
+ parentrows_visible = true;
preferredcolumn_width =
ThemeEngine.Current.DataGridPreferredColumnWidth;
_readonly = false;
rowheaders_visible = true;
@@ -458,6 +458,14 @@
int old_row = current_cell.RowNumber;
+ if (value.RowNumber >= RowsCount) {
+ value.RowNumber = RowsCount ==
0 ? 0 : RowsCount - 1;
+ }
+
+ if (value.ColumnNumber >=
CurrentTableStyle.GridColumnStyles.Count) {
+ value.ColumnNumber =
CurrentTableStyle.GridColumnStyles.Count == 0 ? 0:
CurrentTableStyle.GridColumnStyles.Count - 1;
+ }
+
EnsureCellVisilibility (value);
current_cell = value;
@@ -466,7 +474,10 @@
}
accept_listmgrevents = false;
- cached_currencymgr_events.Position =
current_cell.RowNumber;
+
+ if (cached_currencymgr_events != null)
{
+
cached_currencymgr_events.Position = current_cell.RowNumber;
+ }
accept_listmgrevents = true;
InvalidateCurrentRowHeader ();
OnCurrentCellChanged (EventArgs.Empty);
@@ -478,6 +489,10 @@
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public int CurrentRowIndex {
get {
+ if (ListManager == null) {
+ return -1;
+ }
+
return current_cell.RowNumber;
}
@@ -965,7 +980,7 @@
get { return first_visiblerow; }
set { first_visiblerow = value;}
}
-
+
internal int RowsCount {
get {
if (ListManager != null) {
@@ -996,7 +1011,16 @@
return _readonly == false;
}
}
-
+
+ // It should only be shown if there are relations that
+ // we do not support right now
+ internal bool ShowParentRowsVisible {
+ get {
+ //See parentrows_visible;
+ return false;
+ }
+ }
+
#endregion Private Instance Properties
#region Public Instance Methods
@@ -1014,7 +1038,9 @@
protected virtual void CancelEditing ()
{
-
CurrentTableStyle.GridColumnStyles[current_cell.ColumnNumber].Abort
(current_cell.RowNumber);
+ if (current_cell.ColumnNumber <
CurrentTableStyle.GridColumnStyles.Count) {
+
CurrentTableStyle.GridColumnStyles[current_cell.ColumnNumber].Abort
(current_cell.RowNumber);
+ }
if (is_adding == true) {
ListManager.RemoveAt (RowsCount - 1);
@@ -1131,11 +1157,10 @@
int old_first_visiblerow = first_visiblerow;
first_visiblerow = se.NewValue;
grid_drawing.UpdateVisibleRowCount ();
-
+
if (first_visiblerow == old_first_visiblerow) {
return;
- }
-
+ }
ScrollToRow (old_first_visiblerow, first_visiblerow);
}
@@ -1775,7 +1800,58 @@
vert_scrollbar.Value = first_visiblerow;
}
}
+
+ internal IEnumerable GetDataSource (object source, string
member)
+ {
+ IListSource src = (IListSource) source;
+ IList list = src.GetList();
+ IListSource listsource;
+ ITypedList typedlist;
+
+ if (source is IEnumerable) {
+ return (IEnumerable) source;
+ }
+
+ if(src.ContainsListCollection == false) {
+ return list;
+ }
+
+ listsource = (IListSource) source;
+
+ if (listsource == null) {
+ return null;
+ }
+
+ list = src.GetList ();
+
+ if (list == null) {
+ return null;
+ }
+
+ typedlist = (ITypedList) list;
+
+ if (typedlist == null) {
+ return null;
+ }
+ PropertyDescriptorCollection col =
typedlist.GetItemProperties (new PropertyDescriptor [0]);
+ PropertyDescriptor prop = col.Find (member, true);
+
+ if (prop == null) {
+ if (col.Count > 0) {
+ prop = col[0];
+
+ if (prop == null) {
+ return null;
+ }
+ }
+ }
+
+ IEnumerable result = (IEnumerable)(prop.GetValue
(list[0]));
+ return result;
+
+ }
+
internal void InvalidateCurrentRowHeader ()
{
grid_drawing.InvalidateRowHeader
(current_cell.RowNumber);
@@ -1788,7 +1864,7 @@
}
datamember = member;
- real_datasource =
DataSourceHelper.GetResolvedDataSource (datasource, member);
+ real_datasource = GetDataSource (datasource, member);
DisconnectListManagerEvents ();
cached_currencymgr = cached_currencymgr_events = null;
return true;
@@ -1800,12 +1876,13 @@
if (source != null && source as IListSource != null &&
source as IList != null) {
throw new Exception ("Wrong complex data
binding source");
}
-
+
+ current_cell = new DataGridCell ();
datasource = source;
DisconnectListManagerEvents ();
cached_currencymgr = cached_currencymgr_events = null;
try {
- real_datasource =
DataSourceHelper.GetResolvedDataSource (datasource, DataMember);
+ real_datasource = GetDataSource (datasource,
DataMember);
}catch (Exception e) {
real_datasource = source;
}
@@ -1815,8 +1892,7 @@
}
private void SetNewDataSource ()
- {
- current_cell = new DataGridCell ();
+ {
current_style.GridColumnStyles.Clear ();
current_style.CreateColumnsForTable (false);
CalcAreasAndInvalidate ();
@@ -1847,7 +1923,7 @@
private void OnTableStylesCollectionChanged (object sender,
CollectionChangeEventArgs e)
{
- if (String.Compare (ListManager.ListName,
((DataGridTableStyle)e.Element).MappingName, true) == 0) {
+ if (ListManager != null && String.Compare
(ListManager.ListName, ((DataGridTableStyle)e.Element).MappingName, true) == 0)
{
CurrentTableStyle =
(DataGridTableStyle)e.Element;
((DataGridTableStyle)
e.Element).CreateColumnsForTable (false);
}
@@ -1979,21 +2055,23 @@
private void ScrollToRow (int old_row, int new_row)
{
- Rectangle invalidate = new Rectangle ();
-
+ Rectangle invalidate = new Rectangle ();
+
if (new_row > old_row) { // Scrolldown
int scrolled_rows = new_row - old_row;
int pixels = scrolled_rows * RowHeight;
-
+ Rectangle rows_area = grid_drawing.CellsArea;
// Cells area - partial rows space
+ rows_area.Height =
grid_drawing.CellsArea.Height - grid_drawing.CellsArea.Height % RowHeight;
+
invalidate.X = grid_drawing.CellsArea.X;
- invalidate.Y = grid_drawing.CellsArea.Y +
grid_drawing.CellsArea.Height - pixels;
+ invalidate.Y = grid_drawing.CellsArea.Y +
rows_area.Height - pixels;
invalidate.Width = grid_drawing.CellsArea.Width;
invalidate.Height = pixels;
- XplatUI.ScrollWindow (Handle,
grid_drawing.CellsArea, 0, -pixels, false);
+ XplatUI.ScrollWindow (Handle, rows_area, 0,
-pixels, false);
} else { // ScrollUp
- int scrolled_rows = old_row - new_row;
+ int scrolled_rows = old_row - new_row;
int pixels = scrolled_rows * RowHeight;
invalidate.X = grid_drawing.CellsArea.X;
@@ -2004,7 +2082,7 @@
}
// Right now we use ScrollWindow Invalidate, let's
leave remarked it here for X11 if need it
- //Invalidate ();
+ //Invalidate (invalidate);
Invalidate (grid_drawing.RowsHeadersArea);
}
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridDrawingLogic.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridDrawingLogic.cs
2005-07-06 17:48:25 UTC (rev 47014)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridDrawingLogic.cs
2005-07-06 18:01:46 UTC (rev 47015)
@@ -154,7 +154,7 @@
UpdateVisibleRowCount (); // need it to be able to
calcultate the need of horz scrollbar
if (SetUpVerticalScrollBar ()) { // We need a Vertical
ScrollBar
- if (grid.parentrows_visible) {
+ if (grid.ShowParentRowsVisible) {
parent_rows.Width -=
grid.vert_scrollbar.Width;
}
@@ -213,7 +213,7 @@
cells_area.Y = client_area.Y;
}
- if (grid.parentrows_visible) {
+ if (grid.ShowParentRowsVisible) {
cells_area.Y += parent_rows.Height;
}
@@ -243,7 +243,7 @@
columnshdrs_area.Y = client_area.Y;
}
- if (grid.parentrows_visible) {
+ if (grid.ShowParentRowsVisible) {
columnshdrs_area.Y += parent_rows.Height;
}
@@ -274,7 +274,7 @@
public void CalcParentRows ()
{
- if (grid.parentrows_visible == false) {
+ if (grid.ShowParentRowsVisible == false) {
parent_rows = Rectangle.Empty;
return;
}
@@ -306,7 +306,7 @@
rowshdrs_area.Y = client_area.Y;
}
- if (grid.parentrows_visible) {
+ if (grid.ShowParentRowsVisible) {
rowshdrs_area.Y += parent_rows.Height;
}
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTextBoxColumn.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTextBoxColumn.cs
2005-07-06 17:48:25 UTC (rev 47014)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTextBoxColumn.cs
2005-07-06 18:01:46 UTC (rev 47015)
@@ -37,7 +37,7 @@
{
#region Local Variables
private string format;
- private IFormatProvider format_provider;
+ private IFormatProvider format_provider = null;
private StringFormat string_format = new StringFormat ();
private DataGridTextBox textbox = null;
#endregion // Local Variables
Deleted:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataSourceHelper.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataSourceHelper.cs
2005-07-06 17:48:25 UTC (rev 47014)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataSourceHelper.cs
2005-07-06 18:01:46 UTC (rev 47015)
@@ -1,86 +0,0 @@
-
-//
-// 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.
-//
-/**
- * Namespace: System.Web.UI.Util
- * Class: DataSourceHelper
- *
- * Author: Gaurav Vaish
- * Maintainer: [EMAIL PROTECTED]
- * Contact: <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]>
- * Status: 10%
- *
- * (C) Gaurav Vaish (2001)
- */
-
-using System;
-using System.Collections;
-using System.ComponentModel;
-
-namespace System.Windows.Forms
-{
- internal class DataSourceHelper
- {
- public static IEnumerable GetResolvedDataSource(object source,
string member)
- {
- if(source != null && source is IListSource)
- {
- IListSource src = (IListSource)source;
- IList list = src.GetList();
- if(!src.ContainsListCollection)
- {
- return list;
- }
- if(list != null && list is ITypedList)
- {
- ITypedList tlist = (ITypedList)list;
- PropertyDescriptorCollection pdc =
tlist.GetItemProperties(new PropertyDescriptor[0]);
- if(pdc != null && pdc.Count > 0)
- {
- PropertyDescriptor pd = null;
- if(member != null &&
member.Length > 0)
- {
- pd = pdc.Find(member,
true);
- } else
- {
- pd = pdc[0];
- }
- if(pd != null)
- {
- object rv =
pd.GetValue(list[0]);
- if(rv != null && rv is
IEnumerable)
- {
- return
(IEnumerable)rv;
- }
- }
- throw new
Exception(String.Format ("ListSource_Missing_DataMember {0}", member));
- }
- throw new
Exception("ListSource_Without_DataMembers");
- }
- }
- if(source is IEnumerable)
- {
- return (IEnumerable)source;
- }
- return null;
- }
- }
-}
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridColumnStylesCollection.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridColumnStylesCollection.cs
2005-07-06 17:48:25 UTC (rev 47014)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridColumnStylesCollection.cs
2005-07-06 18:01:46 UTC (rev 47015)
@@ -117,17 +117,14 @@
#region Public Instance Methods
public virtual int Add (DataGridColumnStyle column)
{
- int cnt = AddInternal (column);
- OnCollectionChanged (new CollectionChangeEventArgs
(CollectionChangeAction.Add, column));
+ int cnt = AddInternal (column);
return cnt;
}
public void AddRange (DataGridColumnStyle[] columns)
{
foreach (DataGridColumnStyle mi in columns)
- AddInternal (mi);
-
- OnCollectionChanged (new CollectionChangeEventArgs
(CollectionChangeAction.Refresh, null));
+ AddInternal (mi);
}
public void Clear ()
@@ -163,10 +160,7 @@
int IList.Add (object value)
{
- int cnt = AddInternal ((DataGridColumnStyle)value);
-
- OnCollectionChanged (new CollectionChangeEventArgs
(CollectionChangeAction.Add, null));
- return cnt;
+ return AddInternal ((DataGridColumnStyle)value);
}
void IList.Clear ()
@@ -253,6 +247,7 @@
column.TableStyle = owner;
int cnt = items.Add (column);
+ OnCollectionChanged (new CollectionChangeEventArgs
(CollectionChangeAction.Add, column));
return cnt;
}
@@ -260,8 +255,8 @@
{
for (int i = 0; i < items.Count; i++) {
DataGridColumnStyle column =
(DataGridColumnStyle) items[i];
-
- if (column.MappingName == null)
+
+ if (column.MappingName == null ||
column.MappingName == string.Empty)
continue;
if (String.Compare (column.MappingName,
columnName, true) == 0) {
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridTableStylesCollection.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridTableStylesCollection.cs
2005-07-06 17:48:25 UTC (rev 47014)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridTableStylesCollection.cs
2005-07-06 18:01:46 UTC (rev 47015)
@@ -219,7 +219,7 @@
for (int i = 0; i < items.Count; i++) {
DataGridTableStyle table = (DataGridTableStyle)
items[i];
- if (table.MappingName == null)
+ if (table.MappingName == null ||
table.MappingName == string.Empty)
continue;
if (String.Compare (table.MappingName,
tableName, true) == 0) {
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources
2005-07-06 17:48:25 UTC (rev 47014)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources
2005-07-06 18:01:46 UTC (rev 47015)
@@ -91,7 +91,6 @@
System.Windows.Forms/DataGridTextBox.cs
System.Windows.Forms/DataGridTextBoxColumn.cs
System.Windows.Forms/DataObject.cs
-System.Windows.Forms/DataSourceHelper.cs
System.Windows.Forms/DateBoldEventArgs.cs
System.Windows.Forms/DateBoldEventHandler.cs
System.Windows.Forms/DateRangeEventArgs.cs
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches