diff options
author | Eric Maupin <ermaup@microsoft.com> | 2018-11-28 22:15:18 +0300 |
---|---|---|
committer | Eric Maupin <ermaup@microsoft.com> | 2018-12-11 00:08:45 +0300 |
commit | 10f7d6c6f419396f0d7ce0d250ef285fbec932c9 (patch) | |
tree | b343eeda1328af9f4b7f6566fc44ed878d28b08d | |
parent | f22ae3a071a71de08754838f255a396c20d02f1a (diff) |
[mac] Make compatible with uncommon changes
-rw-r--r-- | Xamarin.PropertyEditing.Mac/PropertyTableDataSource.cs | 23 | ||||
-rw-r--r-- | Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs | 29 |
2 files changed, 31 insertions, 21 deletions
diff --git a/Xamarin.PropertyEditing.Mac/PropertyTableDataSource.cs b/Xamarin.PropertyEditing.Mac/PropertyTableDataSource.cs index 2334a6e..da40034 100644 --- a/Xamarin.PropertyEditing.Mac/PropertyTableDataSource.cs +++ b/Xamarin.PropertyEditing.Mac/PropertyTableDataSource.cs @@ -30,12 +30,14 @@ namespace Xamarin.PropertyEditing.Mac var childCount = 0; if (this.vm.ArrangeMode == PropertyArrangeMode.Name) - childCount = Filtering ? this.vm.ArrangedEditors[0].Count : this.vm.ArrangedEditors[0].Count + 1; + childCount = Filtering ? this.vm.ArrangedEditors[0].Editors.Count : this.vm.ArrangedEditors[0].Editors.Count + 1; else { if (item == null) childCount = Filtering ? this.vm.ArrangedEditors.Count : this.vm.ArrangedEditors.Count + 1; - else - childCount = ((IGroupingList<string, EditorViewModel>)((NSObjectFacade)item).Target).Count; + else { + var group = (PanelGroupViewModel)((NSObjectFacade)item).Target; + childCount = group.Editors.Count + group.UncommonEditors.Count; + } } return childCount; @@ -50,12 +52,19 @@ namespace Xamarin.PropertyEditing.Mac element = null; else { if (this.vm.ArrangeMode == PropertyArrangeMode.Name) - element = Filtering ? this.vm.ArrangedEditors[0][(int)childIndex] : this.vm.ArrangedEditors[0][(int)childIndex - 1]; + element = Filtering ? this.vm.ArrangedEditors[0].Editors[(int)childIndex] : this.vm.ArrangedEditors[0].Editors[(int)childIndex - 1]; else { if (item == null) element = Filtering ? this.vm.ArrangedEditors[(int)childIndex] : this.vm.ArrangedEditors[(int)childIndex - 1]; else { - element = ((IGroupingList<string, EditorViewModel>)((NSObjectFacade)item).Target)[(int)childIndex]; + var group = (PanelGroupViewModel)((NSObjectFacade)item).Target; + var list = group.Editors; + if (childIndex >= list.Count) { + childIndex -= list.Count; + list = group.UncommonEditors; + } + + element = list[(int)childIndex]; } } } @@ -68,13 +77,13 @@ namespace Xamarin.PropertyEditing.Mac if (this.vm.ArrangeMode == PropertyArrangeMode.Name) return false; - return ((NSObjectFacade)item).Target is IGroupingList<string, EditorViewModel>; + return ((NSObjectFacade)item).Target is PanelGroupViewModel; } public NSObject GetFacade (object element) { NSObject facade; - if (element is IGrouping<string, PropertyViewModel>) { + if (element is PanelGroupViewModel) { if (!this.groupFacades.TryGetValue (element, out facade)) { this.groupFacades[element] = facade = new NSObjectFacade (element); } diff --git a/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs b/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs index 471d1d4..7a0209a 100644 --- a/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs +++ b/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs @@ -24,12 +24,12 @@ namespace Xamarin.PropertyEditing.Mac if (!String.IsNullOrWhiteSpace (this.dataSource.DataContext.FilterText)) { outlineView.ExpandItem (null, true); } else { - foreach (IGrouping<string, EditorViewModel> g in this.dataSource.DataContext.ArrangedEditors) { + foreach (PanelGroupViewModel g in this.dataSource.DataContext.ArrangedEditors) { NSObject item; if (!this.dataSource.TryGetFacade (g, out item)) continue; - if (this.dataSource.DataContext.GetIsExpanded (g.Key)) + if (this.dataSource.DataContext.GetIsExpanded (g.Category)) outlineView.ExpandItem (item); else outlineView.CollapseItem (item); @@ -41,7 +41,8 @@ namespace Xamarin.PropertyEditing.Mac public override NSView GetView (NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item) { EditorViewModel evm; - IGroupingList<string, EditorViewModel> group; + PropertyViewModel vm; + PanelGroupViewModel group; string cellIdentifier; GetVMGroupCellItendifiterFromFacade (item, out evm, out group, out cellIdentifier); @@ -53,9 +54,9 @@ namespace Xamarin.PropertyEditing.Mac }; } - labelContainer.StringValue = group.Key; + labelContainer.StringValue = group.Category; - if (this.dataSource.DataContext.GetIsExpanded (group.Key)) { + if (this.dataSource.DataContext.GetIsExpanded (group.Category)) { SynchronizationContext.Current.Post (s => { outlineView.ExpandItem (item); }, null); @@ -103,7 +104,7 @@ namespace Xamarin.PropertyEditing.Mac public override bool ShouldSelectItem (NSOutlineView outlineView, NSObject item) { - return (!(item is NSObjectFacade) || !(((NSObjectFacade)item).Target is IGroupingList<string, EditorViewModel>)); + return (!(item is NSObjectFacade) || !(((NSObjectFacade)item).Target is PanelGroupViewModel)); } public override void ItemDidExpand (NSNotification notification) @@ -112,9 +113,9 @@ namespace Xamarin.PropertyEditing.Mac return; NSObjectFacade facade = notification.UserInfo.Values[0] as NSObjectFacade; - var group = facade.Target as IGroupingList<string, EditorViewModel>; + var group = facade.Target as PanelGroupViewModel; if (group != null) - this.dataSource.DataContext.SetIsExpanded (group.Key, isExpanded: true); + this.dataSource.DataContext.SetIsExpanded (group.Category, isExpanded: true); } public override void ItemDidCollapse (NSNotification notification) @@ -123,15 +124,15 @@ namespace Xamarin.PropertyEditing.Mac return; NSObjectFacade facade = notification.UserInfo.Values[0] as NSObjectFacade; - var group = facade.Target as IGroupingList<string, EditorViewModel>; + var group = facade.Target as PanelGroupViewModel; if (group != null) - this.dataSource.DataContext.SetIsExpanded (group.Key, isExpanded: false); + this.dataSource.DataContext.SetIsExpanded (group.Category, isExpanded: false); } public override nfloat GetRowHeight (NSOutlineView outlineView, NSObject item) { EditorViewModel vm; - IGroupingList<string, EditorViewModel> group; + PanelGroupViewModel group; string cellIdentifier; GetVMGroupCellItendifiterFromFacade (item, out vm, out group, out cellIdentifier); @@ -211,14 +212,14 @@ namespace Xamarin.PropertyEditing.Mac return new PanelHeaderEditorControl (); } - private void GetVMGroupCellItendifiterFromFacade (NSObject item, out EditorViewModel vm, out IGroupingList<string, EditorViewModel> group, out string cellIdentifier) + private void GetVMGroupCellItendifiterFromFacade (NSObject item, out EditorViewModel vm, out PanelGroupViewModel group, out string cellIdentifier) { var facade = (NSObjectFacade)item; vm = facade.Target as EditorViewModel; - group = facade.Target as IGroupingList<string, EditorViewModel>; + group = facade.Target as PanelGroupViewModel; cellIdentifier = facade.Target == null ? nameof (PanelHeaderEditorControl) - : (group == null) ? vm.GetType ().FullName : group.Key; + : (group == null) ? vm.GetType ().FullName : group.Category; } } } |