Author: ivanz
Date: 2008-01-21 21:03:03 -0500 (Mon, 21 Jan 2008)
New Revision: 93472
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGrid.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs
Log:
2008-01-22 Ivan N. Zlatev <[EMAIL PROTECTED]>
* PropertyGrid.cs, GridEntry.cs, PropertyGridView.cs:
- Renamed GridEntry.SelectedObjects to TargetObjects to better
reflect the property name role.
- PropertyGrid.GetTarget is not required as the target is known
(TargetObjects).
- Setting values will handle value types as a special case now and
populate them up in the chain.
[Fixes #354990]
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2008-01-22 01:25:04 UTC (rev 93471)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2008-01-22 02:03:03 UTC (rev 93472)
@@ -1,3 +1,14 @@
+2008-01-22 Ivan N. Zlatev <[EMAIL PROTECTED]>
+
+ * PropertyGrid.cs, GridEntry.cs, PropertyGridView.cs:
+ - Renamed GridEntry.SelectedObjects to TargetObjects to better
+ reflect the property name role.
+ - PropertyGrid.GetTarget is not required as the target is known
+ (TargetObjects).
+ - Setting values will handle value types as a special case now and
+ populate them up in the chain.
+ [Fixes #354990]
+
2008-01-21 Jonathan Pobst <[EMAIL PROTECTED]>
* Hwnd.cs: Create a public property for the Graphics we keep around.
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs
2008-01-22 01:25:04 UTC (rev 93471)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs
2008-01-22 02:03:03 UTC (rev 93472)
@@ -17,10 +17,11 @@
// 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) 2004-2005 Novell, Inc.
+// Copyright (c) 2004-2008 Novell, Inc.
//
// Authors:
// Jonathan Chambers ([EMAIL PROTECTED])
+// Ivan N. Zlatev ([EMAIL PROTECTED])
//
// NOT COMPLETE
@@ -39,7 +40,7 @@
private GridItemCollection grid_items;
private GridItem parent;
private PropertyDescriptor property_descriptor;
- private object[] selected_objects;
+ private object[] target_objects;
private int top;
private Rectangle plus_minus_bounds;
private Rectangle bounds;
@@ -57,7 +58,7 @@
}
public GridEntry(PropertyGridView view, object[] objs,
PropertyDescriptor prop_desc) : this (view) {
- selected_objects = objs;
+ target_objects = objs;
property_descriptor = prop_desc;
}
#endregion // Constructors
@@ -125,7 +126,7 @@
if (Value == null) /* not sure if this is always
right.. */
return false;
- return
PropertyDescriptor.CanResetValue(selected_objects[0]);
+ return
PropertyDescriptor.CanResetValue(target_objects[0]);
}
public override object Value
@@ -135,12 +136,12 @@
* someplace else, maybe when we're
* initially populating the
* PropertyGrid? */
- if (selected_objects == null ||
selected_objects.Length == 0 || property_descriptor == null)
+ if (target_objects == null ||
target_objects.Length == 0 || property_descriptor == null)
return null;
- object v =
property_descriptor.GetValue(selected_objects[0]);
- for (int i = 1; i < selected_objects.Length; i
++) {
- if (!Object.Equals (v,
property_descriptor.GetValue(selected_objects[i])))
+ object v =
property_descriptor.GetValue(target_objects[0]);
+ for (int i = 1; i < target_objects.Length; i
++) {
+ if (!Object.Equals (v,
property_descriptor.GetValue(target_objects[i])))
return null;
}
@@ -201,12 +202,12 @@
#endregion
- internal object[] SelectedObjects {
+ internal object[] TargetObjects {
get {
- return selected_objects;
+ return target_objects;
}
set {
- selected_objects = value;
+ target_objects = value;
}
}
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGrid.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGrid.cs
2008-01-22 01:25:04 UTC (rev 93471)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGrid.cs
2008-01-22 02:03:03 UTC (rev 93472)
@@ -17,10 +17,11 @@
// 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) 2004-2005 Novell, Inc.
+// Copyright (c) 2004-2008 Novell, Inc.
//
// Authors:
// Jonathan Chambers ([EMAIL PROTECTED])
+// Ivan N. Zlatev ([EMAIL PROTECTED])
//
// NOT COMPLETE
@@ -1436,7 +1437,7 @@
if (grid_entry == null || grid_entry is
CategoryGridEntry) {
grid_entry = new GridEntry
(property_grid_view, objs, property);
} else {
- grid_entry.SelectedObjects = objs;
+ grid_entry.TargetObjects = objs;
}
grid_entry.SetParent (parent_grid_item);
@@ -1481,7 +1482,7 @@
if (grid_entry == null)
return;
- if (grid_entry.SelectedObjects == null)
+ if (grid_entry.TargetObjects == null)
return;
PropertyDescriptor property =
grid_entry.PropertyDescriptor;
@@ -1493,7 +1494,7 @@
!property.Attributes.Contains
(DesignerSerializationVisibilityAttribute.Content))
return;
- object [] objs = grid_entry.SelectedObjects;
+ object [] objs = grid_entry.TargetObjects;
object [] subobjs = new object [objs.Length];
for (int i = 0; i < objs.Length; i++)
@@ -1549,18 +1550,6 @@
e.Graphics.DrawRectangle(SystemPens.ControlDark,
0,0,help_panel.Width-1,help_panel.Height-1 );
}
- internal object GetTarget (GridItem item, int selected_index)
- {
- object target =
((GridEntry)item).SelectedObjects[selected_index];
-
- while (item.Parent != null && item.Parent.GridItemType
!= GridItemType.Property)
- item = item.Parent;
-
- if (item.Parent != null &&
item.Parent.PropertyDescriptor != null)
- target =
item.Parent.PropertyDescriptor.GetValue
(((GridEntry)item.Parent).SelectedObjects[selected_index]);
-
- return target;
- }
#endregion // Private Helper Methods
#region Internal helper classes
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs
2008-01-22 01:25:04 UTC (rev 93471)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs
2008-01-22 02:03:03 UTC (rev 93472)
@@ -19,10 +19,11 @@
// 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)
+// Copyright (c) 2005-2008 Novell, Inc. (http://www.novell.com)
//
// Authors:
// Jonathan Chambers ([EMAIL PROTECTED])
+// Ivan N. Zlatev ([EMAIL PROTECTED])
//
//
@@ -819,34 +820,57 @@
CloseDropDown ();
}
- private void SetPropertyValue(object newVal) {
- if (property_grid.SelectedGridItem == null)
+ private void SetPropertyValue(object newVal)
+ {
+ GridEntry selectedItem = (GridEntry)
property_grid.SelectedGridItem;
+ if (selectedItem == null ||
selectedItem.PropertyDescriptor == null)
return;
- PropertyDescriptor desc =
property_grid.SelectedGridItem.PropertyDescriptor;
- if (desc == null)
- return;
-
+ PropertyDescriptor property =
selectedItem.PropertyDescriptor;
bool changed = false;
- for (int i = 0; i <
((GridEntry)property_grid.SelectedGridItem).SelectedObjects.Length; i ++) {
- object target = property_grid.GetTarget
(property_grid.SelectedGridItem, i);
- object currentVal = desc.GetValue (target);
+ foreach (object targetObject in
selectedItem.TargetObjects) {
+ object currentVal = property.GetValue
(targetObject);
if (!Object.Equals (currentVal, newVal)) {
- desc.SetValue (target, newVal);
+ property.SetValue (targetObject,
newVal);
+ // Value Types are weired when handled
via SetValue (structs specifically).
+ // Populate them up the chaing by hand.
+ //
+ if (IsValueTypeGridItem
(selectedItem.Parent)) {
+ object value = targetObject;
+ GridEntry entry = (GridEntry)
selectedItem.Parent;
+ object[] targets =
entry.TargetObjects;
+ while (IsValueTypeGridItem
(entry)) {
+ foreach (object target
in targets)
+
entry.PropertyDescriptor.SetValue (target, value);
+ value = targets[0];
+
+ if (entry.Parent !=
null)
+ targets =
((GridEntry)entry.Parent).TargetObjects;
+ entry =
(GridEntry)entry.Parent;
+ }
+ }
changed = true;
}
}
if (changed) {
// TODO - What else should
RefreshProperties.All do?
- RefreshPropertiesAttribute refresh_attr =
(RefreshPropertiesAttribute) desc.Attributes [typeof
(RefreshPropertiesAttribute)];
+ RefreshPropertiesAttribute refresh_attr =
(RefreshPropertiesAttribute) property.Attributes [typeof
(RefreshPropertiesAttribute)];
if (refresh_attr != null &&
refresh_attr.RefreshProperties != RefreshProperties.None)
Invalidate ();
-
+
property_grid.PropertyValueChangedInternal ();
}
}
-
+
+ private bool IsValueTypeGridItem (GridItem item)
+ {
+ if (item != null && item.PropertyDescriptor != null &&
+ item.PropertyDescriptor.PropertyType.IsValueType)
+ return true;
+ return false;
+ }
+
private void DropDownButtonClicked (object sender, EventArgs e)
{
UITypeEditor editor =
property_grid.SelectedGridItem.PropertyDescriptor.GetEditor (typeof
(UITypeEditor)) as UITypeEditor;
if (editor == null) {
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches