protected override void OnRemoveEditors(IEnumerable <EditorViewModel> editors) { foreach (EditorViewModel vm in editors) { string g = GetGroup(vm); var grouping = this.arranged[g] as ObservableGrouping <string, EditorViewModel>; if (grouping != null) { this.arranged.Remove(g, vm); } } ArrangedPropertiesChanged?.Invoke(this, EventArgs.Empty); }
protected override void OnClearProperties() { this.arranged.Clear(); ArrangedPropertiesChanged?.Invoke(this, EventArgs.Empty); }
protected override void OnAddEditors(IEnumerable <EditorViewModel> editors) { IEnumerable <EditorViewModel> props = Properties; if (!String.IsNullOrWhiteSpace(FilterText)) { props = props.Where(MatchesFilter); } props = props.OrderBy(vm => vm.Name); Dictionary <string, List <PropertyViewModel> > groupedTypeProperties = null; this.arranged.Clear(); foreach (var grouping in props.GroupBy(GetGroup).OrderBy(g => g.Key, CategoryComparer.Instance)) { HashSet <EditorViewModel> remainingItems = null; if (ArrangeMode == PropertyArrangeMode.Category) { foreach (EditorViewModel editorVm in grouping) { var vm = editorVm as PropertyViewModel; if (vm != null && TargetPlatform.GroupedTypes != null && TargetPlatform.GroupedTypes.TryGetValue(vm.Property.Type, out string category)) { if (remainingItems == null) { remainingItems = new HashSet <EditorViewModel> (grouping); } remainingItems.Remove(vm); if (groupedTypeProperties == null) { groupedTypeProperties = new Dictionary <string, List <PropertyViewModel> > (); } if (!groupedTypeProperties.TryGetValue(category, out List <PropertyViewModel> group)) { groupedTypeProperties[category] = group = new List <PropertyViewModel> (); } group.Add(vm); } } } if (remainingItems != null) { this.arranged.Add(grouping.Key, remainingItems); } else { this.arranged.Add(grouping); } } if (groupedTypeProperties != null) // Insert type-grouped properties back in sorted. { int i = 0; foreach (var kvp in groupedTypeProperties.OrderBy(kvp => kvp.Key, CategoryComparer.Instance)) { var group = new ObservableGrouping <string, EditorViewModel> (kvp.Key) { new PropertyGroupViewModel(TargetPlatform, kvp.Key, kvp.Value, ObjectEditors) }; for (; i < this.arranged.Count; i++) { var g = (IGrouping <string, EditorViewModel>) this.arranged[i]; // TODO: Are we translating categories? If so this needs to lookup the resource and be culture specific if (g.Key == null) // nulls go on the bottom. { this.arranged.Insert(i, group); break; } else if (String.Compare(g.Key, kvp.Key, StringComparison.Ordinal) > 0) { this.arranged.Insert(i++, group); break; } } } } ArrangedPropertiesChanged?.Invoke(this, EventArgs.Empty); }