| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886 |
- // 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) 2004-2005 Novell, Inc.
- //
- // Authors:
- // Jonathan Chambers ([email protected])
- //
- // NOT COMPLETE
- using System;
- using System.Drawing;
- using System.Drawing.Design;
- using System.ComponentModel;
- using System.Collections;
- using System.ComponentModel.Design;
- using System.Reflection;
- using System.Windows.Forms.Design;
- using System.Windows.Forms.PropertyGridInternal;
- namespace System.Windows.Forms
- {
- [Designer("System.Windows.Forms.Design.PropertyGridDesigner, " + Consts.AssemblySystem_Design)]
- 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;
- private AttributeCollection browsable_attributes = null;
- private bool can_show_commands = false;
- private Color commands_back_color;
- private Color commands_fore_color;
- private bool commands_visible;
- private bool commands_visible_if_available;
- private Point context_menu_default_location;
- private bool large_buttons;
- private Color line_color;
- private PropertySort property_sort;
- private PropertyTabCollection property_tabs;
- private GridItem selected_grid_item;
- internal GridItemCollection grid_items;
- private object[] selected_objects;
- private PropertyTab selected_tab;
- private ImageList toolbar_imagelist;
- private ToolBarButton categorized_toolbarbutton;
- private ToolBarButton alphabetic_toolbarbutton;
- private ToolBarButton separator_toolbarbutton;
- private ToolBarButton propertypages_toolbarbutton;
- internal ToolBar toolbar;
- internal PropertyGridView property_grid_view;
- internal Splitter splitter;
- internal Panel help_panel;
- internal Label help_title_label;
- internal Label help_description_label;
- private ContextMenu context_menu;
- private MenuItem reset_menuitem;
- private MenuItem description_menuitem;
- #endregion // Private Members
- #region Contructors
- 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.Categorized;
- property_grid_view = new PropertyGridView(this);
- property_grid_view.Dock = DockStyle.Fill;
- splitter = new Splitter();
- splitter.Dock = DockStyle.Bottom;
- help_panel = new Panel();
- help_panel.Dock = DockStyle.Bottom;
- help_panel.Height = 50;
- help_description_label = new Label();
- help_description_label.Dock = DockStyle.Fill;
- help_description_label.Name = "help_description_label";
- help_description_label.Font = this.Font;
- help_title_label = new Label();
- help_title_label.Dock = DockStyle.Top;
- help_title_label.Name = "help_title_label";
- help_description_label.Font = new Font(this.Font,FontStyle.Bold);
- help_panel.Controls.Add(help_description_label);
- help_panel.Controls.Add(help_title_label);
- toolbar = new ToolBar();
- toolbar.Dock = DockStyle.Top;
- categorized_toolbarbutton = new ToolBarButton();
- alphabetic_toolbarbutton = new ToolBarButton();
- separator_toolbarbutton = new ToolBarButton();
- propertypages_toolbarbutton = new ToolBarButton();
- context_menu = new ContextMenu();
- //help_title_label.Dock = DockStyle.Top;
- help_title_label.Name = "help_title_label";
- help_title_label.Location = new Point(2,20);
- help_title_label.Size = new Size(20,20);
- toolbar_imagelist = new ImageList();
- toolbar_imagelist.ColorDepth = ColorDepth.Depth32Bit;
- toolbar_imagelist.ImageSize = new System.Drawing.Size(16, 16);
- toolbar_imagelist.TransparentColor = System.Drawing.Color.Transparent;
- toolbar.Appearance = ToolBarAppearance.Flat;
- toolbar.AutoSize = false;
- toolbar.Buttons.AddRange(new ToolBarButton[] {
- categorized_toolbarbutton,
- alphabetic_toolbarbutton,
- separator_toolbarbutton,
- propertypages_toolbarbutton});
- toolbar.ButtonSize = new System.Drawing.Size(20, 20);
- toolbar.ImageList = toolbar_imagelist;
- toolbar.Location = new System.Drawing.Point(0, 0);
- toolbar.Name = "toolbar";
- toolbar.ShowToolTips = true;
- toolbar.Size = new System.Drawing.Size(256, 27);
- toolbar.TabIndex = 0;
- toolbar.ButtonClick += new ToolBarButtonClickEventHandler(toolbar_ButtonClick);
- categorized_toolbarbutton.Style = ToolBarButtonStyle.ToggleButton;
- categorized_toolbarbutton.ToolTipText = "Categorized";
- categorized_toolbarbutton.Text = "C";
- alphabetic_toolbarbutton.Style = ToolBarButtonStyle.ToggleButton;
- alphabetic_toolbarbutton.ToolTipText = "Alphabetic";
- alphabetic_toolbarbutton.Text = "A";
- alphabetic_toolbarbutton.ImageIndex = 0;
- separator_toolbarbutton.Style = ToolBarButtonStyle.Separator;
- propertypages_toolbarbutton.Enabled = false;
- propertypages_toolbarbutton.Style = ToolBarButtonStyle.ToggleButton;
- propertypages_toolbarbutton.ToolTipText = "Property Pages";
- propertypages_toolbarbutton.Text = "P";
-
- reset_menuitem = context_menu.MenuItems.Add("Reset");
- reset_menuitem.Click +=new EventHandler(OnResetPropertyClick);
- context_menu.MenuItems.Add("-");
- description_menuitem = context_menu.MenuItems.Add("Description");
- description_menuitem.Click += new EventHandler(OnDescriptionClick);
- description_menuitem.Checked = this.HelpVisible;
- this.ContextMenu = context_menu;
- toolbar.ContextMenu = context_menu;
- this.Controls.Add(property_grid_view);
- this.Controls.Add(toolbar);
- this.Controls.Add(splitter);
- this.Controls.Add(help_panel);
- this.Name = "PropertyGrid";
- this.Size = new System.Drawing.Size(256, 400);
- has_focus = false;
- //TextChanged+=new System.EventHandler(RedrawEvent);
- //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);
- UpdateToolBarButtons();
- }
- #endregion // Constructors
- #region Public Instance Properties
- [BrowsableAttribute(false)]
- [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
- [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
- public AttributeCollection BrowsableAttributes {
- get {
- return browsable_attributes;
- }
- set {
- if (browsable_attributes == value) {
- return;
- }
- browsable_attributes = value;
- }
- }
- public override Color BackColor {
- get {
- return base.BackColor;
- }
- set {
- if (base.BackColor == value) {
- return;
- }
- base.BackColor = value;
- }
- }
- [BrowsableAttribute(false)]
- [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
- public virtual bool CanShowCommands {
- get {
- return can_show_commands;
- }
- }
- public Color CommandsBackColor {
- get {
- return commands_back_color;
- }
- set {
- if (commands_back_color == value) {
- return;
- }
- commands_back_color = value;
- }
- }
- public Color CommandsForeColor {
- get {
- return commands_fore_color;
- }
- set {
- if (commands_fore_color == value) {
- return;
- }
- commands_fore_color = value;
- }
- }
- [BrowsableAttribute(false)]
- [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
- public virtual bool CommandsVisible {
- get {
- return commands_visible;
- }
- }
- [DefaultValue(false)]
- public virtual bool CommandsVisibleIfAvailable {
- get {
- return commands_visible_if_available;
- }
- set {
- if (commands_visible_if_available == value) {
- return;
- }
- commands_visible_if_available = value;
- }
- }
- [BrowsableAttribute(false)]
- [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
- [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
- public Point ContextMenuDefaultLocation {
- get {
- return context_menu_default_location;
- }
- }
- public Color HelpBackColor {
- get
- {
- return help_panel.BackColor;
- }
- set
- {
- if (help_panel.BackColor == value) {
- return;
- }
- help_panel.BackColor = value;
- }
- }
- public Color HelpForeColor {
- get {
- return help_panel.ForeColor;
- }
- set {
- if (help_panel.ForeColor == value) {
- return;
- }
- help_panel.ForeColor = value;
- }
- }
- [DefaultValue(true)]
- [Localizable(true)]
- public virtual bool HelpVisible {
- get {
- return help_panel.Visible;
- }
- set {
- if (help_panel.Visible == value) {
- return;
- }
- help_panel.Visible = value;
- }
- }
- public bool LargeButtons {
- get {
- return large_buttons;
- }
- set {
- if (large_buttons == value) {
- return;
- }
- large_buttons = value;
- }
- }
- public Color LineColor {
- get {
- return line_color;
- }
- set {
- if (line_color == value) {
- return;
- }
- line_color = value;
- }
- }
- [DefaultValue(PropertySort.Categorized)]
- public PropertySort PropertySort {
- get {
- return property_sort;
- }
- set {
- if (!Enum.IsDefined (typeof (PropertySort), value)) {
- throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for PropertySort", value));
- }
- if (property_sort == value) {
- return;
- }
- property_sort = value;
-
- ReflectObjects();
- property_grid_view.Redraw();
-
- if (PropertySortChanged != null) {
- PropertySortChanged(this, EventArgs.Empty);
- }
- }
- }
- [BrowsableAttribute(false)]
- [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
- [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
- public PropertyTabCollection PropertyTabs {
- get {
- return property_tabs;
- }
- }
- [BrowsableAttribute(false)]
- [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
- [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
- public GridItem SelectedGridItem {
- get {
- return selected_grid_item;
- }
- set {
- if (selected_grid_item == value) {
- return;
- }
- 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 {
- get {
- return selected_objects[0];
- }
- set {
- selected_objects = new object[] {value};
- ReflectObjects();
- property_grid_view.Redraw();
- }
- }
- [BrowsableAttribute(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public object[] SelectedObjects {
- get {
- return selected_objects;
- }
- set {
- selected_objects = value;
- ReflectObjects();
- }
- }
- [BrowsableAttribute(false)]
- [EditorBrowsable(EditorBrowsableState.Advanced)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public PropertyTab SelectedTab {
- get {
- return selected_tab;
- }
- }
- public override ISite Site {
- get {
- return base.Site;
- }
- set {
- base.Site = value;
- }
- }
- [DefaultValue(true)]
- public virtual bool ToolbarVisible {
- get {
- return toolbar.Visible;
- }
- set {
- if (toolbar.Visible == value) {
- return;
- }
- toolbar.Visible = value;
- }
- }
- public Color ViewBackColor {
- get {
- return property_grid_view.BackColor;
- }
- set {
- if (property_grid_view.BackColor == value) {
- return;
- }
- property_grid_view.BackColor = value;
- }
- }
- public Color ViewForeColor {
- get {
- return property_grid_view.ForeColor;
- }
- set {
- if (property_grid_view.ForeColor == value) {
- return;
- }
- property_grid_view.ForeColor = value;
- }
- }
- #endregion // Public Instance Properties
- #region Protected Instance Properties
- protected override Size DefaultSize {
- get {
- return base.DefaultSize;
- }
- }
- [MonoTODO]
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Advanced)]
- protected virtual Type DefaultTabType {
- get {
- throw new NotImplementedException();
- }
- }
- protected override bool ShowFocusCues {
- get {
- return base.ShowFocusCues;
- }
- }
- #endregion // Protected Instance Properties
- #region Public Instance Methods
- [MonoTODO]
- public void CollapseAllGridItems ()
- {
- throw new NotImplementedException();
- }
- [MonoTODO]
- public void ExpandAllGridItems ()
- {
- throw new NotImplementedException();
- }
- public override void Refresh ()
- {
- base.Refresh ();
- }
- [MonoTODO]
- public void RefreshTabs (PropertyTabScope tabScope)
- {
- throw new NotImplementedException();
- }
- [MonoTODO]
- public void ResetSelectedProperty()
- {
- throw new NotImplementedException();
- }
- #endregion // Public Instance Methods
- #region Protected Instance Methods
- [MonoTODO]
- protected virtual PropertyTab CreatePropertyTab(Type tabType)
- {
- throw new NotImplementedException();
- }
- 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)
- {
- base.OnHandleCreated (e);
- }
- protected override void OnHandleDestroyed (EventArgs e)
- {
- base.OnHandleDestroyed (e);
- }
- protected override void OnMouseDown (MouseEventArgs e)
- {
- base.OnMouseDown (e);
- }
- protected override void OnMouseMove (MouseEventArgs e)
- {
- base.OnMouseMove (e);
- }
- protected override void OnMouseUp (MouseEventArgs e)
- {
- base.OnMouseUp (e);
- }
- protected override void OnPaint (PaintEventArgs pevent)
- {
- base.OnPaint (pevent);
- }
- [MonoTODO]
- protected virtual void OnPropertyTabChanged (PropertyTabChangedEventArgs e)
- {
- throw new NotImplementedException();
- }
- [MonoTODO]
- protected virtual void OnPropertyValueChanged (PropertyValueChangedEventArgs e)
- {
- throw new NotImplementedException();
- }
- protected override void OnResize (EventArgs e)
- {
- base.OnResize (e);
- }
- [MonoTODO]
- protected virtual void OnSelectedGridItemChanged (SelectedGridItemChangedEventArgs e)
- {
- throw new NotImplementedException();
- }
- [MonoTODO]
- protected virtual void OnSelectedObjectsChanged (EventArgs e)
- {
- throw new NotImplementedException();
- }
- protected override void OnSystemColorsChanged (EventArgs e)
- {
- base.OnSystemColorsChanged (e);
- }
- protected override void OnVisibleChanged (EventArgs e)
- {
- base.OnVisibleChanged (e);
- }
- protected override bool ProcessDialogKey (Keys keyData)
- {
- return base.ProcessDialogKey (keyData);
- }
- protected override void ScaleCore (float dx, float dy)
- {
- base.ScaleCore (dx, dy);
- }
- protected override void WndProc (ref Message m)
- {
- base.WndProc (ref m);
- }
- #endregion
- #region Events
- public event EventHandler PropertySortChanged;
- public event PropertyTabChangedEventHandler PropertyTabChanged;
- public event PropertyValueChangedEventHandler PropertyValueChanged;
- public event SelectedGridItemChangedEventHandler SelectedGridItemChanged;
- public event EventHandler SelectedObjectsChanged;
- #endregion
- #region Com2Interop.IComPropertyBrowser Interface
- [MonoTODO]
- bool ComponentModel.Com2Interop.IComPropertyBrowser.InPropertySet {
- get {
- throw new NotImplementedException();
- }
- }
- [MonoTODO]
- void ComponentModel.Com2Interop.IComPropertyBrowser.DropDownDone() {
- throw new NotImplementedException();
- }
- [MonoTODO]
- bool ComponentModel.Com2Interop.IComPropertyBrowser.EnsurePendingChangesCommitted() {
- throw new NotImplementedException();
- }
- [MonoTODO]
- void ComponentModel.Com2Interop.IComPropertyBrowser.HandleF4() {
- throw new NotImplementedException();
- }
- [MonoTODO]
- void ComponentModel.Com2Interop.IComPropertyBrowser.LoadState(Microsoft.Win32.RegistryKey key) {
- throw new NotImplementedException();
- }
- [MonoTODO]
- void ComponentModel.Com2Interop.IComPropertyBrowser.SaveState(Microsoft.Win32.RegistryKey key) {
- throw new NotImplementedException();
- }
- [MonoTODO]
- private event ComponentRenameEventHandler com_component_name_changed;
- event ComponentRenameEventHandler ComponentModel.Com2Interop.IComPropertyBrowser.ComComponentNameChanged {
- add { com_component_name_changed += value; }
- remove { com_component_name_changed -= value; }
- }
- #endregion // Com2Interop.IComPropertyBrowser Interface
- #region PropertyTabCollection Class
- public class PropertyTabCollection : ICollection, IEnumerable
- {
- #region Private Constructors
- private PropertyTabCollection() {
- }
- #endregion // Private Constructors
- [MonoTODO]
- public PropertyTab this[int index] {
- get {
- throw new NotImplementedException();
- }
- }
-
- #region ICollection Members
- [MonoTODO]
- bool ICollection.IsSynchronized
- {
- get {
- // TODO: Add PropertyTabCollection.IsSynchronized getter implementation
- return false;
- }
- }
- [MonoTODO]
- void ICollection.CopyTo(Array array, int index)
- {
- // TODO: Add PropertyTabCollection.CopyTo implementation
- }
- [MonoTODO]
- object ICollection.SyncRoot
- {
- get {
- // TODO: Add PropertyTabCollection.SyncRoot getter implementation
- return null;
- }
- }
- #endregion
- #region IEnumerable Members
- [MonoTODO]
- public IEnumerator GetEnumerator() {
- // TODO: Add PropertyTabCollection.GetEnumerator implementation
- return null;
- }
- #endregion
-
- #region ICollection Members
- [MonoTODO]
- public int Count {
- get {
- // TODO: Add PropertyTabCollection.Count getter implementation
- return 0;
- }
- }
- #endregion
- }
- #endregion // PropertyTabCollection Class
- #region Private Helper Methods
- private void toolbar_ButtonClick (object sender, ToolBarButtonClickEventArgs e)
- {
- 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 ()
- {
- if (PropertySort == PropertySort.Alphabetical) {
- categorized_toolbarbutton.Pushed = false;
- alphabetic_toolbarbutton.Pushed = true;
- }
- else if (PropertySort == PropertySort.Categorized) {
- categorized_toolbarbutton.Pushed = true;
- alphabetic_toolbarbutton.Pushed = false;
- }
- else {
- categorized_toolbarbutton.Pushed = false;
- alphabetic_toolbarbutton.Pushed = false;
- }
- }
- private void OnResetPropertyClick (object sender, EventArgs e)
- {
- ResetSelectedProperty();
- }
- private void OnDescriptionClick (object sender, EventArgs e)
- {
- this.HelpVisible = !this.HelpVisible;
- description_menuitem.Checked = this.HelpVisible;
- }
- private void ReflectObjects ()
- {
- GridItemCollection alphabetical_grid_items = new GridItemCollection();
- GridItemCollection category_grid_items = new GridItemCollection();
- foreach (object obj in selected_objects) {
- if (obj != null) {
- 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, GridItemCollection category_grid_item_coll)
- {
- PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(obj);
- for (int i = 0; i < properties.Count;i++) {
- 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);
- 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
- }
- }
|