예제 #1
0
		// private static void PrintDebugInfo (GridEntry item)
		// {
       		// 	if (item.PropertyDescriptor != null) {
       		// 		Console.WriteLine ("=== [" + item.PropertyDescriptor.Name + "] ===");
		// 		try {
		// 			TypeConverter converter = item.GetConverter ();
		// 			Console.WriteLine ("IsReadOnly: " + item.IsReadOnly);
		// 			Console.WriteLine ("IsEditable: " + item.IsEditable);
		// 			Console.WriteLine ("PropertyDescriptor.IsReadOnly: " + item.PropertyDescriptor.IsReadOnly);
		// 			if (item.ParentEntry != null)
		// 				Console.WriteLine ("ParentEntry.IsReadOnly: " + item.ParentEntry.IsReadOnly);
		// 			Console.WriteLine ("ImmutableObjectAttribute.Yes: " + TypeDescriptor.GetAttributes (item.PropertyDescriptor.PropertyType)
		// 					   [typeof(ImmutableObjectAttribute)].Equals (ImmutableObjectAttribute.Yes));
		// 			UITypeEditor editor = item.GetEditor ();
		// 			Console.WriteLine ("Editor: " + (editor == null ? "none" : editor.GetType ().Name));
		// 			if (editor != null)
		// 				Console.WriteLine ("Editor.EditorStyle: " + editor.GetEditStyle ((ITypeDescriptorContext)item));
		// 			Console.WriteLine ("Converter: " + (converter == null ? "none" : converter.GetType ().Name));
		// 			if (converter != null) {
		// 				Console.WriteLine ("Converter.GetStandardValuesSupported: " + converter.GetStandardValuesSupported ((ITypeDescriptorContext)item).ToString ());
		// 				Console.WriteLine ("Converter.GetStandardValuesExclusive: " + converter.GetStandardValuesExclusive ((ITypeDescriptorContext)item).ToString ());
		// 				Console.WriteLine ("ShouldCreateParentInstance: " + item.ShouldCreateParentInstance);
		// 				Console.WriteLine ("CanConvertFrom (string): " + converter.CanConvertFrom ((ITypeDescriptorContext)item, typeof (string)));
		// 			}
		// 			Console.WriteLine ("IsArray: " + item.PropertyDescriptor.PropertyType.IsArray.ToString ());
		// 		} catch { /* Some converters and editor throw NotImplementedExceptions */ }
		// 	}
		// }

		private GridItemCollection GetChildGridItems ()
		{
			object[] propertyOwners = this.Values;
			string[] propertyNames = GetMergedPropertyNames (propertyOwners);
			GridItemCollection items = new GridItemCollection ();

			foreach (string propertyName in propertyNames) {
				PropertyDescriptor[] properties = new PropertyDescriptor[propertyOwners.Length];
				for (int i=0; i < propertyOwners.Length; i++)
					properties[i] = GetPropertyDescriptor (propertyOwners[i], propertyName);
				items.Add (new GridEntry (property_grid, properties, this));
			}

			return items;
		}
예제 #2
0
		private void UpdateSortLayout (GridEntry rootItem)
		{
			if (rootItem == null)
				return;

			GridItemCollection reordered = new GridItemCollection ();

			if (property_sort == PropertySort.Alphabetical || property_sort == PropertySort.NoSort) {
				alphabetic_toolbarbutton.Pushed = true;
				categorized_toolbarbutton.Pushed = false;
				foreach (GridItem item in rootItem.GridItems) {
					if (item.GridItemType == GridItemType.Category) {
						foreach (GridItem categoryChild in item.GridItems) {
							reordered.Add (categoryChild);
							((GridEntry)categoryChild).SetParent (rootItem);
						}
					} else {
						reordered.Add (item);
					}
				}
			} else if (property_sort == PropertySort.Categorized || 
				   property_sort == PropertySort.CategorizedAlphabetical) {
				alphabetic_toolbarbutton.Pushed = false;
				categorized_toolbarbutton.Pushed = true;
				GridItemCollection categories = new GridItemCollection ();

				foreach (GridItem item in rootItem.GridItems) {
					if (item.GridItemType == GridItemType.Category) {
						categories.Add (item);
						continue;
					}

					string categoryName = item.PropertyDescriptor.Category;
					if (categoryName == null)
						categoryName = UNCATEGORIZED_CATEGORY_LABEL;
					GridItem category_item = rootItem.GridItems [categoryName];
					if (category_item == null)
						category_item = categories [categoryName];

					if (category_item == null) {
						// Create category grid items if they already don't
						category_item = new CategoryGridEntry (this, categoryName, rootItem);
						category_item.Expanded = true;
						categories.Add (category_item);
					}

					category_item.GridItems.Add (item);
					((GridEntry)item).SetParent (category_item);
				}

				reordered.AddRange (categories);
			}

			rootItem.GridItems.Clear ();
			rootItem.GridItems.AddRange (reordered);
		}