Advertisement
Nickun

DevExpress.XtraVerticalGrid.PropertyGridControl

Jul 20th, 2011
2,167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 41.81 KB | None | 0 0
  1. // Type: DevExpress.XtraVerticalGrid.PropertyGridControl
  2. // Assembly: DevExpress.XtraVerticalGrid.v10.2, Version=10.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
  3. // Assembly location: D:\Working\Projects\AutoCalc\3rdParty\DevExpress\DevExpress.XtraVerticalGrid.v10.2.dll
  4.  
  5. using DevExpress.Utils;
  6. using DevExpress.Utils.About;
  7. using DevExpress.Utils.Controls;
  8. using DevExpress.Utils.Design;
  9. using DevExpress.Utils.Menu;
  10. using DevExpress.Utils.Serializing;
  11. using DevExpress.XtraEditors;
  12. using DevExpress.XtraEditors.Container;
  13. using DevExpress.XtraEditors.Controls;
  14. using DevExpress.XtraEditors.Repository;
  15. using DevExpress.XtraEditors.ViewInfo;
  16. using DevExpress.XtraVerticalGrid.Data;
  17. using DevExpress.XtraVerticalGrid.Editors;
  18. using DevExpress.XtraVerticalGrid.Events;
  19. using DevExpress.XtraVerticalGrid.Rows;
  20. using DevExpress.XtraVerticalGrid.ViewInfo;
  21. using System;
  22. using System.Collections;
  23. using System.Collections.Generic;
  24. using System.ComponentModel;
  25. using System.ComponentModel.Design;
  26. using System.Drawing;
  27. using System.Drawing.Design;
  28. using System.Reflection;
  29. using System.Windows.Forms;
  30. using System.Windows.Forms.Design;
  31.  
  32. namespace DevExpress.XtraVerticalGrid
  33. {
  34.   [Designer("DevExpress.XtraVerticalGrid.Design.PropertyGridDesigner, DevExpress.XtraVerticalGrid.v10.2.Design", typeof (IDesigner))]
  35.   [LicenseProvider(typeof (DXVerticalGridLicenseProvider))]
  36.   [Description("Displays properties of any object and allows them to be edited.")]
  37.   [DefaultProperty("Rows")]
  38.   [ToolboxItem(true)]
  39.   [ToolboxTabName("DX.10.2: Data")]
  40.   public class PropertyGridControl : VGridControlBase, IServiceProvider, IDXManagerPopupMenu, IPropertyDescriptorService
  41.   {
  42.     private Hashtable defaultEditorMarkers = new Hashtable();
  43.     private Hashtable objects = new Hashtable();
  44.     public const string FieldNameDelimiter = ".";
  45.     private PGridDefaultEditors defaultEditors;
  46.     private AttributeCollection browsableAttributes;
  47.     private object[] dataSource;
  48.     private bool fAutoGenerateRows;
  49.     private RepositoryItemComboBox fComboEditor;
  50.     private RepositoryItemButtonEdit fButtonEditor;
  51.     private RepositoryItemPopupContainerEdit fPopupEditor;
  52.     private RepositoryItemTextEdit fTextEditor;
  53.     private PGridDataManager dataManager;
  54.     private RowPositionKeeper oldFocusedPosition;
  55.     private readonly WindowsFormsEditorService windowsFormsEditorService;
  56.     private readonly Dictionary<string, UITypeEditor> customUITypeEditors;
  57.     private int rowLoadingUnlockCount;
  58.     private IServiceProvider serviceProvider;
  59.  
  60.     protected internal PGridDataModeHelper DataModeHelper
  61.     {
  62.       get
  63.       {
  64.         return (PGridDataModeHelper) this.DataManager.DataModeHelper;
  65.       }
  66.     }
  67.  
  68.     protected internal PGridEditorContainerHelper EditorHelper
  69.     {
  70.       get
  71.       {
  72.         return (PGridEditorContainerHelper) base.EditorHelper;
  73.       }
  74.     }
  75.  
  76.     public override object EditingValue
  77.     {
  78.       get
  79.       {
  80.         if (this.ActiveEditor == null)
  81.           return (object) null;
  82.         else
  83.           return this.EditorHelper.ConvertFromValue(this.ActiveEditor.EditValue);
  84.       }
  85.       set
  86.       {
  87.         if (this.ActiveEditor == null)
  88.           return;
  89.         this.ActiveEditor.EditValue = this.EditorHelper.ConvertToValue(value);
  90.       }
  91.     }
  92.  
  93.     [DefaultValue(null)]
  94.     [Category("Data")]
  95.     [TypeConverter(typeof (PropertyGridControl.SelectedObjectConverter))]
  96.     [Description("Gets or sets the object whose settings are edited by the PropertyGridControl.")]
  97.     public object SelectedObject
  98.     {
  99.       get
  100.       {
  101.         if (this.dataSource != null && this.dataSource.Length != 0)
  102.           return this.dataSource[0];
  103.         else
  104.           return (object) null;
  105.       }
  106.       set
  107.       {
  108.         if (value == null)
  109.           this.SelectedObjects = new object[0];
  110.         else
  111.           this.SelectedObjects = new object[1]
  112.           {
  113.             value
  114.           };
  115.       }
  116.     }
  117.  
  118.     [Browsable(false)]
  119.     [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  120.     public object[] SelectedObjects
  121.     {
  122.       get
  123.       {
  124.         if (this.dataSource == null)
  125.           return new object[0];
  126.         else
  127.           return (object[]) this.dataSource.Clone();
  128.       }
  129.       set
  130.       {
  131.         if (this.AreEqual(this.dataSource, value))
  132.           return;
  133.         this.TrySaveFocusedRow();
  134.         this.dataSource = value == null ? (object[]) null : (object[]) value.Clone();
  135.         if (!this.IsLoading && !this.GridDisposing)
  136.         {
  137.           this.CloseEditor();
  138.           if (this.Site != null && this.Site.DesignMode && this.Rows.Count > 0)
  139.           {
  140.             IUIService uiService = (IUIService) this.Site.GetService(typeof (IUIService));
  141.             if (uiService == null || uiService.ShowMessage(value == null ? "Do you want to clear the row collection?" : "Do you want to repopulate the row collection?\nWarning: the existing rows will be destroyed.", "Row Designer", MessageBoxButtons.YesNo) == DialogResult.Yes)
  142.             {
  143.               using (new UndoEngineHelper((IComponent) this))
  144.               {
  145.                 this.BeginUpdate();
  146.                 try
  147.                 {
  148.                   this.Rows.DestroyRows();
  149.                 }
  150.                 finally
  151.                 {
  152.                   this.CancelUpdate();
  153.                 }
  154.               }
  155.             }
  156.           }
  157.           else if (this.AutoGenerateRows)
  158.           {
  159.             this.BeginUpdate();
  160.             this.Rows.DestroyRows();
  161.             this.CancelUpdate();
  162.           }
  163.         }
  164.         this.ActivateDataSource();
  165.       }
  166.     }
  167.  
  168.     [DefaultValue(false)]
  169.     [Description("Gets or sets whether rows are automatically created in the control for all fields in the bound object.")]
  170.     [Category("Data")]
  171.     public bool AutoGenerateRows
  172.     {
  173.       get
  174.       {
  175.         return this.fAutoGenerateRows;
  176.       }
  177.       set
  178.       {
  179.         if (value == this.fAutoGenerateRows)
  180.           return;
  181.         this.fAutoGenerateRows = value;
  182.       }
  183.     }
  184.  
  185.     [Description("Contains options that affect the display of context menus in a PropertyGridControl.")]
  186.     [Category("Options")]
  187.     [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  188.     [XtraSerializableProperty(XtraSerializationVisibility.Content, XtraSerializationFlags.DefaultValue)]
  189.     public PGridOptionsMenu OptionsMenu
  190.     {
  191.       get
  192.       {
  193.         return (PGridOptionsMenu) base.OptionsMenu;
  194.       }
  195.     }
  196.  
  197.     [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  198.     [Category("Options")]
  199.     [Description("Provides access to the grid's behavior options.")]
  200.     [XtraSerializableProperty(XtraSerializationVisibility.Content, XtraSerializationFlags.DefaultValue)]
  201.     public PGridOptionsBehavior OptionsBehavior
  202.     {
  203.       get
  204.       {
  205.         return (PGridOptionsBehavior) base.OptionsBehavior;
  206.       }
  207.     }
  208.  
  209.     [Category("Options")]
  210.     [Description("Provides access to the vertical grid's display options. ")]
  211.     [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  212.     [XtraSerializableProperty(XtraSerializationVisibility.Content, XtraSerializationFlags.DefaultValue)]
  213.     public PGridOptionsView OptionsView
  214.     {
  215.       get
  216.       {
  217.         return (PGridOptionsView) base.OptionsView;
  218.       }
  219.     }
  220.  
  221.     [Browsable(false)]
  222.     [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  223.     public IServiceProvider ServiceProvider
  224.     {
  225.       get
  226.       {
  227.         return this.serviceProvider;
  228.       }
  229.       set
  230.       {
  231.         if (value == this.serviceProvider)
  232.           return;
  233.         if (this.serviceProvider != null)
  234.         {
  235.           this.UnsubscribeComponentEvents(this.serviceProvider);
  236.           this.serviceProvider = (IServiceProvider) null;
  237.         }
  238.         if (value != null)
  239.           this.SubscribeComponentEvents(value);
  240.         this.serviceProvider = value;
  241.       }
  242.     }
  243.  
  244.     internal WindowsFormsEditorService WindowsFormsEditorService
  245.     {
  246.       get
  247.       {
  248.         return this.windowsFormsEditorService;
  249.       }
  250.     }
  251.  
  252.     protected internal virtual bool IsUnlockedRowLoading
  253.     {
  254.       get
  255.       {
  256.         return this.rowLoadingUnlockCount != 0;
  257.       }
  258.     }
  259.  
  260.     protected internal override VGridDataManager DataManager
  261.     {
  262.       get
  263.       {
  264.         return (VGridDataManager) this.dataManager;
  265.       }
  266.     }
  267.  
  268.     internal RepositoryItemButtonEdit ButtonEditor
  269.     {
  270.       get
  271.       {
  272.         if (this.fButtonEditor == null)
  273.           this.fButtonEditor = (RepositoryItemButtonEdit) new PGRepositoryItemButtonEdit();
  274.         return this.fButtonEditor;
  275.       }
  276.     }
  277.  
  278.     internal RepositoryItemComboBox ComboEditor
  279.     {
  280.       get
  281.       {
  282.         if (this.fComboEditor == null)
  283.         {
  284.           this.fComboEditor = (RepositoryItemComboBox) new PGRepositoryItemComboBox();
  285.           this.fComboEditor.ShowDropDown = ShowDropDown.Never;
  286.           this.fComboEditor.CycleOnDblClick = true;
  287.         }
  288.         return this.fComboEditor;
  289.       }
  290.     }
  291.  
  292.     internal RepositoryItemPopupContainerEdit PopupEditor
  293.     {
  294.       get
  295.       {
  296.         if (this.fPopupEditor == null)
  297.           this.fPopupEditor = (RepositoryItemPopupContainerEdit) new PGRepositoryItemPopupContainerEdit();
  298.         return this.fPopupEditor;
  299.       }
  300.     }
  301.  
  302.     internal RepositoryItemTextEdit TextEditor
  303.     {
  304.       get
  305.       {
  306.         if (this.fTextEditor == null)
  307.           this.fTextEditor = (RepositoryItemTextEdit) new PGRepositoryItemTextEdit();
  308.         return this.fTextEditor;
  309.       }
  310.     }
  311.  
  312.     [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  313.     [Category("Data")]
  314.     [Browsable(false)]
  315.     public PGridDefaultEditors DefaultEditors
  316.     {
  317.       get
  318.       {
  319.         return this.defaultEditors;
  320.       }
  321.     }
  322.  
  323.     [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  324.     [Browsable(false)]
  325.     public AttributeCollection BrowsableAttributes
  326.     {
  327.       get
  328.       {
  329.         if (this.browsableAttributes == null)
  330.           this.browsableAttributes = new AttributeCollection(new Attribute[1]
  331.           {
  332.             (Attribute) BrowsableAttribute.Yes
  333.           });
  334.         return this.browsableAttributes;
  335.       }
  336.       set
  337.       {
  338.         this.browsableAttributes = value;
  339.         if (this.AutoGenerateRows)
  340.           this.Rows.DestroyRows();
  341.         this.ActivateDataSource();
  342.       }
  343.     }
  344.  
  345.     protected internal Dictionary<string, UITypeEditor> CustomUITypeEditors
  346.     {
  347.       get
  348.       {
  349.         return this.customUITypeEditors;
  350.       }
  351.     }
  352.  
  353.     [Obsolete("Use 'PopupMenuShowing' instead", false)]
  354.     [Description("Allows context menus for rows to be customized.")]
  355.     [Category("Behavior")]
  356.     [Browsable(false)]
  357.     [EditorBrowsable(EditorBrowsableState.Never)]
  358.     public event PropertyGridMenuEventHandler ShowMenu
  359.     {
  360.       add
  361.       {
  362.         this.Events.AddHandler(VGridControlBase.GS.showMenu, (Delegate) value);
  363.       }
  364.       remove
  365.       {
  366.         this.Events.RemoveHandler(VGridControlBase.GS.showMenu, (Delegate) value);
  367.       }
  368.     }
  369.  
  370.     [Category("Data")]
  371.     [Description("Allows you to filter properties or display custom properties.")]
  372.     public event CustomPropertyDescriptorsEventHandler CustomPropertyDescriptors
  373.     {
  374.       add
  375.       {
  376.         this.Events.AddHandler(VGridControlBase.GS.customPropertyDescriptors, (Delegate) value);
  377.       }
  378.       remove
  379.       {
  380.         this.Events.RemoveHandler(VGridControlBase.GS.customPropertyDescriptors, (Delegate) value);
  381.       }
  382.     }
  383.  
  384.     public PropertyGridControl()
  385.     {
  386.       this.dataManager = new PGridDataManager(this);
  387.       this.defaultEditors = new PGridDefaultEditors(this);
  388.       this.LayoutStyle = LayoutViewStyle.SingleRecordView;
  389.       this.windowsFormsEditorService = new WindowsFormsEditorService(this);
  390.       this.customUITypeEditors = new Dictionary<string, UITypeEditor>();
  391.     }
  392.  
  393.     protected override VGridOptionsView CreateOptionsView()
  394.     {
  395.       return (VGridOptionsView) new PGridOptionsView();
  396.     }
  397.  
  398.     protected override VGridOptionsBehavior CreateOptionsBehavior()
  399.     {
  400.       return (VGridOptionsBehavior) new PGridOptionsBehavior();
  401.     }
  402.  
  403.     protected override VGridRows CreateRows()
  404.     {
  405.       return (VGridRows) new PGridVirtualRows(this);
  406.     }
  407.  
  408.     protected override VGridMenuBase CreateMenu()
  409.     {
  410.       return (VGridMenuBase) new PGridMenu(this);
  411.     }
  412.  
  413.     protected override void Dispose(bool disposing)
  414.     {
  415.       if (disposing)
  416.       {
  417.         this.fGridDisposing = true;
  418.         this.DisposeAutoEditors();
  419.         this.ServiceProvider = (IServiceProvider) null;
  420.         this.SelectedObject = (object) null;
  421.       }
  422.       base.Dispose(disposing);
  423.     }
  424.  
  425.     private void DisposeAutoEditors()
  426.     {
  427.       this.Dispose((RepositoryItem) this.fComboEditor);
  428.       this.Dispose((RepositoryItem) this.fButtonEditor);
  429.       this.Dispose((RepositoryItem) this.fPopupEditor);
  430.       this.Dispose((RepositoryItem) this.fTextEditor);
  431.     }
  432.  
  433.     private void Dispose(RepositoryItem item)
  434.     {
  435.       if (item == null)
  436.         return;
  437.       item.Dispose();
  438.       item = (RepositoryItem) null;
  439.     }
  440.  
  441.     protected override void ActivateDataSource()
  442.     {
  443.       if (this.IsLoading)
  444.         return;
  445.       this.DataManager.SetGridDataSource((BindingContext) null, (object) this.SelectedObjects, (string) null);
  446.       this.OnDataManager_Reset((object) this.DataManager, EventArgs.Empty);
  447.       this.LayoutChanged();
  448.       if (this.DataManager.CurrentControllerRow < 0 || this.DataManager.CurrentControllerRow > this.RecordCount - 1)
  449.         this.FocusedRecord = Math.Min(0, this.RecordCount - 1);
  450.       else
  451.         this.FocusedRecord = this.DataManager.CurrentControllerRow;
  452.       this.FocusedRecordCellIndex = this.RecordCount == 0 ? -1 : 0;
  453.     }
  454.  
  455.     protected override void SetFocusedRowAfterChangingVisibleRows()
  456.     {
  457.       this.TryLoadFocusedRow();
  458.       base.SetFocusedRowAfterChangingVisibleRows();
  459.     }
  460.  
  461.     private void TrySaveFocusedRow()
  462.     {
  463.       if (this.FocusedRow == null || !this.FocusedRow.IsConnected)
  464.         return;
  465.       this.oldFocusedPosition = new RowPositionKeeper(this.FocusedRow);
  466.     }
  467.  
  468.     private void TryLoadFocusedRow()
  469.     {
  470.       if (this.oldFocusedPosition == null)
  471.         return;
  472.       this.oldFocusedPosition.Restore(this);
  473.       this.oldFocusedPosition = (RowPositionKeeper) null;
  474.     }
  475.  
  476.     private bool AreEqual(object[] dataSource, object[] value)
  477.     {
  478.       bool flag = false;
  479.       if (value != null && dataSource != null && dataSource.Length == value.Length)
  480.       {
  481.         int index = 0;
  482.         while (index < value.Length && dataSource[index] == value[index])
  483.           ++index;
  484.         if (index == value.Length)
  485.           flag = true;
  486.       }
  487.       return flag;
  488.     }
  489.  
  490.     private void SubscribeComponentEvents(IServiceProvider provider)
  491.     {
  492.       IComponentChangeService componentChangeService = PropertyHelper.GetComponentChangeService(provider);
  493.       if (componentChangeService == null)
  494.         return;
  495.       componentChangeService.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
  496.       componentChangeService.ComponentRemoved += new ComponentEventHandler(this.OnComponentRemoved);
  497.     }
  498.  
  499.     private void UnsubscribeComponentEvents(IServiceProvider provider)
  500.     {
  501.       IComponentChangeService componentChangeService = PropertyHelper.GetComponentChangeService(provider);
  502.       if (componentChangeService == null)
  503.         return;
  504.       componentChangeService.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged);
  505.       componentChangeService.ComponentRemoved -= new ComponentEventHandler(this.OnComponentRemoved);
  506.     }
  507.  
  508.     private void OnComponentRemoved(object sender, ComponentEventArgs e)
  509.     {
  510.       for (int index = 0; index < this.SelectedObjects.Length; ++index)
  511.       {
  512.         if (this.SelectedObjects[index] == e.Component)
  513.         {
  514.           object[] objArray = new object[this.SelectedObjects.Length - 1];
  515.           Array.Copy((Array) this.SelectedObjects, 0, (Array) objArray, 0, index);
  516.           if (index < objArray.Length)
  517.             Array.Copy((Array) this.SelectedObjects, index + 1, (Array) objArray, index, objArray.Length - index);
  518.           this.SelectedObjects = objArray;
  519.           break;
  520.         }
  521.       }
  522.     }
  523.  
  524.     private void OnComponentChanged(object sender, ComponentChangedEventArgs e)
  525.     {
  526.       bool flag = false;
  527.       int length = this.SelectedObjects.Length;
  528.       for (int index = 0; index < length; ++index)
  529.       {
  530.         if (this.SelectedObjects[index] == e.Component)
  531.         {
  532.           flag = true;
  533.           break;
  534.         }
  535.       }
  536.       if (!flag)
  537.         return;
  538.       this.ComponentChanged();
  539.     }
  540.  
  541.     protected virtual void ComponentChanged()
  542.     {
  543.       this.DataModeHelper.Invalidate();
  544.       this.InvalidateUpdate();
  545.     }
  546.  
  547.     private bool ShouldSerializeOptionsMenu()
  548.     {
  549.       return this.OptionsMenu.ShouldSerializeCore((IComponent) this);
  550.     }
  551.  
  552.     internal void ProcessUIEditing(object sender, ButtonPressedEventArgs args)
  553.     {
  554.       if (args != null && args.Button != null && !args.Button.IsDefaultButton)
  555.         return;
  556.       this.WindowsFormsEditorService.ProcessUIEditing();
  557.     }
  558.  
  559.     object IServiceProvider.GetService(System.Type serviceType)
  560.     {
  561.       if (serviceType == typeof (IWindowsFormsEditorService))
  562.         return (object) this.windowsFormsEditorService;
  563.       if (serviceType == typeof (IPropertyDescriptorService))
  564.         return (object) this;
  565.       if (this.ServiceProvider == null)
  566.         return (object) null;
  567.       else
  568.         return this.ServiceProvider.GetService(serviceType);
  569.     }
  570.  
  571.     protected internal virtual void UnlockRowLoading()
  572.     {
  573.       ++this.rowLoadingUnlockCount;
  574.     }
  575.  
  576.     protected internal virtual void LockRowLoading()
  577.     {
  578.       --this.rowLoadingUnlockCount;
  579.     }
  580.  
  581.     protected override EditorContainerHelper CreateHelper()
  582.     {
  583.       return (EditorContainerHelper) new PGridEditorContainerHelper((VGridControlBase) this);
  584.     }
  585.  
  586.     protected internal override bool IsDefault(RepositoryItem item)
  587.     {
  588.       if (item == null)
  589.         return false;
  590.       else
  591.         return this.defaultEditorMarkers.Contains((object) item);
  592.     }
  593.  
  594.     protected internal override void OnClearViewInfo()
  595.     {
  596.       base.OnClearViewInfo();
  597.       this.defaultEditorMarkers.Clear();
  598.     }
  599.  
  600.     protected RepositoryItem MakeDefault(RepositoryItem item)
  601.     {
  602.       if (item != null)
  603.         this.defaultEditorMarkers.Add((object) item, (object) true);
  604.       return item;
  605.     }
  606.  
  607.     protected internal override RepositoryItem CreateDefaultRowEdit(RowProperties p)
  608.     {
  609.       DescriptorContext descriptorContext = this.DataModeHelper.GetDescriptorContext(p.FieldName);
  610.       PropertyDescriptor propertyDescriptor = descriptorContext.PropertyDescriptor;
  611.       if (p.Row == null || propertyDescriptor == null)
  612.         return this.MakeDefault((RepositoryItem) base.CreateDefaultRowEdit(p).Clone());
  613.       if (this.OptionsBehavior.UseDefaultEditorsCollection)
  614.       {
  615.         DevExpress.XtraVerticalGrid.Rows.DefaultEditor defaultEditor = this.DefaultEditors[propertyDescriptor.PropertyType];
  616.         if (defaultEditor != null && defaultEditor.Edit != null)
  617.           return this.MakeDefault((RepositoryItem) defaultEditor.Edit.Clone());
  618.       }
  619.       switch (this.DataModeHelper.GetEditStyle(descriptorContext))
  620.       {
  621.         case UITypeEditorEditStyle.Modal:
  622.           return this.MakeDefault((RepositoryItem) this.ButtonEditor.Clone());
  623.         case UITypeEditorEditStyle.DropDown:
  624.           return this.MakeDefault((RepositoryItem) this.PopupEditor.Clone());
  625.         default:
  626.           if (PropertyHelper.GetStandardValuesSupported((ITypeDescriptorContext) descriptorContext))
  627.             return this.MakeDefault((RepositoryItem) this.ComboEditor.Clone());
  628.           else
  629.             return this.MakeDefault((RepositoryItem) this.TextEditor.Clone());
  630.       }
  631.     }
  632.  
  633.     protected override void ConfigureRowEdit(RepositoryItem item, RowProperties p)
  634.     {
  635.       base.ConfigureRowEdit(item, p);
  636.       DescriptorContext descriptorContext = this.DataModeHelper.GetDescriptorContext(p.FieldName);
  637.       PropertyDescriptor propertyDescriptor = descriptorContext.PropertyDescriptor;
  638.       if (p.Row == null || propertyDescriptor == null)
  639.         return;
  640.       item.BeginUpdate();
  641.       if (!item.ReadOnly && this.IsDefault(item))
  642.         item.ReadOnly = this.ViewInfoHelper.ShouldRenderReadOnly(p.FieldName, p);
  643.       RepositoryItemButtonEdit repositoryItemButtonEdit = item as RepositoryItemButtonEdit;
  644.       if (repositoryItemButtonEdit != null && (this.IsDefault(item) || !this.IsDefault(item) && repositoryItemButtonEdit.TextEditStyle == TextEditStyles.Standard))
  645.         repositoryItemButtonEdit.TextEditStyle = PropertyHelper.AllowTextEdit((ITypeDescriptorContext) descriptorContext) ? TextEditStyles.Standard : TextEditStyles.DisableTextEditor;
  646.       if (this.IsAutoEditor(item) && PropertyHelper.IsPassword(descriptorContext))
  647.       {
  648.         RepositoryItemTextEdit repositoryItemTextEdit = item as RepositoryItemTextEdit;
  649.         if (repositoryItemTextEdit != null)
  650.           repositoryItemTextEdit.PasswordChar = this.OptionsView.PasswordChar;
  651.       }
  652.       item.CancelUpdate();
  653.     }
  654.  
  655.     protected internal virtual bool IsAutoEditor(RepositoryItem item)
  656.     {
  657.       if (item is IAutoEditor)
  658.         return true;
  659.       else
  660.         return false;
  661.     }
  662.  
  663.     protected override void OnOptionsBehaviorChanged(object sender, BaseOptionChangedEventArgs e)
  664.     {
  665.       if (!(e.Name == "UseDefaultEditorsCollection"))
  666.         return;
  667.       this.ResetGeneratedRowEdits();
  668.     }
  669.  
  670.     protected override void OnOptionsViewChanged(object sender, BaseOptionChangedEventArgs e)
  671.     {
  672.       base.OnOptionsViewChanged(sender, e);
  673.       if (!(e.Name == "PasswordChar"))
  674.         return;
  675.       this.ResetGeneratedRowEdits();
  676.     }
  677.  
  678.     protected override void AddVisibleRows(VGridRows rows, bool root)
  679.     {
  680.       if (this.OptionsView == null)
  681.         return;
  682.       if (!root || this.OptionsView.ShowRootCategories)
  683.       {
  684.         base.AddVisibleRows(rows, root);
  685.       }
  686.       else
  687.       {
  688.         List<BaseRow> list = new List<BaseRow>();
  689.         foreach (BaseRow baseRow1 in rows)
  690.         {
  691.           if (baseRow1.Visible)
  692.           {
  693.             if (!(baseRow1 is CategoryRow))
  694.             {
  695.               list.Add(baseRow1);
  696.             }
  697.             else
  698.             {
  699.               foreach (BaseRow baseRow2 in baseRow1.ChildRows)
  700.               {
  701.                 if (baseRow2.Visible)
  702.                   list.Add(baseRow2);
  703.               }
  704.             }
  705.           }
  706.         }
  707.         list.Sort((IComparer<BaseRow>) new PGridRowComparer((IList) list));
  708.         foreach (BaseRow row in list)
  709.         {
  710.           this.VisibleRows.Add(row);
  711.           if (row.Expanded)
  712.             this.AddVisibleRows(row.ChildRows, false);
  713.         }
  714.       }
  715.     }
  716.  
  717.     protected override void ProcessEditorAfterPost(object value)
  718.     {
  719.       base.ProcessEditorAfterPost(value);
  720.       this.EditorHelper.UnmodifiedEditValue = value;
  721.     }
  722.  
  723.     protected internal void RetrieveFieldsCore(VGridRows rows, bool createCategories, string parentPropertyName, bool forceChildRowsCreating)
  724.     {
  725.       rows.IsLoadedCore = true;
  726.       object singleValue = PropertyHelper.GetSingleValue(this, parentPropertyName);
  727.       if (singleValue == null || this.objects.ContainsKey(singleValue))
  728.         return;
  729.       DescriptorContext descriptorContext = this.DataModeHelper.GetSingleDescriptorContext(parentPropertyName);
  730.       if (!PropertyHelper.IsRoot(parentPropertyName) && !PropertyHelper.GetPropertiesSupported(singleValue, (ITypeDescriptorContext) descriptorContext))
  731.         return;
  732.       PropertyDescriptorCollection properties = descriptorContext.GetProperties(singleValue, this.GetBrowsableAttributesArray());
  733.       if (properties == null || properties.Count == 0)
  734.         return;
  735.       this.objects.Add(singleValue, (object) null);
  736.       Dictionary<string, BaseRow> categories = new Dictionary<string, BaseRow>();
  737.       PropertyDescriptorCollection descriptorCollection = this.ApplySorting(properties);
  738.       int retrieveIndex = -1;
  739.       foreach (PropertyDescriptor pd in descriptorCollection)
  740.       {
  741.         ++retrieveIndex;
  742.         string propertyName = this.GetPropertyName(parentPropertyName, pd.Name);
  743.         if (!this.DataModeHelper.IsMultiSource || this.ShouldIncludeMultiProperty(propertyName))
  744.         {
  745.           PGridEditorRow row = (PGridEditorRow) this.CreateEditorRow(propertyName);
  746.           this.AssignRetrieveIndex((BaseRow) row, retrieveIndex, descriptorCollection.Count, pd);
  747.           row.Properties.Caption = this.GetCaption(pd);
  748.           this.TryExtractChildren(row, forceChildRowsCreating, propertyName);
  749.           this.TryAddToCategory(rows, createCategories, categories, pd, (BaseRow) row);
  750.         }
  751.       }
  752.       if (createCategories)
  753.         rows.AddRange(this.GetCategories(categories));
  754.       this.objects.Remove(singleValue);
  755.     }
  756.  
  757.     protected virtual PropertyDescriptorCollection ApplySorting(PropertyDescriptorCollection properties)
  758.     {
  759.       if (this.GetComparer(properties) != null)
  760.         return properties;
  761.       else
  762.         return properties.Sort((IComparer) new DisplayNameComparer());
  763.     }
  764.  
  765.     private object GetComparer(PropertyDescriptorCollection properties)
  766.     {
  767.       object obj = (object) null;
  768.       try
  769.       {
  770.         obj = properties.GetType().GetField("comparer", BindingFlags.Instance | BindingFlags.NonPublic).GetValue((object) properties);
  771.       }
  772.       catch
  773.       {
  774.       }
  775.       return obj;
  776.     }
  777.  
  778.     private void AssignRetrieveIndex(BaseRow row, int retrieveIndex, int rowCount, PropertyDescriptor pd)
  779.     {
  780.       IRetrievable retrievable = row as IRetrievable;
  781.       if (retrievable == null)
  782.         return;
  783.       if (this.NeedParenthesize(pd))
  784.         retrievable.RetrieveIndex = retrieveIndex - rowCount;
  785.       else
  786.         retrievable.RetrieveIndex = retrieveIndex;
  787.     }
  788.  
  789.     protected virtual BaseRow CreateEditorRow(string propertyName)
  790.     {
  791.       BaseRow editorRow = base.CreateEditorRow();
  792.       editorRow.Properties.FieldName = propertyName;
  793.       return editorRow;
  794.     }
  795.  
  796.     public override BaseRow CreateEditorRow()
  797.     {
  798.       return (BaseRow) new PGridEditorRow();
  799.     }
  800.  
  801.     private string GetPropertyName(string parentPropertyName, string name)
  802.     {
  803.       if (!string.IsNullOrEmpty(parentPropertyName))
  804.         return parentPropertyName + "." + name;
  805.       else
  806.         return name;
  807.     }
  808.  
  809.     private string GetCaption(PropertyDescriptor pd)
  810.     {
  811.       if (this.NeedParenthesize(pd))
  812.         return this.ParenthesizeCaption(pd.DisplayName);
  813.       else
  814.         return pd.DisplayName;
  815.     }
  816.  
  817.     private void TryAddToCategory(VGridRows rows, bool createCategories, Dictionary<string, BaseRow> categories, PropertyDescriptor pd, BaseRow row)
  818.     {
  819.       if (createCategories)
  820.       {
  821.         string category = pd.Category;
  822.         BaseRow baseRow = (BaseRow) null;
  823.         if (!categories.TryGetValue(category, out baseRow))
  824.         {
  825.           baseRow = (BaseRow) new CategoryRow(category);
  826.           categories[category] = baseRow;
  827.         }
  828.         baseRow.ChildRows.Add(row);
  829.       }
  830.       else
  831.         rows.Add(row);
  832.     }
  833.  
  834.     private void TryExtractChildren(PGridEditorRow row, bool forceChildRowsCreating, string propertyName)
  835.     {
  836.       object singleValue = PropertyHelper.GetSingleValue(this, propertyName);
  837.       if (singleValue == null || !PropertyHelper.GetPropertiesSupported(singleValue, (ITypeDescriptorContext) this.DataModeHelper.GetSingleDescriptorContext(propertyName)))
  838.       {
  839.         row.IsChildRowsLoaded = true;
  840.       }
  841.       else
  842.       {
  843.         if (forceChildRowsCreating)
  844.           this.RetrieveFieldsCore(row.ChildRows, false, propertyName, forceChildRowsCreating);
  845.         else
  846.           row.IsChildRowsLoaded = false;
  847.         row.Expanded = false;
  848.       }
  849.     }
  850.  
  851.     private bool ShouldIncludeMultiProperty(string propertyName)
  852.     {
  853.       if (!this.DataModeHelper.IsMultiSource)
  854.         return false;
  855.       else
  856.         return this.DataModeHelper.GetDescriptorContext(propertyName).PropertyDescriptor != null;
  857.     }
  858.  
  859.     private bool NeedParenthesize(PropertyDescriptor pd)
  860.     {
  861.       return ((ParenthesizePropertyNameAttribute) pd.Attributes[typeof (ParenthesizePropertyNameAttribute)]).NeedParenthesis;
  862.     }
  863.  
  864.     private BaseRow[] GetCategories(Dictionary<string, BaseRow> categories)
  865.     {
  866.       List<BaseRow> list = new List<BaseRow>(categories.Count);
  867.       foreach (BaseRow baseRow in categories.Values)
  868.       {
  869.         baseRow.ChildRows.Sort((IComparer) new PGridRowComparer((IList) baseRow.ChildRows));
  870.         list.Add(baseRow);
  871.       }
  872.       list.Sort((IComparer<BaseRow>) new CaptionComparer());
  873.       return list.ToArray();
  874.     }
  875.  
  876.     internal Attribute[] GetBrowsableAttributesArray()
  877.     {
  878.       Attribute[] attributeArray = new Attribute[this.BrowsableAttributes.Count];
  879.       this.BrowsableAttributes.CopyTo((Array) attributeArray, 0);
  880.       return attributeArray;
  881.     }
  882.  
  883.     private string ParenthesizeCaption(string caption)
  884.     {
  885.       return "(" + caption + ")";
  886.     }
  887.  
  888.     protected internal override void OnRowChanged(BaseRow row, VGridRows rows, RowProperties rowProperties, RowChangeTypeEnum changeType)
  889.     {
  890.       base.OnRowChanged(row, rows, rowProperties, changeType);
  891.       if (changeType == RowChangeTypeEnum.Value && !this.IsLoading)
  892.         this.GetRefreshStrategy(rowProperties, this.GetCellValue(row, 0)).Refresh();
  893.       this.DataModeHelper.ChangedImmutableFieldName = (string) null;
  894.     }
  895.  
  896.     protected virtual PropertyGridControl.RefreshStrategyBase GetRefreshStrategy(RowProperties props, object newValue)
  897.     {
  898.       if (this.NeedRefreshRefreshProperty(props))
  899.         return (PropertyGridControl.RefreshStrategyBase) new PropertyGridControl.RefreshAllStrategy(props);
  900.       if (PropertyHelper.GetPropertiesSupported(newValue, (ITypeDescriptorContext) this.DataModeHelper.GetDescriptorContext(props.FieldName)))
  901.         return (PropertyGridControl.RefreshStrategyBase) new PropertyGridControl.RefreshChildrenStrategy(props);
  902.       if (string.IsNullOrEmpty(this.DataModeHelper.ChangedImmutableFieldName))
  903.         return (PropertyGridControl.RefreshStrategyBase) new PropertyGridControl.VoidRefreshStrategy();
  904.       BaseRow rowByFieldName = this.GetRowByFieldName(this.DataModeHelper.ChangedImmutableFieldName);
  905.       if (rowByFieldName == null)
  906.         return (PropertyGridControl.RefreshStrategyBase) new PropertyGridControl.VoidRefreshStrategy();
  907.       else
  908.         return (PropertyGridControl.RefreshStrategyBase) new PropertyGridControl.UpdateChildrenDataStrategy(rowByFieldName.Properties);
  909.     }
  910.  
  911.     private bool NeedRefreshRefreshProperty(RowProperties properties)
  912.     {
  913.       if (this.AutoGenerateRows)
  914.         return this.DataModeHelper.HasRefreshPropertiesAttribute(properties);
  915.       else
  916.         return false;
  917.     }
  918.  
  919.     protected override bool GenerateRowsOnDataManagerReset()
  920.     {
  921.       if (base.GenerateRowsOnDataManagerReset())
  922.         return !this.DesignMode;
  923.       else
  924.         return false;
  925.     }
  926.  
  927.     public override void RetrieveFields()
  928.     {
  929.       this.RetrieveFields(!this.OptionsBehavior.AllowDynamicRowLoading);
  930.     }
  931.  
  932.     public void RetrieveFields(bool forceChildRowsCreating)
  933.     {
  934.       if (this.SelectedObject == null)
  935.         return;
  936.       this.BeginUpdate();
  937.       try
  938.       {
  939.         this.DataModeHelper.Invalidate();
  940.         this.Rows.DestroyRows();
  941.         this.objects = new Hashtable();
  942.         this.RetrieveFieldsCore(this.Rows, true, "", forceChildRowsCreating);
  943.       }
  944.       finally
  945.       {
  946.         this.EndUpdate();
  947.       }
  948.     }
  949.  
  950.     internal BaseRow GetLoadedRowByFieldName(string fieldName)
  951.     {
  952.       return this.Rows.GetLoadedRowByFieldName(fieldName, true);
  953.     }
  954.  
  955.     public PropertyDescriptor GetPropertyDescriptor(BaseRow row)
  956.     {
  957.       object targetObject;
  958.       return this.GetPropertyDescriptor(row, out targetObject);
  959.     }
  960.  
  961.     public PropertyDescriptor GetPropertyDescriptor(BaseRow row, out object targetObject)
  962.     {
  963.       if (row == null)
  964.         throw new ArgumentNullException("row");
  965.       DescriptorContext descriptorContext = this.DataModeHelper.GetDescriptorContext(row.Properties.FieldName);
  966.       targetObject = descriptorContext.Instance;
  967.       return descriptorContext.PropertyDescriptor;
  968.     }
  969.  
  970.     internal void UpdateEditor()
  971.     {
  972.       this.PostEditor();
  973.       if (this.ActiveEditor == null)
  974.         return;
  975.       this.ActiveEditor.Properties.Appearance.Assign(this.UpdateFocusedAppearance());
  976.     }
  977.  
  978.     private AppearanceObject UpdateFocusedAppearance()
  979.     {
  980.       RowValueInfo rowValueInfo = this.ViewInfo[this.FocusedRow].ValuesInfo[this.FocusedRecordCellIndex];
  981.       rowValueInfo.CalcAppearance(this.ViewInfo);
  982.       return rowValueInfo.Style;
  983.     }
  984.  
  985.     protected internal override void RowDoubleClick(BaseRow row)
  986.     {
  987.       if (row != null && row.HasChildren)
  988.       {
  989.         base.RowDoubleClick(row);
  990.       }
  991.       else
  992.       {
  993.         if (this.ActiveEditor == null)
  994.           this.ShowEditor();
  995.         ComboBoxEdit comboEdit;
  996.         if (this.ActiveEditor == null || this.ActiveEditor.Properties.ReadOnly || (comboEdit = this.ActiveEditor as ComboBoxEdit) == null)
  997.           return;
  998.         this.ScrollComboBox(comboEdit);
  999.       }
  1000.     }
  1001.  
  1002.     protected internal override void UpdateEditViewInfoData(BaseEditViewInfo editViewInfo, RowProperties properties, int recordIndex)
  1003.     {
  1004.       base.UpdateEditViewInfoData(editViewInfo, properties, recordIndex);
  1005.       if (!this.OverrideEditorDisplayText(editViewInfo.Item, properties))
  1006.         return;
  1007.       string textData = this.DataModeHelper.GetTextData(properties, recordIndex);
  1008.       if (properties.Format.FormatType != FormatType.None || textData == null)
  1009.         return;
  1010.       editViewInfo.SetDisplayText(textData);
  1011.     }
  1012.  
  1013.     protected virtual bool OverrideEditorDisplayText(RepositoryItem item, RowProperties properties)
  1014.     {
  1015.       if (properties == null)
  1016.         return false;
  1017.       bool flag = this.EditorHelper.OverrideEditorDisplayText(item, properties.FieldName);
  1018.       RepositoryItemTextEdit repositoryItemTextEdit = item as RepositoryItemTextEdit;
  1019.       if (repositoryItemTextEdit != null && (int) repositoryItemTextEdit.PasswordChar != 0)
  1020.         return false;
  1021.       else
  1022.         return flag;
  1023.     }
  1024.  
  1025.     protected virtual void CheckPropertyDescriptors(PropertyDescriptorCollection properties)
  1026.     {
  1027.       if (properties == null)
  1028.         return;
  1029.       foreach (PropertyDescriptor propertyDescriptor in properties)
  1030.       {
  1031.         if (propertyDescriptor == null)
  1032.           throw new ArgumentNullException("Properties");
  1033.       }
  1034.     }
  1035.  
  1036.     internal bool CanResetDefaultValue(RowProperties properties)
  1037.     {
  1038.       return this.DataModeHelper.CanResetDefaultValue(properties);
  1039.     }
  1040.  
  1041.     internal void ResetDefaultValue(BaseRow row)
  1042.     {
  1043.       this.DataModeHelper.Reset = true;
  1044.       try
  1045.       {
  1046.         this.SetCellValue(row, 0, (object) null);
  1047.         if (this.ActiveEditor == null || row != this.FocusedRow)
  1048.           return;
  1049.         this.EditingValue = this.GetCellValue(row, 0);
  1050.       }
  1051.       finally
  1052.       {
  1053.         this.DataModeHelper.Reset = false;
  1054.       }
  1055.     }
  1056.  
  1057.     private void ScrollComboBox(ComboBoxEdit comboEdit)
  1058.     {
  1059.       int count = comboEdit.Properties.Items.Count;
  1060.       if (count == 0)
  1061.         return;
  1062.       comboEdit.IsModified = true;
  1063.       comboEdit.SelectedIndex = comboEdit.SelectedIndex >= count - 1 ? 0 : comboEdit.SelectedIndex + 1;
  1064.       this.PostEditor();
  1065.     }
  1066.  
  1067.     protected internal override void RaiseShowMenu(PopupMenuShowingEventArgs e)
  1068.     {
  1069.       this.RaiseShowMenuCore(e);
  1070.       PropertyGridMenuEventHandler menuEventHandler = (PropertyGridMenuEventHandler) this.Events[VGridControlBase.GS.showMenu];
  1071.       if (menuEventHandler == null)
  1072.         return;
  1073.       PropertyGridMenuEventArgs e1 = new PropertyGridMenuEventArgs(e.Menu, e.Row);
  1074.       menuEventHandler((object) this, e1);
  1075.     }
  1076.  
  1077.     protected virtual void RaiseCustomPropertyDescriptors(CustomPropertyDescriptorsEventArgs e)
  1078.     {
  1079.       CustomPropertyDescriptorsEventHandler descriptorsEventHandler = (CustomPropertyDescriptorsEventHandler) this.Events[VGridControlBase.GS.customPropertyDescriptors];
  1080.       if (descriptorsEventHandler == null)
  1081.         return;
  1082.       descriptorsEventHandler((object) this, e);
  1083.     }
  1084.  
  1085.     protected internal virtual void ProcessUIEditingException(Exception e)
  1086.     {
  1087.       int num = (int) MessageBox.Show(e.Message, "Error Information", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  1088.     }
  1089.  
  1090.     internal UITypeEditor GetUITypeEditor(PropertyDescriptor propertyDescriptor)
  1091.     {
  1092.       UITypeEditor uiTypeEditor;
  1093.       if (this.CustomUITypeEditors.TryGetValue(propertyDescriptor.Name, out uiTypeEditor))
  1094.         return uiTypeEditor;
  1095.       try
  1096.       {
  1097.         return propertyDescriptor.GetEditor(typeof (UITypeEditor)) as UITypeEditor;
  1098.       }
  1099.       catch
  1100.       {
  1101.         return (UITypeEditor) null;
  1102.       }
  1103.     }
  1104.  
  1105.     protected internal override VGridViewInfoHelper CreateViewInfoHelper()
  1106.     {
  1107.       return (VGridViewInfoHelper) new PGridViewInfoHelper(this);
  1108.     }
  1109.  
  1110.     PropertyDescriptorCollection IPropertyDescriptorService.GetProperties(object source, ITypeDescriptorContext context, Attribute[] attributes)
  1111.     {
  1112.       CustomPropertyDescriptorsEventArgs e = new CustomPropertyDescriptorsEventArgs(source, context, attributes);
  1113.       this.RaiseCustomPropertyDescriptors(e);
  1114.       this.CheckPropertyDescriptors(e.Properties);
  1115.       return e.Properties;
  1116.     }
  1117.  
  1118.     protected internal virtual void ConfigurePredefinedProperties(DevExpress.XtraVerticalGrid.Rows.DefaultEditor edit)
  1119.     {
  1120.       RepositoryItemColorEdit repositoryItemColorEdit = edit.Edit as RepositoryItemColorEdit;
  1121.       if (repositoryItemColorEdit == null || edit.EditingType != typeof (Color))
  1122.         return;
  1123.       repositoryItemColorEdit.TextEditStyle = TextEditStyles.Standard;
  1124.     }
  1125.  
  1126.     protected override bool BreakPostOnEquals()
  1127.     {
  1128.       if (!base.BreakPostOnEquals() && !this.GridDisposing)
  1129.         return object.Equals(this.EditorHelper.UnmodifiedEditValue, this.ActiveEditor.EditValue);
  1130.       else
  1131.         return true;
  1132.     }
  1133.  
  1134.     private class SelectedObjectConverter : ReferenceConverter
  1135.     {
  1136.       public SelectedObjectConverter()
  1137.         : base(typeof (IComponent))
  1138.       {
  1139.       }
  1140.     }
  1141.  
  1142.     protected abstract class RefreshStrategyBase
  1143.     {
  1144.       private readonly RowProperties rowProperties;
  1145.       private readonly PropertyGridControl grid;
  1146.  
  1147.       public PropertyGridControl Grid
  1148.       {
  1149.         get
  1150.         {
  1151.           return this.grid;
  1152.         }
  1153.       }
  1154.  
  1155.       public BaseRow Row
  1156.       {
  1157.         get
  1158.         {
  1159.           return this.RowProperties.Row;
  1160.         }
  1161.       }
  1162.  
  1163.       public RowProperties RowProperties
  1164.       {
  1165.         get
  1166.         {
  1167.           return this.rowProperties;
  1168.         }
  1169.       }
  1170.  
  1171.       public string FieldName
  1172.       {
  1173.         get
  1174.         {
  1175.           return this.RowProperties.FieldName;
  1176.         }
  1177.       }
  1178.  
  1179.       public RefreshStrategyBase(RowProperties rowProperties)
  1180.       {
  1181.         if (rowProperties == null)
  1182.           return;
  1183.         this.rowProperties = rowProperties;
  1184.         this.grid = (PropertyGridControl) rowProperties.Row.Grid;
  1185.       }
  1186.  
  1187.       public abstract void Refresh();
  1188.     }
  1189.  
  1190.     private class VoidRefreshStrategy : PropertyGridControl.RefreshStrategyBase
  1191.     {
  1192.       public VoidRefreshStrategy()
  1193.         : base((RowProperties) null)
  1194.       {
  1195.       }
  1196.  
  1197.       public override void Refresh()
  1198.       {
  1199.       }
  1200.     }
  1201.  
  1202.     private class RefreshAllStrategy : PropertyGridControl.RefreshStrategyBase
  1203.     {
  1204.       public RefreshAllStrategy(RowProperties props)
  1205.         : base(props)
  1206.       {
  1207.       }
  1208.  
  1209.       public override void Refresh()
  1210.       {
  1211.         this.Grid.BeginUpdate();
  1212.         SaveExpandedStateOperation expandedStateOperation = new SaveExpandedStateOperation();
  1213.         this.Grid.RowsIterator.DoOperation((RowOperation) expandedStateOperation);
  1214.         object[] selectedObjects = this.Grid.SelectedObjects;
  1215.         this.Grid.SelectedObjects = (object[]) null;
  1216.         this.Grid.SelectedObjects = selectedObjects;
  1217.         this.Grid.RowsIterator.DoOperation((RowOperation) new LoadExpandedStateOperation(expandedStateOperation.ExpandedRowStateStore));
  1218.         this.Grid.EndUpdate();
  1219.       }
  1220.     }
  1221.  
  1222.     private class RefreshChildrenStrategy : PropertyGridControl.RefreshStrategyBase
  1223.     {
  1224.       public RefreshChildrenStrategy(RowProperties props)
  1225.         : base(props)
  1226.       {
  1227.       }
  1228.  
  1229.       public override void Refresh()
  1230.       {
  1231.         if (!this.Row.ChildRows.IsLoaded)
  1232.           return;
  1233.         OneRowState oneRowState = new OneRowState(this.Row);
  1234.         this.Grid.BeginUpdate();
  1235.         this.Row.ChildRows.DestroyRows();
  1236.         this.Grid.RetrieveFieldsCore(this.Row.ChildRows, false, this.FieldName, true);
  1237.         this.Grid.EndUpdate();
  1238.         oneRowState.Restore(this.Grid);
  1239.       }
  1240.     }
  1241.  
  1242.     private class UpdateChildrenDataStrategy : PropertyGridControl.RefreshStrategyBase
  1243.     {
  1244.       public UpdateChildrenDataStrategy(RowProperties props)
  1245.         : base(props)
  1246.       {
  1247.       }
  1248.  
  1249.       public override void Refresh()
  1250.       {
  1251.         if (!this.Row.ChildRows.IsLoaded)
  1252.           return;
  1253.         this.Grid.BeginUpdate();
  1254.         this.Grid.RowsIterator.DoLocalOperation((RowOperation) new DelegateRowPropertiesOperation(new DelegateRowPropertiesOperation.ExecuteDelegate(this.InvalidateRow)), this.Row);
  1255.         this.Grid.EndUpdate();
  1256.       }
  1257.  
  1258.       private void InvalidateRow(RowProperties properties)
  1259.       {
  1260.         this.Grid.ViewInfo.UpdateCellData(properties.Row, 0, properties.CellIndex);
  1261.       }
  1262.     }
  1263.   }
  1264. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement