public CategoryGridEntry(PropertyGrid ownerGrid, GridEntry peParent,string name, GridEntry[] childGridEntries) : base(ownerGrid, peParent) { this.name = name; #if DEBUG for (int n = 0;n < childGridEntries.Length; n++) { Debug.Assert(childGridEntries[n] != null, "Null item in category subproperty list"); } #endif if (categoryStates == null) { categoryStates = new Hashtable(); } lock (categoryStates) { if (!categoryStates.ContainsKey(name)) { categoryStates.Add(name, true); } } this.IsExpandable = true; for (int i = 0; i < childGridEntries.Length; i++) { childGridEntries[i].ParentGridEntry = this; } this.ChildCollection = new GridEntryCollection(this, childGridEntries); lock (categoryStates) { this.InternalExpanded = (bool)categoryStates[name]; } this.SetFlag(GridEntry.FLAG_LABEL_BOLD,true); }
public CategoryGridEntry(PropertyGrid ownerGrid, GridEntry peParent, string name, GridEntry[] childGridEntries) : base(ownerGrid, peParent) { this.name = name; if (categoryStates == null) { categoryStates = new Hashtable(); } lock (categoryStates) { if (!categoryStates.ContainsKey(name)) { categoryStates.Add(name, true); } } this.IsExpandable = true; for (int i = 0; i < childGridEntries.Length; i++) { childGridEntries[i].ParentGridEntry = this; } base.ChildCollection = new GridEntryCollection(this, childGridEntries); lock (categoryStates) { this.InternalExpanded = (bool) categoryStates[name]; } this.SetFlag(0x40, true); }
public override object GetChildValueOwner(GridEntry childEntry) { if (!this.mergedPd.PropertyType.IsValueType && ((this.Flags & 0x200) == 0)) { return this.mergedPd.GetValues(this.objs); } return base.GetChildValueOwner(childEntry); }
internal void CategorizePropEntries() { if (this.Children.Count > 0) { GridEntry[] dest = new GridEntry[this.Children.Count]; this.Children.CopyTo(dest, 0); if ((base.PropertySort & PropertySort.Categorized) != PropertySort.NoSort) { Hashtable hashtable = new Hashtable(); for (int i = 0; i < dest.Length; i++) { GridEntry entry = dest[i]; if (entry != null) { string propertyCategory = entry.PropertyCategory; ArrayList list = (ArrayList) hashtable[propertyCategory]; if (list == null) { list = new ArrayList(); hashtable[propertyCategory] = list; } list.Add(entry); } } ArrayList list2 = new ArrayList(); IDictionaryEnumerator enumerator = hashtable.GetEnumerator(); while (enumerator.MoveNext()) { ArrayList list3 = (ArrayList) enumerator.Value; if (list3 != null) { string key = (string) enumerator.Key; if (list3.Count > 0) { GridEntry[] array = new GridEntry[list3.Count]; list3.CopyTo(array, 0); try { list2.Add(new CategoryGridEntry(base.ownerGrid, this, key, array)); continue; } catch { continue; } } } } dest = new GridEntry[list2.Count]; list2.CopyTo(dest, 0); StringSorter.Sort(dest); base.ChildCollection.Clear(); base.ChildCollection.AddRange(dest); } } }
protected GridEntry (PropertyGrid propertyGrid, GridEntry parent) { if (propertyGrid == null) throw new ArgumentNullException ("propertyGrid"); property_grid = propertyGrid; plus_minus_bounds = new Rectangle (0,0,0,0); top = -1; grid_items = new GridItemCollection (); expanded = false; this.parent = parent; child_griditems_cache = null; }
internal SingleSelectRootGridEntry(PropertyGridView gridEntryHost, object value, GridEntry parent, IServiceProvider baseProvider, IDesignerHost host, PropertyTab tab, PropertySort sortType) : base(gridEntryHost.OwnerGrid, parent) { this.host = host; this.gridEntryHost = gridEntryHost; this.baseProvider = baseProvider; this.tab = tab; this.objValue = value; this.objValueClassName = TypeDescriptor.GetClassName(this.objValue); this.IsExpandable = true; base.PropertySort = sortType; this.InternalExpanded = true; }
protected virtual void Dispose(bool disposing) { if (disposing) { if (owner != null && entries != null) { for (int i = 0; i < entries.Length; i++) { if (entries[i] != null) { ((GridEntry)entries[i]).Dispose(); entries[i] = null; } } entries = new GridEntry[0]; } } }
public void AddRange(GridEntry[] value) { if (value == null) { throw new ArgumentNullException("value"); } if (entries != null) { GridEntry[] newArray = new GridEntry[entries.Length + value.Length]; entries.CopyTo(newArray, 0); value.CopyTo(newArray, entries.Length); entries = newArray; } else { entries = (GridEntry[])value.Clone(); } }
internal SingleSelectRootGridEntry(PropertyGridView gridEntryHost, object value, GridEntry parent, IServiceProvider baseProvider, IDesignerHost host, PropertyTab tab, PropertySort sortType) : base(gridEntryHost.OwnerGrid, parent) { Debug.Assert(value != null,"Can't browse a null object!"); this.host = host; this.gridEntryHost = gridEntryHost; this.baseProvider = baseProvider; this.tab = tab; this.objValue = value; this.objValueClassName = TypeDescriptor.GetClassName(this.objValue); this.IsExpandable = true; // default to categories this.PropertySort = sortType; this.InternalExpanded = true; }
protected GridEntry(PropertyGrid owner, GridEntry peParent) { this.parentPE = peParent; this.ownerGrid = owner; if (peParent != null) { this.propertyDepth = peParent.PropertyDepth + 1; this.PropertySort = peParent.PropertySort; if (peParent.ForceReadOnly) { this.flags |= 0x400; } } else { this.propertyDepth = -1; } }
public void AddRange(GridEntry[] value) { if (value == null) { throw new ArgumentNullException("value"); } if (base.entries != null) { GridEntry[] array = new GridEntry[base.entries.Length + value.Length]; base.entries.CopyTo(array, 0); value.CopyTo(array, base.entries.Length); base.entries = array; } else { base.entries = (GridEntry[]) value.Clone(); } }
internal override bool NotifyChildValue(GridEntry pe, int type) { bool flag = false; IDesignerHost designerHost = this.DesignerHost; DesignerTransaction transaction = null; if (designerHost != null) { transaction = designerHost.CreateTransaction(); } try { flag = base.NotifyChildValue(pe, type); } finally { if (transaction != null) { transaction.Commit(); } } return flag; }
private bool IsValueType (GridEntry item) { if (item != null && item.PropertyDescriptor != null && (item.PropertyDescriptor.PropertyType.IsValueType || item.PropertyDescriptor.PropertyType.IsPrimitive)) return true; return false; }
/// <include file='doc\GridEntry.uex' path='docs/doc[@for="GridEntry.NotifyChildValue"]/*' /> /// <devdoc> /// Sends a notify message to the child GridEntry, and returns the success result /// </devdoc> internal virtual bool NotifyChildValue(GridEntry pe, int type) { return pe.NotifyValueGivenParent(pe.GetValueOwner(),type); }
private static ArrayList GetCommonProperties(object[] objs, bool presort, PropertyTab tab, GridEntry parentEntry) { PropertyDescriptorCollection[] descriptorsArray = new PropertyDescriptorCollection[objs.Length]; Attribute[] array = new Attribute[parentEntry.BrowsableAttributes.Count]; parentEntry.BrowsableAttributes.CopyTo(array, 0); for (int i = 0; i < objs.Length; i++) { PropertyDescriptorCollection descriptors = tab.GetProperties(parentEntry, objs[i], array); if (presort) { descriptors = descriptors.Sort(MultiSelectRootGridEntry.PropertyComparer); } descriptorsArray[i] = descriptors; } ArrayList list = new ArrayList(); PropertyDescriptor[] descriptorArray = new PropertyDescriptor[objs.Length]; int[] numArray = new int[descriptorsArray.Length]; for (int j = 0; j < descriptorsArray[0].Count; j++) { PropertyDescriptor descriptor = descriptorsArray[0][j]; bool flag = descriptor.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute(); for (int k = 1; flag && (k < descriptorsArray.Length); k++) { if (numArray[k] >= descriptorsArray[k].Count) { flag = false; break; } PropertyDescriptor descriptor2 = descriptorsArray[k][numArray[k]]; if (descriptor.Equals(descriptor2)) { numArray[k]++; if (!descriptor2.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute()) { flag = false; break; } descriptorArray[k] = descriptor2; continue; } int num4 = numArray[k]; descriptor2 = descriptorsArray[k][num4]; flag = false; while (MultiSelectRootGridEntry.PropertyComparer.Compare(descriptor2, descriptor) <= 0) { if (descriptor.Equals(descriptor2)) { if (!descriptor2.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute()) { flag = false; num4++; } else { flag = true; descriptorArray[k] = descriptor2; numArray[k] = num4 + 1; } break; } num4++; if (num4 >= descriptorsArray[k].Count) { break; } descriptor2 = descriptorsArray[k][num4]; } if (!flag) { numArray[k] = num4; break; } } if (flag) { descriptorArray[0] = descriptor; list.Add(descriptorArray.Clone()); } } return(list); }
internal PropertyDescriptorGridEntry(PropertyGrid ownerGrid, GridEntry peParent, bool hide) : base(ownerGrid, peParent) { activeXHide = hide; }
protected void SetPropertyValueCore(object obj, object value, bool doUndo) { if (propertyInfo == null) { return; } // Store the current cursor and set it to the HourGlass. // Cursor oldCursor = Cursor.Current; try { Cursor.Current = Cursors.WaitCursor; object target = obj; if (target is ICustomTypeDescriptor) { target = ((ICustomTypeDescriptor)target).GetPropertyOwner(propertyInfo); } // check the type of the object we are modifying. If it's a value type or an array, // we need to modify the object and push the value back up to the parent. // bool treatAsValueType = false; if (ParentGridEntry != null) { Type propType = ParentGridEntry.PropertyType; treatAsValueType = propType.IsValueType || propType.IsArray; } if (target != null) { propertyInfo.SetValue(target, value); // Microsoft, okay, since the value that we modified may not // be stored by the parent property, we need to push this // value back into the parent. An example here is Size or // Location, which return Point objects that are unconnected // to the object they relate to. So we modify the Point object and // push it back into the object we got it from. // if (treatAsValueType) { GridEntry parent = ParentGridEntry; if (parent != null && parent.IsValueEditable) { parent.PropertyValue = obj; } } } } finally { // Flip back to the old cursor. // Cursor.Current = oldCursor; } }
public void Clear() { entries = new GridEntry[0]; }
public ArrayElementGridEntry(PropertyGrid ownerGrid, GridEntry peParent, int index) : base(ownerGrid, peParent) { this.index = index; this.SetFlag(FLAG_RENDER_READONLY, (peParent.Flags & FLAG_RENDER_READONLY) != 0 || peParent.ForceReadOnly); }
internal PropertyDescriptorGridEntry(PropertyGrid ownerGrid, GridEntry parent, bool hide) : base(ownerGrid, parent) { _hide = hide; }
private static ArrayList GetCommonProperties(object[] objs, bool presort, PropertyTab tab, GridEntry parentEntry) { PropertyDescriptorCollection[] propCollections = new PropertyDescriptorCollection[objs.Length]; Attribute[] attrs = new Attribute[parentEntry.BrowsableAttributes.Count]; parentEntry.BrowsableAttributes.CopyTo(attrs, 0); for (int i = 0; i < objs.Length; i++) { PropertyDescriptorCollection pdc = tab.GetProperties(parentEntry, objs[i], attrs); if (presort) { pdc = pdc.Sort(PropertyComparer); } propCollections[i] = pdc; } ArrayList mergedList = new ArrayList(); PropertyDescriptor[] matchArray = new PropertyDescriptor[objs.Length]; // // Merge the property descriptors // int[] posArray = new int[propCollections.Length]; for (int i = 0; i < propCollections[0].Count; i++) { PropertyDescriptor pivotDesc = propCollections[0][i]; bool match = pivotDesc.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute(); for (int j = 1; match && j < propCollections.Length; j++) { if (posArray[j] >= propCollections[j].Count) { match = false; break; } // check to see if we're on a match // PropertyDescriptor jProp = propCollections[j][posArray[j]]; if (pivotDesc.Equals(jProp)) { posArray[j] += 1; if (!jProp.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute()) { match = false; break; } matchArray[j] = jProp; continue; } int jPos = posArray[j]; jProp = propCollections[j][jPos]; match = false; // if we aren't on a match, check all the items until we're past // where the matching item would be while (PropertyComparer.Compare(jProp, pivotDesc) <= 0) { // got a match! if (pivotDesc.Equals(jProp)) { if (!jProp.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute()) { match = false; jPos++; } else { match = true; matchArray[j] = jProp; posArray[j] = jPos + 1; } break; } // try again jPos++; if (jPos < propCollections[j].Count) { jProp = propCollections[j][jPos]; } else { break; } } // if we got here, there is no match, quit for this guy if (!match) { posArray[j] = jPos; break; } } // do we have a match? if (match) { matchArray[0] = pivotDesc; mergedList.Add(matchArray.Clone()); } } return(mergedList); }
private void InvalidateItemLabel(GridEntry item) { Invalidate(new Rectangle(0, ((GridEntry)item).Top, SplitterLocation, row_height)); }
protected override void OnKeyDown(KeyEventArgs e) { GridEntry selectedItem = this.SelectedGridItem; if (selectedItem == null) { /* XXX not sure what MS does, but at least we shouldn't crash */ base.OnKeyDown(e); return; } switch (e.KeyData & Keys.KeyCode) { case Keys.Left: if (e.Control) { if (SplitterLocation > 2 * V_INDENT) { SplitterPercent -= 0.01; } e.Handled = true; break; } else { /* if the node is expandable and is expanded, collapse it. * otherwise, act just like the user pressed up */ if (selectedItem.Expandable && selectedItem.Expanded) { selectedItem.Expanded = false; e.Handled = true; break; } else { goto case Keys.Up; } } case Keys.Right: if (e.Control) { if (SplitterLocation < Width) { SplitterPercent += 0.01; } e.Handled = true; break; } else { /* if the node is expandable and not expanded, expand it. * otherwise, act just like the user pressed down */ if (selectedItem.Expandable && !selectedItem.Expanded) { selectedItem.Expanded = true; e.Handled = true; break; } else { goto case Keys.Down; } } case Keys.Enter: /* toggle the expanded state of the selected item */ if (selectedItem.Expandable) { selectedItem.Expanded = !selectedItem.Expanded; } e.Handled = true; break; case Keys.Up: this.SelectedGridItem = MoveUpFromItem(selectedItem, 1); e.Handled = true; break; case Keys.Down: this.SelectedGridItem = MoveDownFromItem(selectedItem, 1); e.Handled = true; break; case Keys.PageUp: this.SelectedGridItem = MoveUpFromItem(selectedItem, vbar.LargeChange); e.Handled = true; break; case Keys.PageDown: this.SelectedGridItem = MoveDownFromItem(selectedItem, vbar.LargeChange); e.Handled = true; break; case Keys.End: /* find the last, most deeply nested visible item */ GridEntry item = (GridEntry)this.RootGridItem.GridItems[this.RootGridItem.GridItems.Count - 1]; while (item.Expandable && item.Expanded) { item = (GridEntry)item.GridItems[item.GridItems.Count - 1]; } this.SelectedGridItem = item; e.Handled = true; break; case Keys.Home: this.SelectedGridItem = (GridEntry)this.RootGridItem.GridItems[0]; e.Handled = true; break; } base.OnKeyDown(e); }
internal void CollapseItem(GridEntry item) { UpdateItem(this.SelectedGridItem); Invalidate(new Rectangle(0, item.Top, Width, Height - item.Top)); }
internal PropertyDescriptorGridEntry(PropertyGrid ownerGrid, GridEntry peParent, bool hide) : base(ownerGrid, peParent) { this.parensAroundName = 0xff; this.activeXHide = hide; }
internal PropertyDescriptorGridEntry(PropertyGrid ownerGrid, GridEntry peParent, System.ComponentModel.PropertyDescriptor propInfo, bool hide) : base(ownerGrid, peParent) { this.parensAroundName = 0xff; this.activeXHide = hide; this.Initialize(propInfo); }
/// <include file='doc\PropertyGrid.uex' path='docs/doc[@for="PropertyGrid.Dispose"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected override void Dispose(bool disposing) { if (disposing) { // Unhook IDesignerEventService.ActiveDesignerChanged event // if (GetFlag(GotDesignerEventService)) { Debug.Assert(designerEventService != null, "GetFlag(GotDesignerEventService) inconsistent with designerEventService == null"); if (designerEventService != null) { designerEventService.ActiveDesignerChanged -= new ActiveDesignerEventHandler(this.OnActiveDesignerChanged); } designerEventService = null; SetFlag(GotDesignerEventService, false); } this.ActiveDesigner = null; if (viewTabs != null) { for (int i = 0; i < viewTabs.Length; i++) { viewTabs[i].Dispose(); } viewTabs = null; } if (imageList != null) { for (int i = 0; i < imageList.Length; i++) { if(imageList[i] != null) { imageList[i].Dispose(); } } imageList = null; } if (bmpAlpha != null) { bmpAlpha.Dispose(); bmpAlpha = null; } if (bmpCategory != null) { bmpCategory.Dispose(); bmpCategory = null; } if (bmpPropPage != null) { bmpPropPage.Dispose(); bmpPropPage = null; } if (lineBrush != null) { lineBrush.Dispose(); lineBrush = null; } if (peMain != null) { peMain.Dispose(); peMain = null; } if (currentObjects != null) { currentObjects = null; SinkPropertyNotifyEvents(); } ClearCachedProps(); currentPropEntries = null; } base.Dispose(disposing); }
public static MultiPropertyDescriptorGridEntry[] GetMergedProperties(object[] rgobjs, GridEntry parentEntry, PropertySort sort, PropertyTab tab) { MultiPropertyDescriptorGridEntry[] result = null; try { int cLength = rgobjs.Length; object[] rgobjArgs = new object[1]; if ((sort & PropertySort.Alphabetical) != 0) { ArrayList props = GetCommonProperties(rgobjs, true, tab, parentEntry); MultiPropertyDescriptorGridEntry[] entries = new MultiPropertyDescriptorGridEntry[props.Count]; for (int i = 0; i < entries.Length; i++) { entries[i] = new MultiPropertyDescriptorGridEntry(parentEntry.OwnerGrid, parentEntry, rgobjs, (PropertyDescriptor[])props[i], false); } result = SortParenEntries(entries); } else { object[] sortObjs = new object[cLength - 1]; Array.Copy(rgobjs, 1, sortObjs, 0, cLength - 1); ArrayList props = GetCommonProperties(sortObjs, true, tab, parentEntry); // this'll work for just one as well ArrayList firstProps = GetCommonProperties(new object[] { rgobjs[0] }, false, tab, parentEntry); PropertyDescriptor[] firstPds = new PropertyDescriptor[firstProps.Count]; for (int i = 0; i < firstProps.Count; i++) { firstPds[i] = ((PropertyDescriptor[])firstProps[i])[0]; } props = UnsortedMerge(firstPds, props); MultiPropertyDescriptorGridEntry[] entries = new MultiPropertyDescriptorGridEntry[props.Count]; for (int i = 0; i < entries.Length; i++) { entries[i] = new MultiPropertyDescriptorGridEntry(parentEntry.OwnerGrid, parentEntry, rgobjs, (PropertyDescriptor[])props[i], false); } result = SortParenEntries(entries); } } catch { } return(result); }
internal SingleSelectRootGridEntry(PropertyGridView gridEntryHost, object value, GridEntry parent, IServiceProvider baseProvider, IDesignerHost host, PropertyTab tab, PropertySort sortType) : base(parent) { Debug.Assert(value != null, "Can't browse a null object!"); this.host = host; this.gridEntryHost = gridEntryHost; this.baseProvider = baseProvider; this.tab = tab; this.objValue = value; this.IsExpandable = true; // default to categories this.PropertySort = sortType; this.InternalExpanded = true; }
public ArrayElementGridEntry(PropertyGrid ownerGrid, GridEntry parent, int index) : base(ownerGrid, parent) { _index = index; SetFlag(Flags.RenderReadOnly, (parent.EntryFlags & Flags.RenderReadOnly) != 0 || parent.ForceReadOnly); }
public static MultiPropertyDescriptorGridEntry[] GetMergedProperties( object[] objects, GridEntry parentEntry, PropertySort sort, PropertyTab tab) { MultiPropertyDescriptorGridEntry[] result = null; try { int length = objects.Length; if ((sort & PropertySort.Alphabetical) != 0) { ArrayList commonProperties = GetCommonProperties(objects, presort: true, tab, parentEntry); var entries = new MultiPropertyDescriptorGridEntry[commonProperties.Count]; for (int i = 0; i < entries.Length; i++) { entries[i] = new MultiPropertyDescriptorGridEntry( parentEntry.OwnerGrid, parentEntry, objects, (PropertyDescriptor[])commonProperties[i], hide: false); } result = SortParenEntries(entries); } else { object[] sortObjects = new object[length - 1]; Array.Copy(objects, 1, sortObjects, 0, length - 1); ArrayList properties = GetCommonProperties(sortObjects, presort: true, tab, parentEntry); // This will work for just one as well. ArrayList firstProperties = GetCommonProperties(new object[] { objects[0] }, presort: false, tab, parentEntry); var firstPropertyDescriptors = new PropertyDescriptor[firstProperties.Count]; for (int i = 0; i < firstProperties.Count; i++) { firstPropertyDescriptors[i] = ((PropertyDescriptor[])firstProperties[i])[0]; } properties = UnsortedMerge(firstPropertyDescriptors, properties); var entries = new MultiPropertyDescriptorGridEntry[properties.Count]; for (int i = 0; i < entries.Length; i++) { entries[i] = new MultiPropertyDescriptorGridEntry( parentEntry.OwnerGrid, parentEntry, objects, (PropertyDescriptor[])properties[i], hide: false); } result = SortParenEntries(entries); } } catch { } return(result); }
internal void OnSelectedGridItemChanged(GridEntry oldEntry, GridEntry newEntry) { OnSelectedGridItemChanged(new SelectedGridItemChangedEventArgs(oldEntry, newEntry)); }
public CategoryInvokeProviderBehavior(PropertyGridCategoryProvider provider) : base(provider) { entry = (PGI.GridEntry)provider.entry; }
protected override void Dispose(bool disposing) { if (disposing) { host = null; baseProvider = null; tab = null; gridEntryHost = null; changeService = null; } this.objValue = null; this.objValueClassName = null; this.propDefault = null; base.Dispose(disposing); }
internal PropertyDescriptorGridEntry(PropertyGrid ownerGrid, GridEntry peParent, PropertyDescriptor propInfo, bool hide) : base(ownerGrid, peParent) { activeXHide = hide; Initialize(propInfo); }
private static ArrayList GetCommonProperties(object[] objects, bool presort, PropertyTab tab, GridEntry parentEntry) { var propertyCollections = new PropertyDescriptorCollection[objects.Length]; var attributes = new Attribute[parentEntry.BrowsableAttributes.Count]; parentEntry.BrowsableAttributes.CopyTo(attributes, 0); for (int i = 0; i < objects.Length; i++) { var properties = tab.GetProperties(parentEntry, objects[i], attributes); if (presort) { properties = properties.Sort(s_propertyComparer); } propertyCollections[i] = properties; } ArrayList mergedList = new(); var matchArray = new PropertyDescriptor[objects.Length]; // // Merge the property descriptors // int[] positions = new int[propertyCollections.Length]; for (int i = 0; i < propertyCollections[0].Count; i++) { PropertyDescriptor pivotProperty = propertyCollections[0][i]; bool match = pivotProperty.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute(); for (int j = 1; match && j < propertyCollections.Length; j++) { if (positions[j] >= propertyCollections[j].Count) { match = false; break; } // Check to see if we're on a match. PropertyDescriptor property = propertyCollections[j][positions[j]]; if (pivotProperty.Equals(property)) { positions[j] += 1; if (!property.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute()) { match = false; break; } matchArray[j] = property; continue; } int position = positions[j]; property = propertyCollections[j][position]; match = false; // If we aren't on a match, check all the items until we're past where the matching item would be. while (s_propertyComparer.Compare(property, pivotProperty) <= 0) { // Got a match! if (pivotProperty.Equals(property)) { if (!property.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute()) { match = false; position++; } else { match = true; matchArray[j] = property; positions[j] = position + 1; } break; } // Try again. position++; if (position < propertyCollections[j].Count) { property = propertyCollections[j][position]; } else { break; } } // If we got here, there is no match, quit for this one. if (!match) { positions[j] = position; break; } } // Do we have a match? if (match) { matchArray[0] = pivotProperty; mergedList.Add(matchArray.Clone()); } } return(mergedList); }
public static MultiPropertyDescriptorGridEntry[] GetMergedProperties(object[] rgobjs, GridEntry parentEntry, PropertySort sort, PropertyTab tab) { MultiPropertyDescriptorGridEntry[] entryArray = null; try { int length = rgobjs.Length; if ((sort & PropertySort.Alphabetical) != PropertySort.NoSort) { ArrayList list = GetCommonProperties(rgobjs, true, tab, parentEntry); MultiPropertyDescriptorGridEntry[] entryArray2 = new MultiPropertyDescriptorGridEntry[list.Count]; for (int k = 0; k < entryArray2.Length; k++) { entryArray2[k] = new MultiPropertyDescriptorGridEntry(parentEntry.OwnerGrid, parentEntry, rgobjs, (PropertyDescriptor[])list[k], false); } return(SortParenEntries(entryArray2)); } object[] destinationArray = new object[length - 1]; Array.Copy(rgobjs, 1, destinationArray, 0, length - 1); ArrayList sortedMergedEntries = GetCommonProperties(destinationArray, true, tab, parentEntry); ArrayList list3 = GetCommonProperties(new object[] { rgobjs[0] }, false, tab, parentEntry); PropertyDescriptor[] baseEntries = new PropertyDescriptor[list3.Count]; for (int i = 0; i < list3.Count; i++) { baseEntries[i] = ((PropertyDescriptor[])list3[i])[0]; } sortedMergedEntries = UnsortedMerge(baseEntries, sortedMergedEntries); MultiPropertyDescriptorGridEntry[] entries = new MultiPropertyDescriptorGridEntry[sortedMergedEntries.Count]; for (int j = 0; j < entries.Length; j++) { entries[j] = new MultiPropertyDescriptorGridEntry(parentEntry.OwnerGrid, parentEntry, rgobjs, (PropertyDescriptor[])sortedMergedEntries[j], false); } entryArray = SortParenEntries(entries); } catch { } return(entryArray); }
internal PropertyDescriptorGridEntry(PropertyGrid ownerGrid, GridEntry peParent, bool hide) : base(ownerGrid, peParent) { this.parensAroundName = 0xff; this.activeXHide = hide; }
public GridEntryAccessibleObject(GridEntry owner) : base() { Debug.Assert(owner != null, "GridEntryAccessibleObject must have a valid owner GridEntry"); this.owner = owner; }
public override void PaintValue(object val, Graphics g, Rectangle rect, Rectangle clipRect, GridEntry.PaintValueFlags paintFlags) { base.PaintValue(val, g, rect, clipRect, paintFlags & ~GridEntry.PaintValueFlags.DrawSelected); if (base.parentPE.GetChildIndex(this) > 0) { g.DrawLine(SystemPens.Control, (int) (rect.X - 2), (int) (rect.Y - 1), (int) (rect.Width + 1), (int) (rect.Y - 1)); } }
public override object GetChildValueOwner(GridEntry childEntry) => _mergedDescriptor.PropertyType.IsValueType || (EntryFlags & Flags.Immutable) != 0 ? base.GetChildValueOwner(childEntry) : _mergedDescriptor.GetValues(_objects);
public GridEntryAccessibleObject(GridEntry owner) : base() { Debug.Assert(owner is not null, "GridEntryAccessibleObject must have a valid owner GridEntry"); _owningGridEntry = owner; }
internal int GetEntry(GridEntry child) { return(Array.IndexOf(entries, child)); }
internal ImmutablePropertyDescriptorGridEntry(PropertyGrid ownerGrid, GridEntry peParent, PropertyDescriptor propInfo, bool hide) : base(ownerGrid, peParent, propInfo, hide) { }
internal GridEntry GetDefaultGridEntry() { if (peDefault == null && currentPropEntries != null) { peDefault = (GridEntry)currentPropEntries[0]; } return peDefault; }
internal void CategorizePropEntries() { if (Children.Count > 0) { GridEntry[] childEntries = new GridEntry[this.Children.Count]; this.Children.CopyTo(childEntries, 0); if ((this.PropertySort & PropertySort.Categorized) != 0) { // first, walk through all the entires and // group them by their category by adding // them to a hashtable of arraylists. // Hashtable bins = new Hashtable(); for (int i = 0; i < childEntries.Length; i++) { GridEntry pe = childEntries[i]; string category = pe.PropertyCategory; ArrayList bin = (ArrayList)bins[category]; if (bin == null) { bin = new ArrayList(); bins[category] = bin; } bin.Add(pe); } // now walk through the hashtable // and create a categorygridentry for each // category that holds all the properties // of that category. // ArrayList propList = new ArrayList(); IDictionaryEnumerator enumBins = (IDictionaryEnumerator)bins.GetEnumerator(); while (enumBins.MoveNext()) { ArrayList bin = (ArrayList)enumBins.Value; if (bin != null) { string category = (string)enumBins.Key; if (bin.Count > 0) { GridEntry[] rgpes = new GridEntry[bin.Count]; bin.CopyTo(rgpes, 0); try { propList.Add(new CategoryGridEntry(this, category, rgpes)); } catch (Exception) { } } } } childEntries = new GridEntry[propList.Count]; propList.CopyTo(childEntries, 0); StringSorter.Sort(childEntries); ChildCollection.Clear(); ChildCollection.AddRange(childEntries); } } }
internal void UpdateSelection() { if (!GetFlag(PropertiesChanged)) { return; } if (viewTabs == null) { return; } string tabName = viewTabs[selectedViewTab].TabName + propertySortValue.ToString(); if (viewTabProps != null && viewTabProps.ContainsKey(tabName)) { peMain = (GridEntry)viewTabProps[tabName]; if (peMain != null) { peMain.Refresh(); } } else { if (currentObjects != null && currentObjects.Length > 0) { peMain = (GridEntry)GridEntry.Create(gridView, currentObjects, new PropertyGridServiceProvider(this), designerHost, this.SelectedTab, propertySortValue); } else { peMain = null; } if (peMain == null) { currentPropEntries = new GridEntryCollection(null, new GridEntry[0]); gridView.ClearProps(); return; } if (BrowsableAttributes != null) { peMain.BrowsableAttributes = BrowsableAttributes; } if (viewTabProps == null) { viewTabProps = new Hashtable(); } viewTabProps[tabName] = peMain; } // get entries. currentPropEntries = peMain.Children; peDefault = peMain.DefaultChild; gridView.Invalidate(); }
public override object GetChildValueOwner(GridEntry childEntry) { return(ParentGridEntry.GetChildValueOwner(childEntry)); }
internal void CategorizePropEntries() { if (Children.Count > 0) { GridEntry[] childEntries = new GridEntry[this.Children.Count]; this.Children.CopyTo(childEntries, 0); if ((this.PropertySort & PropertySort.Categorized) != 0) { // first, walk through all the entires and // group them by their category by adding // them to a hashtable of arraylists. // Hashtable bins = new Hashtable(); for (int i = 0; i < childEntries.Length; i++) { GridEntry pe = childEntries[i]; Debug.Assert(pe != null); if (pe != null) { string category = pe.PropertyCategory; ArrayList bin = (ArrayList)bins[category]; if (bin == null) { bin = new ArrayList(); bins[category] = bin; } bin.Add(pe); } } // now walk through the hashtable // and create a categorygridentry for each // category that holds all the properties // of that category. // ArrayList propList = new ArrayList(); IDictionaryEnumerator enumBins = (IDictionaryEnumerator)bins.GetEnumerator(); while (enumBins.MoveNext()) { ArrayList bin = (ArrayList)enumBins.Value; if (bin != null) { string category = (string)enumBins.Key; if (bin.Count > 0) { GridEntry[] rgpes = new GridEntry[bin.Count]; bin.CopyTo(rgpes, 0); try { propList.Add(new CategoryGridEntry(this.ownerGrid, this, category, rgpes)); } catch { } } } } childEntries = new GridEntry[propList.Count]; propList.CopyTo(childEntries, 0); StringSorter.Sort(childEntries); ChildCollection.Clear(); ChildCollection.AddRange(childEntries); } } }
internal override bool NotifyChildValue(GridEntry pe, int type) { return(parentPE.NotifyChildValue(pe, type)); }
protected virtual void NotifyParentChange(GridEntry ge) { while (((ge != null) && (ge is PropertyDescriptorGridEntry)) && ((PropertyDescriptorGridEntry) ge).propertyInfo.Attributes.Contains(NotifyParentPropertyAttribute.Yes)) { object valueOwner = ge.GetValueOwner(); bool isValueType = valueOwner.GetType().IsValueType; while ((!(ge is PropertyDescriptorGridEntry) || isValueType) ? valueOwner.Equals(ge.GetValueOwner()) : (valueOwner == ge.GetValueOwner())) { ge = ge.ParentGridEntry; if (ge == null) { break; } } if (ge != null) { valueOwner = ge.GetValueOwner(); IComponentChangeService componentChangeService = this.ComponentChangeService; if (componentChangeService != null) { componentChangeService.OnComponentChanging(valueOwner, ((PropertyDescriptorGridEntry) ge).propertyInfo); componentChangeService.OnComponentChanged(valueOwner, ((PropertyDescriptorGridEntry) ge).propertyInfo, null, null); } ge.ClearCachedValues(false); PropertyGridView gridEntryHost = this.GridEntryHost; if (gridEntryHost != null) { gridEntryHost.InvalidateGridEntryValue(ge); } } } }
public GridEntryCollection(GridEntry owner, GridEntry[] entries) : base(entries) { _owner = owner; }
internal PropertyDescriptorGridEntry(PropertyGrid ownerGrid, GridEntry peParent, System.ComponentModel.PropertyDescriptor propInfo, bool hide) : base(ownerGrid, peParent) { this.parensAroundName = 0xff; this.activeXHide = hide; this.Initialize(propInfo); }
internal int GetEntry(GridEntry child) => Array.IndexOf(_entries, child);
public CategoryGridEntry (PropertyGrid owner, string category, GridEntry parent) : base (owner, parent) { label = category; }
public CategoryGridEntry(PropertyGrid owner, string category, GridEntry parent) : base(owner, parent) { label = category; }
internal ImmutablePropertyDescriptorGridEntry(PropertyGrid ownerGrid, GridEntry peParent, PropertyDescriptor propInfo, bool hide) : base(ownerGrid, peParent, propInfo, hide) { }
public override object GetChildValueOwner(GridEntry childEntry) { return this.ParentGridEntry.GetChildValueOwner(childEntry); }
internal override bool NotifyChildValue(GridEntry pe, int type) { return base.parentPE.NotifyChildValue(pe, type); }
// Cannot use one PropertyDescriptor for all owners, because the // propertydescriptors might have different Invokees. Check // ReflectionPropertyDescriptor.GetInvokee and how it's used. // public GridEntry (PropertyGrid propertyGrid, PropertyDescriptor[] properties, GridEntry parent) : this (propertyGrid, parent) { if (properties == null || properties.Length == 0) throw new ArgumentNullException ("prop_desc"); property_descriptors = properties; }