Beispiel #1
0
 //"outlineView:isItemExpandable:"
 public override bool ItemExpandable(NSOutlineView outlineView, NSObject item)
 {
     //Console.WriteLine ("ItemExpandable:item{0},", item);
     if (item == null || outlineView.GetParent(item) == null)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #2
0
        //"outlineView:isItemExpandable:"
        public override bool ItemExpandable(NSOutlineView outlineView, NSObject item)
        {
//			if (item == null)
//				return false;

            if (item == null || outlineView.GetParent(item) == null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
 /// <summary>
 /// Shoulds the select item.
 /// </summary>
 /// <returns><c>true</c>, if select item was shoulded, <c>false</c> otherwise.</returns>
 /// <param name="outlineView">Outline view.</param>
 /// <param name="item">Item.</param>
 public override bool ShouldSelectItem(NSOutlineView outlineView, Foundation.NSObject item)
 {
     return(outlineView.GetParent(item) != null);
 }
		/// <summary>
		/// Shoulds the select item.
		/// </summary>
		/// <returns><c>true</c>, if select item was shoulded, <c>false</c> otherwise.</returns>
		/// <param name="outlineView">Outline view.</param>
		/// <param name="item">Item.</param>
		public override bool ShouldSelectItem (NSOutlineView outlineView, Foundation.NSObject item)
		{
			return (outlineView.GetParent (item) != null);
		}
        public override NSView GetView(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item)
        {
            GetVMGroupCellItendifiterFromFacade(item, out EditorViewModel evm, out PanelGroupViewModel group, out var cellIdentifier);

            if (group != null)
            {
                var categoryContainer = (CategoryContainerControl)outlineView.MakeView(CategoryIdentifier, this);
                if (categoryContainer == null)
                {
                    categoryContainer = new CategoryContainerControl(this.hostResources, outlineView)
                    {
                        Identifier = CategoryIdentifier,
                        TableView  = outlineView,
                    };
                }

                ((UnfocusableTextField)categoryContainer.Subviews[1]).StringValue = group.Category;

                if (this.dataSource.DataContext.GetIsExpanded(group.Category))
                {
                    SynchronizationContext.Current.Post(s => {
                        outlineView.ExpandItem(item);
                    }, null);
                }

                return(categoryContainer);
            }

            NSView editorOrContainer = null;

            if (this.firstCache.TryGetValue(cellIdentifier, out IEditorView editor))
            {
                this.firstCache.Remove(cellIdentifier);
                editorOrContainer = (editor.NativeView is PropertyEditorControl) ? new EditorContainer(this.hostResources, editor)
                {
                    Identifier = cellIdentifier
                } : editor.NativeView;
            }
            else
            {
                editorOrContainer = GetEditor(cellIdentifier, evm, outlineView);
                editor            = ((editorOrContainer as EditorContainer)?.EditorView) ?? editorOrContainer as IEditorView;
            }

            if (editorOrContainer is EditorContainer ec)
            {
                ec.ViewModel = evm;
                ec.Label     = evm.Name;

#if DEBUG // Currently only used to highlight which controls haven't been implemented
                if (editor == null)
                {
                    ec.LabelTextColor = NSColor.Red;
                }
#endif
            }

            if (editor != null)
            {
                var ovm = evm as ObjectPropertyViewModel;
                if (ovm != null && editorOrContainer is EditorContainer container)
                {
                    if (container.LeftEdgeView == null)
                    {
                        if (ovm.CanDelve)
                        {
                            container.LeftEdgeView = outlineView.MakeView("NSOutlineViewDisclosureButtonKey", outlineView);
                        }
                    }
                    else if (!ovm.CanDelve)
                    {
                        container.LeftEdgeView = null;
                    }
                }
                else if (!(editorOrContainer is EditorContainer))
                {
                    editor.ViewModel = evm;
                }

                bool openObjectRow = ovm != null && outlineView.IsItemExpanded(item);
                if (!openObjectRow)
                {
                    var parent = outlineView.GetParent(item);
                    openObjectRow = (parent != null && ((NSObjectFacade)parent).Target is ObjectPropertyViewModel);
                }

                SetRowValueBackground(editorOrContainer, openObjectRow);

                // Force a row update due to new height, but only when we are non-default
                if (editor.IsDynamicallySized)
                {
                    nint index = outlineView.RowForItem(item);
                    outlineView.NoteHeightOfRowsWithIndexesChanged(new NSIndexSet(index));
                }
            }
            else if (editorOrContainer is PanelHeaderEditorControl header)
            {
                header.ViewModel = this.dataSource.DataContext;
            }

            return(editorOrContainer);
        }