Author: joncham
Date: 2005-03-22 08:28:24 -0500 (Tue, 22 Mar 2005)
New Revision: 42105
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/GridItem.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridItemCollection.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGrid.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs
Log:
Updated PropertyGrid and related items.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2005-03-22 12:52:07 UTC (rev 42104)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2005-03-22 13:28:24 UTC (rev 42105)
@@ -1,3 +1,14 @@
+2005-03-22 Jonathan Chambers <[EMAIL PROTECTED]>
+
+ * CategoryGridEntry.cs: Added
+ * GridItem.cs: Added helper properties
+ * PropertyGridTextBox.cs: Custom textbox control for PropertyGrid.
+ * GridEntry.cs: Updated code for collection
+ * PropertyGrid.cs: Cleaned up some formatting
+ * PropertyGridView.cs: Added drop down functionality for enums.
+ * GridItemCollection.cs: Added enumerator logic
+ * PropertyGridEntry.cs: Added
+
2005-03-19 Alexander Olk <[EMAIL PROTECTED]>
* FileDialog.cs:
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs
2005-03-22 12:52:07 UTC (rev 42104)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs
2005-03-22 13:28:24 UTC (rev 42105)
@@ -28,22 +28,28 @@
using System;
using System.Windows.Forms;
using System.ComponentModel;
+using System.Drawing;
namespace System.Windows.Forms.PropertyGridInternal
{
- public class GridEntry : GridItem
+ internal class GridEntry : GridItem
{
#region Local Variables
- private bool expanded = false;
+ private bool expanded = true;
private GridItemCollection grid_items;
private GridItem parent;
private PropertyDescriptor property_descriptor;
private object selected_object;
+ private string label;
+ private int top;
+ private Rectangle plus_minus_bounds;
#endregion // Local Variables
#region Contructors
- public GridEntry() : base() {
- grid_items = GridItemCollection.Empty;
+ public GridEntry() : base() {
+ plus_minus_bounds = new Rectangle(0,0,0,0);
+ top = -1;
+ grid_items = new GridItemCollection();
}
public GridEntry(object obj, PropertyDescriptor prop_desc) :
this() {
@@ -56,7 +62,7 @@
public override bool Expandable
{
get {
- return false;
+ return grid_items.Count > 0;
}
}
@@ -109,7 +115,10 @@
public override object Value
{
get {
- return
property_descriptor.GetValue(selected_object);
+ object return_value = null;
+ if (selected_object != null)
+ return_value =
property_descriptor.GetValue(selected_object);
+ return return_value;
}
}
#endregion // Public Instance Properties
@@ -120,5 +129,25 @@
throw new NotImplementedException();
}
#endregion // Public Instance Methods
+
+ internal override int Top {
+ get {
+ return top;
+ }
+ set {
+ top = value;
+ }
+ }
+
+ internal override Rectangle PlusMinusBounds {
+ get{
+ return plus_minus_bounds;
+ }
+ set{
+ plus_minus_bounds = value;
+ }
+ }
+
+
}
}
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridItem.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridItem.cs
2005-03-22 12:52:07 UTC (rev 42104)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridItem.cs
2005-03-22 13:28:24 UTC (rev 42105)
@@ -26,6 +26,7 @@
// NOT COMPLETE
using System;
+using System.Drawing;
namespace System.Windows.Forms
{
@@ -94,5 +95,15 @@
public abstract new bool Select ();
#endregion // Public Instance Methods
+ internal abstract int Top {
+ get;
+ set;
+ }
+
+ internal abstract Rectangle PlusMinusBounds {
+ get;
+ set;
+ }
+
}
}
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridItemCollection.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridItemCollection.cs
2005-03-22 12:52:07 UTC (rev 42104)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridItemCollection.cs
2005-03-22 13:28:24 UTC (rev 42105)
@@ -83,8 +83,34 @@
#region IEnumerable Members
public IEnumerator GetEnumerator()
{
- return list.GetEnumerator();
+ return new GridItemEnumerator(this);
}
#endregion
+
+ #region Enumerator Class
+ public class GridItemEnumerator : IEnumerator{
+ int nIndex;
+ GridItemCollection collection;
+ public GridItemEnumerator(GridItemCollection coll) {
+ collection = coll;
+ nIndex = -1;
+ }
+
+ public bool MoveNext() {
+ nIndex++;
+ return(nIndex < collection.Count);
+ }
+
+ public void Reset() {
+ nIndex = -1;
+ }
+
+ object System.Collections.IEnumerator.Current {
+ get {
+ return(collection[nIndex]);
+ }
+ }
+ }
+ #endregion
}
}
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGrid.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGrid.cs
2005-03-22 12:52:07 UTC (rev 42104)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGrid.cs
2005-03-22 13:28:24 UTC (rev 42105)
@@ -26,10 +26,11 @@
// NOT COMPLETE
using System;
+using System.Drawing;
+using System.Drawing.Design;
+using System.ComponentModel;
using System.Collections;
-using System.ComponentModel;
using System.ComponentModel.Design;
-using System.Drawing;
using System.Reflection;
using System.Windows.Forms.Design;
using System.Windows.Forms.PropertyGridInternal;
@@ -40,8 +41,8 @@
public class PropertyGrid : System.Windows.Forms.ContainerControl,
ComponentModel.Com2Interop.IComPropertyBrowser
{
#region Private Members
-
+
private const int GRID_ITEM_HEIGHT = 16;
private const int GRID_LEFT_COLUMN_WIDTH = 16;
private const int DIVIDER_PADDING = 2;
@@ -82,12 +83,15 @@
#endregion // Private Members
#region Contructors
- public PropertyGrid()
- {
+ public PropertyGrid() {
+ selected_objects = new object[1];
+ grid_items = new GridItemCollection();
+
line_color = SystemColors.ScrollBar;
+ line_color = SystemColors.ScrollBar;
browsable_attributes = new AttributeCollection(new
Attribute[] {});
commands_visible_if_available = false;
- property_sort = PropertySort.CategorizedAlphabetical;
+ property_sort = PropertySort.Categorized;
property_grid_view = new PropertyGridView(this);
property_grid_view.Dock = DockStyle.Fill;
@@ -133,10 +137,10 @@
toolbar.Appearance = ToolBarAppearance.Flat;
toolbar.AutoSize = false;
toolbar.Buttons.AddRange(new ToolBarButton[] {
- categorized_toolbarbutton,
- alphabetic_toolbarbutton,
- separator_toolbarbutton,
- propertypages_toolbarbutton});
+
categorized_toolbarbutton,
+
alphabetic_toolbarbutton,
+
separator_toolbarbutton,
+
propertypages_toolbarbutton});
toolbar.ButtonSize = new System.Drawing.Size(20, 20);
toolbar.ImageList = toolbar_imagelist;
@@ -154,6 +158,7 @@
alphabetic_toolbarbutton.Style =
ToolBarButtonStyle.ToggleButton;
alphabetic_toolbarbutton.ToolTipText = "Alphabetic";
alphabetic_toolbarbutton.Text = "A";
+ alphabetic_toolbarbutton.ImageIndex = 0;
separator_toolbarbutton.Style =
ToolBarButtonStyle.Separator;
@@ -178,10 +183,7 @@
this.Controls.Add(help_panel);
this.Name = "PropertyGrid";
this.Size = new System.Drawing.Size(256, 400);
-
- selected_objects = new object[1];
- grid_items = new GridItemCollection();
-
+
has_focus = false;
//TextChanged+=new System.EventHandler(RedrawEvent);
@@ -195,6 +197,8 @@
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.StandardClick |
ControlStyles.StandardDoubleClick, false);
+
+ UpdateToolBarButtons();
}
#endregion // Constructors
@@ -203,8 +207,7 @@
[BrowsableAttribute(false)]
[EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
- public AttributeCollection BrowsableAttributes
- {
+ public AttributeCollection BrowsableAttributes {
get {
return browsable_attributes;
}
@@ -218,8 +221,7 @@
}
}
- public override Color BackColor
- {
+ public override Color BackColor {
get {
return base.BackColor;
}
@@ -233,17 +235,15 @@
}
- [BrowsableAttribute(false)]
+ [BrowsableAttribute(false)]
[EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
- public virtual bool CanShowCommands
- {
+ public virtual bool CanShowCommands {
get {
return can_show_commands;
}
}
- public Color CommandsBackColor
- {
+ public Color CommandsBackColor {
get {
return commands_back_color;
}
@@ -256,8 +256,7 @@
}
}
- public Color CommandsForeColor
- {
+ public Color CommandsForeColor {
get {
return commands_fore_color;
}
@@ -272,16 +271,14 @@
[BrowsableAttribute(false)]
[EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
- public virtual bool CommandsVisible
- {
+ public virtual bool CommandsVisible {
get {
return commands_visible;
}
}
[DefaultValue(false)]
- public virtual bool CommandsVisibleIfAvailable
- {
+ public virtual bool CommandsVisibleIfAvailable {
get {
return commands_visible_if_available;
}
@@ -294,26 +291,23 @@
}
}
- [BrowsableAttribute(false)]
+ [BrowsableAttribute(false)]
[EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
- public Point ContextMenuDefaultLocation
- {
+ public Point ContextMenuDefaultLocation {
get {
return context_menu_default_location;
}
}
-
- public Color HelpBackColor
- {
+
+ public Color HelpBackColor {
get
{
- return help_panel.BackColor;
- }
-
+ return help_panel.BackColor;
+ }
set
{
- if (help_panel.BackColor == value) {
+ if (help_panel.BackColor == value) {
return;
}
@@ -321,8 +315,7 @@
}
}
- public Color HelpForeColor
- {
+ public Color HelpForeColor {
get {
return help_panel.ForeColor;
}
@@ -335,11 +328,10 @@
help_panel.ForeColor = value;
}
}
-
+
[DefaultValue(true)]
[Localizable(true)]
- public virtual bool HelpVisible
- {
+ public virtual bool HelpVisible {
get {
return help_panel.Visible;
}
@@ -353,8 +345,7 @@
}
}
- public bool LargeButtons
- {
+ public bool LargeButtons {
get {
return large_buttons;
}
@@ -368,8 +359,7 @@
}
}
- public Color LineColor
- {
+ public Color LineColor {
get {
return line_color;
}
@@ -382,10 +372,9 @@
line_color = value;
}
}
-
- [DefaultValue(PropertySort.CategorizedAlphabetical)]
- public PropertySort PropertySort
- {
+
+ [DefaultValue(PropertySort.Categorized)]
+ public PropertySort PropertySort {
get {
return property_sort;
}
@@ -399,25 +388,30 @@
return;
}
- property_sort = value;
+ property_sort = value;
+
+ ReflectObjects();
+ property_grid_view.Redraw();
+
+ if (PropertySortChanged != null) {
+ PropertySortChanged(this,
EventArgs.Empty);
+ }
}
}
- [BrowsableAttribute(false)]
+ [BrowsableAttribute(false)]
[EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
- public PropertyTabCollection PropertyTabs
- {
+ public PropertyTabCollection PropertyTabs {
get {
return property_tabs;
}
}
- [BrowsableAttribute(false)]
+ [BrowsableAttribute(false)]
[EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
- public GridItem SelectedGridItem
- {
+ public GridItem SelectedGridItem {
get {
return selected_grid_item;
}
@@ -427,18 +421,21 @@
return;
}
- selected_grid_item = value;
- this.help_title_label.Text =
selected_grid_item.PropertyDescriptor.Name;
- this.help_description_label.Text =
selected_grid_item.PropertyDescriptor.Description;
+ GridItem oldItem = selected_grid_item;
+ selected_grid_item = value;
+ this.help_title_label.Text =
selected_grid_item.Label;
+ if (selected_grid_item.PropertyDescriptor !=
null)
+ this.help_description_label.Text =
selected_grid_item.PropertyDescriptor.Description;
property_grid_view.Redraw();
-
+ if (SelectedGridItemChanged != null) {
+ SelectedGridItemChanged(this, new
SelectedGridItemChangedEventArgs( oldItem, selected_grid_item));
+ }
}
}
[DefaultValue(null)]
[TypeConverter("System.Windows.Forms.PropertyGrid+SelectedObjectConverter,
System.Windows.Forms, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089")]
- public object SelectedObject
- {
+ public object SelectedObject {
get {
return selected_objects[0];
}
@@ -452,8 +449,7 @@
[BrowsableAttribute(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public object[] SelectedObjects
- {
+ public object[] SelectedObjects {
get {
return selected_objects;
}
@@ -467,15 +463,13 @@
[BrowsableAttribute(false)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public PropertyTab SelectedTab
- {
+ public PropertyTab SelectedTab {
get {
return selected_tab;
}
}
- public override ISite Site
- {
+ public override ISite Site {
get {
return base.Site;
}
@@ -485,10 +479,9 @@
}
}
-
+
[DefaultValue(true)]
- public virtual bool ToolbarVisible
- {
+ public virtual bool ToolbarVisible {
get {
return toolbar.Visible;
}
@@ -502,8 +495,7 @@
}
}
- public Color ViewBackColor
- {
+ public Color ViewBackColor {
get {
return property_grid_view.BackColor;
}
@@ -517,8 +509,7 @@
}
}
- public Color ViewForeColor
- {
+ public Color ViewForeColor {
get {
return property_grid_view.ForeColor;
}
@@ -536,8 +527,7 @@
#region Protected Instance Properties
- protected override Size DefaultSize
- {
+ protected override Size DefaultSize {
get {
return base.DefaultSize;
}
@@ -547,15 +537,13 @@
[MonoTODO]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
- protected virtual Type DefaultTabType
- {
+ protected virtual Type DefaultTabType {
get {
throw new NotImplementedException();
}
}
- protected override bool ShowFocusCues
- {
+ protected override bool ShowFocusCues {
get {
return base.ShowFocusCues;
}
@@ -565,31 +553,31 @@
#region Public Instance Methods
[MonoTODO]
- public void CollapseAllGridItems()
+ public void CollapseAllGridItems ()
{
throw new NotImplementedException();
}
[MonoTODO]
- public void ExpandAllGridItems()
+ public void ExpandAllGridItems ()
{
throw new NotImplementedException();
}
- public override void Refresh()
+ public override void Refresh ()
{
base.Refresh ();
}
[MonoTODO]
- public void RefreshTabs(PropertyTabScope tabScope)
+ public void RefreshTabs (PropertyTabScope tabScope)
{
throw new NotImplementedException();
}
[MonoTODO]
- public void ResetSelectedProperty()
+ public void ResetSelectedProperty()
{
throw new NotImplementedException();
}
@@ -597,102 +585,102 @@
#region Protected Instance Methods
[MonoTODO]
- protected virtual PropertyTab CreatePropertyTab(Type tabType)
+ protected virtual PropertyTab CreatePropertyTab(Type tabType)
{
throw new NotImplementedException();
}
- protected override void OnFontChanged(EventArgs e)
+ protected override void OnFontChanged(EventArgs e)
{
base.OnFontChanged (e);
}
protected override void OnGotFocus(EventArgs e)
{
+ has_focus=true;
base.OnGotFocus(e);
}
- protected override void OnHandleCreated(EventArgs e)
+ protected override void OnHandleCreated (EventArgs e)
{
base.OnHandleCreated (e);
}
- protected override void OnHandleDestroyed(EventArgs e)
+ protected override void OnHandleDestroyed (EventArgs e)
{
base.OnHandleDestroyed (e);
}
-
- protected override void OnMouseDown(MouseEventArgs e)
+ protected override void OnMouseDown (MouseEventArgs e)
{
base.OnMouseDown (e);
}
- protected override void OnMouseMove(MouseEventArgs e)
+ protected override void OnMouseMove (MouseEventArgs e)
{
base.OnMouseMove (e);
}
- protected override void OnMouseUp(MouseEventArgs e)
+ protected override void OnMouseUp (MouseEventArgs e)
{
base.OnMouseUp (e);
}
-
- protected override void OnPaint(PaintEventArgs pevent)
- {
+
+ protected override void OnPaint (PaintEventArgs pevent)
+ {
base.OnPaint (pevent);
}
[MonoTODO]
- protected virtual void
OnPropertyTabChanged(PropertyTabChangedEventArgs e)
+ protected virtual void OnPropertyTabChanged
(PropertyTabChangedEventArgs e)
{
throw new NotImplementedException();
}
[MonoTODO]
- protected virtual void
OnPropertyValueChanged(PropertyValueChangedEventArgs e)
+ protected virtual void OnPropertyValueChanged
(PropertyValueChangedEventArgs e)
{
throw new NotImplementedException();
}
- protected override void OnResize(EventArgs e)
+ protected override void OnResize (EventArgs e)
{
base.OnResize (e);
}
[MonoTODO]
- protected virtual void
OnSelectedGridItemChanged(SelectedGridItemChangedEventArgs e)
+ protected virtual void OnSelectedGridItemChanged
(SelectedGridItemChangedEventArgs e)
{
throw new NotImplementedException();
}
[MonoTODO]
- protected virtual void OnSelectedObjectsChanged(EventArgs e)
+ protected virtual void OnSelectedObjectsChanged (EventArgs e)
{
throw new NotImplementedException();
}
- protected override void OnSystemColorsChanged(EventArgs e)
+ protected override void OnSystemColorsChanged (EventArgs e)
{
base.OnSystemColorsChanged (e);
}
- protected override void OnVisibleChanged(EventArgs e)
+ protected override void OnVisibleChanged (EventArgs e)
{
base.OnVisibleChanged (e);
}
- protected override bool ProcessDialogKey(Keys keyData)
+ protected override bool ProcessDialogKey (Keys keyData)
{
return base.ProcessDialogKey (keyData);
}
- protected override void ScaleCore(float dx, float dy)
+ protected override void ScaleCore (float dx, float dy)
{
base.ScaleCore (dx, dy);
}
- protected override void WndProc(ref Message m)
+ protected override void WndProc (ref Message m)
{
base.WndProc (ref m);
}
@@ -756,19 +744,18 @@
#endregion // Private Constructors
- [MonoTODO]
- public PropertyTab this[int index]
- {
- get {
+ [MonoTODO]
+ public PropertyTab this[int index] {
+ get {
throw new NotImplementedException();
}
}
#region ICollection Members
- [MonoTODO]
+ [MonoTODO]
bool ICollection.IsSynchronized
{
- get {
+ get {
// TODO: Add
PropertyTabCollection.IsSynchronized getter implementation
return false;
}
@@ -780,10 +767,10 @@
// TODO: Add PropertyTabCollection.CopyTo
implementation
}
- [MonoTODO]
+ [MonoTODO]
object ICollection.SyncRoot
{
- get {
+ get {
// TODO: Add
PropertyTabCollection.SyncRoot getter implementation
return null;
}
@@ -793,8 +780,7 @@
#region IEnumerable Members
[MonoTODO]
- public IEnumerator GetEnumerator()
- {
+ public IEnumerator GetEnumerator() {
// TODO: Add
PropertyTabCollection.GetEnumerator implementation
return null;
}
@@ -802,10 +788,9 @@
#endregion
#region ICollection Members
- [MonoTODO]
- public int Count
- {
- get {
+ [MonoTODO]
+ public int Count {
+ get {
// TODO: Add
PropertyTabCollection.Count getter implementation
return 0;
}
@@ -815,67 +800,87 @@
}
#endregion // PropertyTabCollection Class
-
#region Private Helper Methods
-
- private void toolbar_ButtonClick(object sender,
ToolBarButtonClickEventArgs e)
+
+ private void toolbar_ButtonClick (object sender,
ToolBarButtonClickEventArgs e)
{
- if (e.Button == alphabetic_toolbarbutton) {
- this.PropertySort = PropertySort.Alphabetical;
- } else if (e.Button == categorized_toolbarbutton) {
+ if (e.Button == alphabetic_toolbarbutton) {
+ this.PropertySort = PropertySort.Alphabetical;
+ }
+ else if (e.Button == categorized_toolbarbutton) {
this.PropertySort = PropertySort.Categorized;
}
+ UpdateToolBarButtons();
+ ReflectObjects();
+ property_grid_view.Redraw();
}
-
- internal void UpdateToolBarButtons()
+
+ internal void UpdateToolBarButtons ()
{
- if (PropertySort == PropertySort.Alphabetical) {
+ if (PropertySort == PropertySort.Alphabetical) {
categorized_toolbarbutton.Pushed = false;
- alphabetic_toolbarbutton.Pushed = true;
- } else if (PropertySort == PropertySort.Categorized) {
+ alphabetic_toolbarbutton.Pushed = true;
+ }
+ else if (PropertySort == PropertySort.Categorized) {
categorized_toolbarbutton.Pushed = true;
- alphabetic_toolbarbutton.Pushed = false;
- } else {
+ alphabetic_toolbarbutton.Pushed = false;
+ }
+ else {
categorized_toolbarbutton.Pushed = false;
alphabetic_toolbarbutton.Pushed = false;
}
}
- private void OnResetPropertyClick(object sender, EventArgs e)
+ private void OnResetPropertyClick (object sender, EventArgs e)
{
ResetSelectedProperty();
}
- private void OnDescriptionClick(object sender, EventArgs e)
+ private void OnDescriptionClick (object sender, EventArgs e)
{
this.HelpVisible = !this.HelpVisible;
description_menuitem.Checked = this.HelpVisible;
}
-
- private void ReflectObjects()
+
+ private void ReflectObjects ()
{
- grid_items = new GridItemCollection();
+ GridItemCollection alphabetical_grid_items = new
GridItemCollection();
+ GridItemCollection category_grid_items = new
GridItemCollection();
foreach (object obj in selected_objects) {
if (obj != null) {
-
PopulateGridItemCollection(obj,grid_items);
+
PopulateGridItemCollection(obj,alphabetical_grid_items, category_grid_items);
}
}
+ if (PropertySort == PropertySort.Alphabetical) {
+ grid_items = alphabetical_grid_items;
+ }
+ // need to use categories
+ else {
+ grid_items = category_grid_items;
+ }
}
- private void PopulateGridItemCollection(object obj,
GridItemCollection grid_item_coll)
+ private void PopulateGridItemCollection (object obj,
GridItemCollection grid_item_coll, GridItemCollection category_grid_item_coll)
{
- PropertyDescriptorCollection properties =
TypeDescriptor.GetProperties(obj);
+ PropertyDescriptorCollection properties =
TypeDescriptor.GetProperties(obj);
for (int i = 0; i < properties.Count;i++) {
- bool not_browseable =
properties[i].Attributes.Contains(new Attribute[] {new
BrowsableAttribute(false)});
- if (!not_browseable) {
- GridEntry grid_entry = new
GridEntry(obj, properties[i]);
- //object test =
grid_item_coll["Length"];
+ bool not_browseable =
properties[i].Attributes.Contains(new BrowsableAttribute(false));
+ if (!not_browseable) {
+ GridEntry grid_entry = new
GridEntry(obj, properties[i]);
grid_item_coll.Add(properties[i].Name,grid_entry);
-
//PopulateGridItemCollection(grid_entry.Value,grid_entry.GridItems);
+
+ string category =
properties[i].Category;
+ GridItem cat_item =
category_grid_item_coll[category];
+ if (cat_item == null) {
+ cat_item = new
CategoryGridEntry(category);
+
category_grid_item_coll.Add(category,cat_item);
+ }
+
cat_item.GridItems.Add(properties[i].Name,grid_entry);
}
}
- }
+ }
+
#endregion // Private Helper Methods
}
}
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs
2005-03-22 12:52:07 UTC (rev 42104)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs
2005-03-22 13:28:24 UTC (rev 42105)
@@ -1,218 +1,465 @@
-// 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)
-//
-// Authors:
-// Jonathan Chambers ([EMAIL PROTECTED])
-//
-//
-
-// NOT COMPLETE
-
-using System;
-using System.Drawing;
-
-namespace System.Windows.Forms.PropertyGridInternal
-{
- public class PropertyGridView : System.Windows.Forms.ScrollableControl
- {
- internal const int LEFT_COLUMN_WIDTH = 16;
- internal const int ROW_HEIGHT = 16;
- internal const int RESIZE_WIDTH = 3;
- private TextBox grid_textbox;
- internal PropertyGrid property_grid;
- internal bool redraw;
- internal bool resizing_grid;
+// 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)
+//
+// Authors:
+// Jonathan Chambers ([EMAIL PROTECTED])
+//
+//
+
+// NOT COMPLETE
+
+using System;
+using System.Collections;
+using System.Drawing;
+using System.Drawing.Design;
+using System.ComponentModel;
+
+namespace System.Windows.Forms.PropertyGridInternal
+{
+ public class PropertyGridView : System.Windows.Forms.ScrollableControl
+ {
+
+ #region Private Members
+ internal const int V_INDENT = 16;
+ internal const int ROW_HEIGHT = 16;
+ internal const int RESIZE_WIDTH = 3;
+ internal const int BUTTON_WIDTH = 25;
+ private PropertyGridTextBox grid_textbox;
+ internal PropertyGrid property_grid;
+ internal bool redraw;
+ internal bool resizing_grid;
internal int label_column_width;
-
- public PropertyGridView(PropertyGrid property_grid)
+ private bool add_hscroll;
+ private int open_grid_item_count = -1;
+ private VScrollBar vbar;
+ private bool vbar_added;
+ private int skipped_grid_items;
+ private Form dropdown_form;
+ private ListBox listBox;
+ #endregion
+
+ #region Contructors
+ public PropertyGridView (PropertyGrid propertyGrid)
+ {
+ property_grid = propertyGrid;
+ this.BackColor = Color.Beige;
+ grid_textbox = new PropertyGridTextBox();
+ grid_textbox.DropDownButtonClicked +=new
EventHandler(grid_textbox_DropDownButtonClicked);
+
+ dropdown_form = new Form();
+ dropdown_form.FormBorderStyle = FormBorderStyle.None;
+ dropdown_form.Deactivate +=new
EventHandler(dropdown_form_Deactivate);
+
+ listBox = new ListBox();
+ listBox.Dock = DockStyle.Fill;
+ listBox.SelectedIndexChanged +=new
EventHandler(listBox_SelectedIndexChanged);
+ dropdown_form.Controls.Add(listBox);
+
+ grid_textbox.Visible = true;
+ grid_textbox.Font = new Font(this.Font,FontStyle.Bold);
+ grid_textbox.BackColor = this.BackColor;
+ // Not working at all, used to??
+ //grid_textbox.TextBox.Validated += new
EventHandler(TextBoxValidated);
+
+ label_column_width = 65;
+ resizing_grid = false;
+
+ ForeColorChanged+=new EventHandler(RedrawEvent);
+ BackColorChanged+=new System.EventHandler(RedrawEvent);
+ FontChanged+=new EventHandler(RedrawEvent);
+ SizeChanged+=new EventHandler(RedrawEvent);
+
+ SetStyle(ControlStyles.UserPaint, true);
+ SetStyle(ControlStyles.AllPaintingInWmPaint, true);
+ SetStyle(ControlStyles.ResizeRedraw, true);
+ SetStyle(ControlStyles.StandardClick |
ControlStyles.StandardDoubleClick, false);
+ }
+
+ #endregion
+
+ #region Protected Instance Methods
+ protected override void WndProc (ref Message m)
{
- this.property_grid = property_grid;
- this.BackColor = Color.Beige;
- grid_textbox = new TextBox();
+ switch ((Msg) m.Msg) {
+ case Msg.WM_PAINT: {
+ PaintEventArgs paint_event;
- grid_textbox.Visible = false;
- grid_textbox.Font = new Font(this.Font,FontStyle.Bold);
- grid_textbox.BorderStyle = BorderStyle.None;
- grid_textbox.BackColor = this.BackColor;
- grid_textbox.Validated += new
EventHandler(grid_textbox_Validated);
-
- label_column_width = 65;
- resizing_grid = false;
-
- this.Controls.Add(grid_textbox);
-
- ForeColorChanged+=new EventHandler(RedrawEvent);
- BackColorChanged+=new System.EventHandler(RedrawEvent);
- FontChanged+=new EventHandler(RedrawEvent);
- SizeChanged+=new EventHandler(RedrawEvent);
- MouseMove+=new
MouseEventHandler(PropertyGridView_MouseMove);
-
- SetStyle(ControlStyles.UserPaint, true);
- SetStyle(ControlStyles.AllPaintingInWmPaint, true);
- SetStyle(ControlStyles.ResizeRedraw, true);
- SetStyle(ControlStyles.StandardClick |
ControlStyles.StandardDoubleClick, false);
- }
-
- protected override void OnPaint(PaintEventArgs pevent)
+ paint_event = XplatUI.PaintEventStart (Handle);
+ DoPaint (paint_event);
+ XplatUI.PaintEventEnd (Handle);
+ return;
+ }
+ }
+ base.WndProc (ref m);
+ }
+
+ protected override void OnMouseMove (MouseEventArgs e)
+ {
+ if (resizing_grid) {
+ label_column_width = Math.Max(e.X -
V_INDENT,V_INDENT);
+ Redraw();
+ }
+ else if (e.X > label_column_width+V_INDENT -
RESIZE_WIDTH && e.X < label_column_width+V_INDENT + RESIZE_WIDTH) {
+ this.Cursor = Cursors.VSplit;
+ }
+ base.OnMouseMove (e);
+ }
+
+ private GridItem GetSelectedGridItem (GridItemCollection
grid_items, int y)
+ {
+ foreach (GridItem child_grid_item in grid_items) {
+ if (y > child_grid_item.Top && y <
child_grid_item.Top + ROW_HEIGHT) {
+ return child_grid_item;
+ }
+ GridItem foundItem =
GetSelectedGridItem(child_grid_item.GridItems, y);
+ if (foundItem != null)
+ return foundItem;
+ }
+ return null;
+ }
+
+ protected override void OnMouseDown (MouseEventArgs e)
+ {
+ if (e.X > label_column_width+V_INDENT + 2 -
RESIZE_WIDTH && e.X < label_column_width+V_INDENT + 2 + RESIZE_WIDTH) {
+ resizing_grid = true;
+ }
+ else {
+ GridItem foundItem =
GetSelectedGridItem(property_grid.grid_items, e.Y);
+ if (this.property_grid.SelectedGridItem !=
null) {
+ PropertyDescriptor desc =
property_grid.SelectedGridItem.PropertyDescriptor;
+ if (desc != null) {
+
desc.SetValue(property_grid.SelectedObject,
desc.Converter.ConvertFromString(grid_textbox.TextBoxText));
+ }
+ }
+ if (foundItem != null)
+ property_grid.SelectedGridItem =
foundItem;
+ if (property_grid.SelectedGridItem.Expandable) {
+ if
(((CategoryGridEntry)property_grid.SelectedGridItem).PlusMinusBounds.Contains(e.X,e.Y)){
+
property_grid.SelectedGridItem.Expanded =
!property_grid.SelectedGridItem.Expanded;
+ }
+ }
+ Redraw();
+ base.OnMouseDown (e);
+ }
+ }
+
+ protected override void OnMouseUp (MouseEventArgs e)
+ {
+ resizing_grid = false;
+ base.OnMouseUp (e);
+ }
+
+ protected override void OnKeyDown (KeyEventArgs e)
+ {
+ base.OnKeyDown (e);
+ }
+
+ #endregion
+
+ #region Private Helper Methods
+ private void AddVerticalScrollBar (int total_grid_items, bool
count_changed)
{
- this.grid_textbox.Visible = false;
- Draw(pevent);
- pevent.Graphics.DrawImage(this.ImageBuffer,
pevent.ClipRectangle, pevent.ClipRectangle, GraphicsUnit.Pixel);
- if (property_grid.SelectedGridItem != null)
- grid_textbox.Visible = true;
- base.OnPaint (pevent);
- }
+ if (vbar == null) {
+ vbar = new VScrollBar ();
+ count_changed = true;
+ }
- // Derived classes should override Draw method and we dont want
- // to break the control signature, hence this approach.
- internal virtual void Draw (PaintEventArgs e)
- {
- if (redraw)
- {
- Rectangle grid_rect = new
Rectangle(0,0,this.Width-1,this.Height-1);
+ vbar.Bounds = new Rectangle (ClientRectangle.Width -
vbar.Width,
+ 0, vbar.Width, Height);
- Rectangle grid_left_rect = new
Rectangle(grid_rect.Left+1,grid_rect.Top+1,LEFT_COLUMN_WIDTH,ROW_HEIGHT);
- Rectangle grid_label_rect = new
Rectangle(grid_left_rect.Right,grid_rect.Top+1,label_column_width,ROW_HEIGHT);
- Rectangle grid_value_rect = new
Rectangle(grid_label_rect.Right,grid_rect.Top+1,grid_rect.Right-grid_label_rect.Right,ROW_HEIGHT);
+ if (count_changed) {
+ vbar.Maximum = total_grid_items;
+ int height = ClientRectangle.Height;
+ vbar.LargeChange = height / ROW_HEIGHT;
+ }
+ if (!vbar_added) {
+ Controls.Add (vbar);
+ vbar.ValueChanged += new EventHandler
(VScrollBarValueChanged);
+ vbar_added = true;
+ }
- Brush label_brush =
ThemeEngine.Current.ResPool.GetSolidBrush(ThemeEngine.Current.ColorWindowText);
- Brush label_backcolor_brush =
ThemeEngine.Current.ResPool.GetSolidBrush(ThemeEngine.Current.ColorWindow);
- Brush back_color_brush =
ThemeEngine.Current.ResPool.GetSolidBrush(this.BackColor);
- Brush control_brush =
ThemeEngine.Current.ResPool.GetSolidBrush(property_grid.LineColor);
- Pen control_pen =
ThemeEngine.Current.ResPool.GetPen(property_grid.LineColor);
+ vbar.Visible = true;
+ }
+
+ internal void Redraw ()
+ {
+ redraw = true;
+ Refresh ();
+ }
+
+ private GridItem GetGridItemAt (int y)
+ {
+ return null;
+ }
+
+ #region Drawing Code
+ private void DoPaint (PaintEventArgs pevent)
+ {
+ Draw(pevent.ClipRectangle);
+ pevent.Graphics.DrawImage(this.ImageBuffer,
pevent.ClipRectangle, pevent.ClipRectangle, GraphicsUnit.Pixel);
+ }
+
+ [MonoTODO("Do a better job of clipping")]
+ private void Draw (Rectangle clip)
+ {
+ if (redraw) {
+ // Decide if we need a scrollbar
+ bool add_vscroll = false;
+ int old_open_grid_item_count =
open_grid_item_count;
+
+ // Use same brushes for all grid items
+ Brush line_brush =
ThemeEngine.Current.ResPool.GetSolidBrush(property_grid.LineColor);
+ Pen line_pen =
ThemeEngine.Current.ResPool.GetPen(property_grid.LineColor);
+ Brush text_brush =
ThemeEngine.Current.ResPool.GetSolidBrush(ThemeEngine.Current.ColorWindowText);
+
+
+ Rectangle fill = ClientRectangle;
// draw grid outline
-
e.Graphics.FillRectangle(back_color_brush,grid_rect);
-
e.Graphics.DrawRectangle(ThemeEngine.Current.ResPool.GetPen(SystemColors.ControlDark),grid_rect);
-
- // draw items
- GridItemCollection grid_items =
this.property_grid.grid_items;
- for (int i = 0; i < grid_items.Count; i++) {
- GridItem grid_item = grid_items[i];
-
- label_brush =
ThemeEngine.Current.ResPool.GetSolidBrush(ThemeEngine.Current.ColorWindowText);
- label_backcolor_brush =
ThemeEngine.Current.ResPool.GetSolidBrush(ThemeEngine.Current.ColorWindow);
- if (grid_item ==
this.property_grid.SelectedGridItem) {
- label_backcolor_brush =
ThemeEngine.Current.ResPool.GetSolidBrush(ThemeEngine.Current.ColorHilight);
- label_brush =
ThemeEngine.Current.ResPool.GetSolidBrush(ThemeEngine.Current.ColorHilightText);
- grid_textbox.Size = new
Size(grid_value_rect.Size.Width-6,grid_value_rect.Size.Height);
- grid_textbox.Location = new
Point(grid_value_rect.Location.X+4,grid_value_rect.Location.Y+1);
-
- // PDB - added check to prevent
crash with test app
- if (grid_item.Value != null) {
- grid_textbox.Text =
grid_item.Value.ToString();
- } else {
- grid_textbox.Text =
string.Empty;
- }
- }
-
-
e.Graphics.FillRectangle(control_brush,grid_left_rect);
-
-
e.Graphics.FillRectangle(label_backcolor_brush,grid_label_rect);
-
e.Graphics.DrawRectangle(control_pen,grid_label_rect);
-
e.Graphics.DrawString(grid_item.Label,this.Font,label_brush,grid_label_rect.Left
+ 5,grid_label_rect.Top+1);
-
-
e.Graphics.FillRectangle(back_color_brush,grid_value_rect);
-
e.Graphics.DrawRectangle(control_pen,grid_value_rect);
- // PDB - added check to prevent crash
with test app
- if (grid_item.Value != null) {
-
e.Graphics.DrawString(grid_item.Value.ToString(),new
Font(this.Font,FontStyle.Bold),ThemeEngine.Current.ResPool.GetSolidBrush(ThemeEngine.Current.ColorWindowText),grid_value_rect.Left
+ 2,grid_value_rect.Top+1);
- }
-
-
- // shift down for next item
- grid_left_rect.Y = grid_label_rect.Y =
grid_value_rect.Y = grid_left_rect.Y + ROW_HEIGHT;
+ DeviceContext.FillRectangle (new SolidBrush
(BackColor), fill);
+
DeviceContext.DrawRectangle(ThemeEngine.Current.ResPool.GetPen(SystemColors.ControlDark),fill);
+
+ int depth = 0;
+ int item_height = ROW_HEIGHT;
+ Font font = Font;
+ int height = ClientRectangle.Height;
+
+ GridItemCollection grid_items =
this.property_grid.grid_items;
+
+ open_grid_item_count = 0;
+ foreach (GridItem grid_item in grid_items) {
+ DrawGridItem (grid_item, clip, ref
depth, item_height, font, height, line_brush, text_brush, line_pen);
+ depth = 0;
}
- redraw = false;
- }
- }
+ add_vscroll = (open_grid_item_count *
ROW_HEIGHT) > ClientRectangle.Height;
+
+ if (add_vscroll) {
+ AddVerticalScrollBar
(open_grid_item_count, old_open_grid_item_count != open_grid_item_count);
+ } else if (vbar != null) {
+ vbar.Visible = false;
+ skipped_grid_items = 0;
+ }
+
+ if (property_grid.SelectedGridItem != null &&
property_grid.SelectedGridItem.GridItemType == GridItemType.Property) {
+ //if (grid_textbox.Visible == false) {
+ this.Controls.Add(grid_textbox);
+ //}
+ //grid_textbox.Visible = true;
+ if (!grid_textbox.Focused)
+ grid_textbox.Focus();
+ }
+ else {
+ this.Controls.Remove(grid_textbox);
+ //grid_textbox.Visible = false;
+ }
+
+ redraw = false;
+ }
+ }
+
+ private void DrawGridItem (GridItem grid_item, Rectangle clip,
ref int depth, int item_height,
+ Font font, int max_height, Brush line_brush, Brush
text_brush, Pen line_pen)
+ {
+
+ int y =
ClientRectangle.Top+1+(ROW_HEIGHT*(open_grid_item_count-skipped_grid_items));
+ grid_item.Top = y;
+
+ Rectangle indentRectangle = new
Rectangle(ClientRectangle.Left+1,y,V_INDENT,ROW_HEIGHT);
+ Rectangle labelRectangle = new
Rectangle(indentRectangle.Right,y,label_column_width,ROW_HEIGHT);
+ Rectangle valueRectangle = new
Rectangle(labelRectangle.Right,y,ClientRectangle.Right-labelRectangle.Right,ROW_HEIGHT);
+
+ DrawGridItemIndent(grid_item, line_brush,
indentRectangle, grid_item.Expandable, grid_item.Expanded);
+ DrawGridItemLabel(grid_item, labelRectangle, line_pen,
text_brush, Font, depth, line_brush);
+ DrawGridItemValue(grid_item, valueRectangle, line_pen,
text_brush, new Font(Font, FontStyle.Bold), line_brush);
+
+ if (grid_item == property_grid.SelectedGridItem) {
+ if (grid_item.Value != null) {
+ grid_textbox.TextBoxText =
grid_item.Value.ToString();
+ }
+ else {
+ grid_textbox.TextBoxText = string.Empty;
+ }
+ grid_textbox.Size = new
Size(valueRectangle.Size.Width- (vbar == null || !vbar.Visible ? 0 :
ThemeEngine.Current.VerticalScrollBarWidth),valueRectangle.Size.Height);
+ grid_textbox.Location = new
Point(valueRectangle.Location.X+4,valueRectangle.Location.Y+1);
+ }
- private void grid_textbox_Validated(object sender, EventArgs e)
- {
- if (this.property_grid.SelectedGridItem != null)
-
this.property_grid.SelectedGridItem.PropertyDescriptor.SetValue(this.property_grid.SelectedObject,this.property_grid.SelectedGridItem.PropertyDescriptor.Converter.ConvertTo(((TextBox)sender).Text,this.property_grid.SelectedGridItem.PropertyDescriptor.PropertyType));
- }
+ open_grid_item_count++;
+
+
+ depth++;
+ if (grid_item.Expanded) {
+ foreach (GridItem child_item in
grid_item.GridItems) {
+ int tdepth = depth;
+ DrawGridItem(child_item, clip, ref
tdepth, item_height, font, max_height, line_brush, text_brush, line_pen);
+ }
+ }
+ }
+
+ private void DrawGridItemIndent (GridItem grid_item, Brush
brush, Rectangle rect, bool showPlusMinus, bool expanded)
+ {
+
+ DeviceContext.FillRectangle(brush,rect);
+
+ if (showPlusMinus) {
+ Rectangle plus_minus_rect = new
Rectangle(rect.X+3,rect.Y+3,8,8);
+ grid_item.PlusMinusBounds = plus_minus_rect;
+
+ DeviceContext.DrawRectangle
(SystemPens.ControlDark, plus_minus_rect);
- protected override void OnMouseMove(MouseEventArgs e)
- {
- if (resizing_grid) {
- label_column_width = Math.Max(e.X -
LEFT_COLUMN_WIDTH,LEFT_COLUMN_WIDTH);
- Redraw();
- } else if (e.X > label_column_width+LEFT_COLUMN_WIDTH -
RESIZE_WIDTH && e.X < label_column_width+LEFT_COLUMN_WIDTH + RESIZE_WIDTH) {
- this.Cursor = Cursors.VSplit;
- }
- base.OnMouseMove (e);
- }
+ int middle =
(plus_minus_rect.Bottom-plus_minus_rect.Top)/2 + plus_minus_rect.Top;
+ int x = plus_minus_rect.X;
+ DeviceContext.DrawLine
(SystemPens.ControlDarkDark, x + 2, middle, x + 6, middle);
+ if (!expanded) {
+ DeviceContext.DrawLine
(SystemPens.ControlDarkDark, x + 4, middle - 2, x + 4, middle + 2);
+ }
+ }
+ }
+
+ private void DrawGridItemLabel (GridItem grid_item, Rectangle
rect, Pen pen, Brush brush, Font font, int depth, Brush line_brush)
+ {
+ Brush backBrush =
ThemeEngine.Current.ResPool.GetSolidBrush(BackColor);
+ Brush foreBrush = brush;
+ bool selectedItem = false, expandable = false;
+ if (grid_item == property_grid.SelectedGridItem){
+ backBrush =
ThemeEngine.Current.ResPool.GetSolidBrush(ThemeEngine.Current.ColorHilight);
+ foreBrush =
ThemeEngine.Current.ResPool.GetSolidBrush(ThemeEngine.Current.ColorHilightText);
+ }
+ if (grid_item.Expandable){
+ backBrush = line_brush;
+ foreBrush = brush;
+ }
+
+ DeviceContext.FillRectangle(backBrush,rect);
+ DeviceContext.DrawRectangle(pen,rect);
+
DeviceContext.DrawString(grid_item.Label,font,foreBrush,rect.Left + 5 +
depth*V_INDENT,rect.Top+1);
+ }
+
+ [MonoTODO("GetEditor once the TypeDescriptor class is
complete")]
+ private void DrawGridItemValue (GridItem grid_item, Rectangle
rect, Pen pen, Brush brush, Font font, Brush line_brush)
+ {
+ DeviceContext.FillRectangle((grid_item.GridItemType ==
GridItemType.Property) ? ThemeEngine.Current.ResPool.GetSolidBrush(BackColor) :
line_brush,rect);
+ DeviceContext.DrawRectangle(pen,rect);
- protected override void OnMouseDown(MouseEventArgs e)
+ // PDB - added check to prevent crash with test app
+ if (grid_item.Value != null) {
+
DeviceContext.DrawString(grid_item.Value.ToString(),font,brush,rect.Left +
2,rect.Top+1);
+ }
+
+ if (grid_item == property_grid.SelectedGridItem) {
+ grid_textbox.ReadOnly = false;
+ if (grid_item.PropertyDescriptor != null) {
+ UITypeEditor editor =
null;//(UITypeEditor)grid_item.PropertyDescriptor.GetEditor(typeof(UITypeEditor));
+ if (editor != null) {
+ UITypeEditorEditStyle style =
editor.GetEditStyle();
+ if (style ==
UITypeEditorEditStyle.DropDown) {
+
grid_textbox.DropDownButtonVisible = true;
+
grid_textbox.DialogButtonVisible = false;
+
+ }
+ else if (style ==
UITypeEditorEditStyle.Modal) {
+
grid_textbox.DropDownButtonVisible = false;
+
grid_textbox.DialogButtonVisible = true;
+ }
+
+ }
+ else if
(grid_item.PropertyDescriptor.Converter.GetStandardValuesSupported()) {
+ listBox.Items.Clear();
+ foreach (object obj in
grid_item.PropertyDescriptor.Converter.GetStandardValues())
+ listBox.Items.Add(obj);
+
grid_textbox.DropDownButtonVisible = true;
+
grid_textbox.DialogButtonVisible = false;
+ grid_textbox.ReadOnly = true;
+ }
+ else {
+
grid_textbox.DropDownButtonVisible = false;
+
grid_textbox.DialogButtonVisible = false;
+ }
+ }
+ else {
+ grid_textbox.DropDownButtonVisible =
false;
+ grid_textbox.DialogButtonVisible =
false;
+ }
+ }
+ }
+
+ #endregion
+
+ #region Event Handling
+ private void RedrawEvent (object sender, System.EventArgs e)
+ {
+ Redraw();
+ }
+
+ private void VScrollBarValueChanged (object sender, EventArgs
e)
{
- if (e.X > label_column_width+LEFT_COLUMN_WIDTH + 2 -
RESIZE_WIDTH && e.X < label_column_width+LEFT_COLUMN_WIDTH + 2 + RESIZE_WIDTH) {
- resizing_grid = true;
- } else {
- int index = e.Y / ROW_HEIGHT;
- if (index < property_grid.grid_items.Count)
- this.property_grid.SelectedGridItem =
this.property_grid.grid_items[index];
- base.OnMouseDown (e);
- }
- }
+ int old_skip = skipped_grid_items;
+ skipped_grid_items = vbar.Value;
- protected override void OnMouseUp(MouseEventArgs e)
- {
- resizing_grid = false;
- base.OnMouseUp (e);
- }
-
-
- protected override void OnKeyDown(KeyEventArgs e)
- {
- if (this.property_grid.SelectedGridItem != null) {
- grid_textbox.Focus();
- }
- base.OnKeyDown (e);
- }
-
-
- internal void Redraw()
- {
+ int y_move = (old_skip - skipped_grid_items) *
ROW_HEIGHT;
+ // need this to refresh drawing
redraw = true;
- Refresh ();
+ XplatUI.ScrollWindow (Handle, ClientRectangle, 0,
y_move, true);
}
+
+ private void TextBoxValidated (object sender, EventArgs e)
+ {
+ if (this.property_grid.SelectedGridItem != null) {
+ PropertyDescriptor desc =
property_grid.SelectedGridItem.PropertyDescriptor;
+ if (desc != null) {
+
desc.SetValue(property_grid.SelectedObject,
desc.Converter.ConvertFromString(grid_textbox.TextBoxText));
+ }
+ }
+ }
- private void RedrawEvent(object sender, System.EventArgs e)
- {
- Redraw();
- }
-
- private void PropertyGridView_MouseMove(object sender,
MouseEventArgs e)
- {
-
- if (e.X > label_column_width+LEFT_COLUMN_WIDTH -
RESIZE_WIDTH && e.X < label_column_width+LEFT_COLUMN_WIDTH + RESIZE_WIDTH
- || resizing_grid) {
- this.Cursor = Cursors.VSplit;
- } else {
- this.Cursor = Cursors.Default;
- }
- }
- }
+ #endregion
+
+
+ #endregion
+
+ private void dropdown_form_Deactivate (object sender, EventArgs
e)
+ {
+ dropdown_form.Hide();
+ }
+
+
+ private void listBox_SelectedIndexChanged (object sender,
EventArgs e)
+ {
+ if (this.property_grid.SelectedGridItem != null) {
+ PropertyDescriptor desc =
property_grid.SelectedGridItem.PropertyDescriptor;
+ if (desc != null) {
+
desc.SetValue(property_grid.SelectedObject, listBox.SelectedItem);
+ }
+ }
+ dropdown_form.Hide();
+ Redraw();
+ }
+
+ private void grid_textbox_DropDownButtonClicked (object sender,
EventArgs e)
+ {
+ dropdown_form.Location = PointToScreen(new
Point(grid_textbox.Location.X,grid_textbox.Location.Y+ROW_HEIGHT));
+ dropdown_form.Width = grid_textbox.Width;
+ dropdown_form.Show();
+ }
+ }
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches