public override bool ItemExpandable (NSOutlineView outlineView, NSObject item) { if (item != null) { try { if (item is DirectoryNode) { DirectoryNode node = item as DirectoryNode; node.PopulateChildren (node.Name); return (node.NumberOfChildren () != 0); } else if (item is ScopeNode) { ScopeNode passedNode = item as ScopeNode; // cast to appropriate type of node return (passedNode.NumberOfChildren () != 0); } else { System.Diagnostics.Debug.WriteLine ("passedNode cast failed."); return false; } } catch (Exception e) { System.Diagnostics.Debug.WriteLine (e.Message); return false; } } else { // if null, it's asking about the root element return true; } }
public override NSCell GetCell(NSOutlineView view, NSTableColumn column, MonoMac.Foundation.NSObject item) { NSCmisTree cmis = item as NSCmisTree; if (cmis == null) { Console.WriteLine ("GetCell Error"); return null; } if (column == null) { return null; } else if (column.Identifier.Equals ("Name")) { // Console.WriteLine ("GetCell " + cmis); NSButtonCell cell = new NSButtonCell (); if (cmis.Parent != null) cell.SetButtonType (NSButtonType.Switch); else cell.SetButtonType (NSButtonType.Radio); // FIXME cell.AllowsMixedState = true; cell.Title = cmis.Name; cell.Editable = true; return cell; } else { NSTextFieldCell cell = new NSTextFieldCell (); return cell; } }
public NSView GetViewForItem(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item) { var libraryBrowserItem = (LibraryBrowserItem)item; var view = (NSTableCellView)outlineView.MakeView("cellLibrary", this); view.TextField.Font = NSFont.FromFontName("Roboto", 11); view.TextField.StringValue = libraryBrowserItem.Entity.Title; switch (libraryBrowserItem.Entity.EntityType) { case LibraryBrowserEntityType.AllSongs: view.ImageView.Image = ImageResources.Images.FirstOrDefault(x => x.Name == "icon_artists"); break; case LibraryBrowserEntityType.Artists: view.ImageView.Image = ImageResources.Images.FirstOrDefault(x => x.Name == "icon_artists"); break; case LibraryBrowserEntityType.Album: case LibraryBrowserEntityType.Albums: case LibraryBrowserEntityType.ArtistAlbum: view.ImageView.Image = ImageResources.Images.FirstOrDefault(x => x.Name == "icon_vinyl"); break; case LibraryBrowserEntityType.Artist: view.ImageView.Image = ImageResources.Images.FirstOrDefault(x => x.Name == "icon_user"); break; } return view; }
// This sets up a NSOutlineView for demonstration internal static NSView SetupOutlineView (CGRect frame) { // Create our NSOutlineView and set it's frame to a reasonable size. It will be autosized via the NSClipView NSOutlineView outlineView = new NSOutlineView () { Frame = frame }; // Every NSOutlineView must have at least one column or your Delegate will not be called. NSTableColumn column = new NSTableColumn ("Values"); outlineView.AddColumn (column); // You must set OutlineTableColumn or the arrows showing children/expansion will not be drawn outlineView.OutlineTableColumn = column; // Setup the Delegate/DataSource instances to be interrogated for data and view information // In Unified, these take an interface instead of a base class and you can combine these into // one instance. outlineView.Delegate = new OutlineViewDelegate (); outlineView.DataSource = new OutlineViewDataSource (); // NSOutlineView expects to be hosted inside an NSClipView and won't draw correctly otherwise NSClipView clipView = new NSClipView (frame) { AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable }; clipView.DocumentView = outlineView; return clipView; }
public override NSView GetView (NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item) { // Cast item var product = item as Product; // This pattern allows you reuse existing views when they are no-longer in use. // If the returned view is null, you instance up a new view // If a non-null view is returned, you modify it enough to reflect the new data NSTableCellView view = (NSTableCellView)outlineView.MakeView (tableColumn.Title, this); if (view == null) { view = new NSTableCellView (); if (tableColumn.Title == "Product") { view.ImageView = new NSImageView (new CGRect (0, 0, 16, 16)); view.AddSubview (view.ImageView); view.TextField = new NSTextField (new CGRect (20, 0, 400, 16)); } else { view.TextField = new NSTextField (new CGRect (0, 0, 400, 16)); } view.TextField.AutoresizingMask = NSViewResizingMask.WidthSizable; view.AddSubview (view.TextField); view.Identifier = tableColumn.Title; view.TextField.BackgroundColor = NSColor.Clear; view.TextField.Bordered = false; view.TextField.Selectable = false; view.TextField.Editable = !product.IsProductGroup; } // Tag view view.TextField.Tag = outlineView.RowForItem (item); // Allow for edit view.TextField.EditingEnded += (sender, e) => { // Grab product var prod = outlineView.ItemAtRow(view.Tag) as Product; // Take action based on type switch(view.Identifier) { case "Product": prod.Title = view.TextField.StringValue; break; case "Details": prod.Description = view.TextField.StringValue; break; } }; // Setup view based on the column selected switch (tableColumn.Title) { case "Product": view.ImageView.Image = NSImage.ImageNamed (product.IsProductGroup ? "tags.png" : "tag.png"); view.TextField.StringValue = product.Title; break; case "Details": view.TextField.StringValue = product.Description; break; } return view; }
/// <summary> /// Gets the child. /// </summary> /// <returns>The child.</returns> /// <param name="outlineView">Outline view.</param> /// <param name="childIndex">Child index.</param> /// <param name="item">Item.</param> public override NSObject GetChild (NSOutlineView outlineView, nint childIndex, Foundation.NSObject item) { if (item == null) { return Items [(int)childIndex]; } else { return ((SourceListItem)item) [(int)childIndex]; } }
/// <summary> /// Gets the children count. /// </summary> /// <returns>The children count.</returns> /// <param name="outlineView">Outline view.</param> /// <param name="item">Item.</param> public override nint GetChildrenCount (NSOutlineView outlineView, Foundation.NSObject item) { if (item == null) { return Items.Count; } else { return ((SourceListItem)item).Count; } }
public override NSObject GetObjectValue (NSOutlineView outlineView, NSTableColumn forTableColumn, NSObject byItem) { TreeDataNode nodeItem = byItem as TreeDataNode; if (nodeItem == null) return null; return (NSString)nodeItem.CombinedName; }
public override bool ItemExpandable (NSOutlineView outlineView, NSObject item) { var result = item as ResultWrapper; if (result != null) return result.HasChildren; else return false; }
public override void WillDisplayCell (NSOutlineView outlineView, NSObject cell, NSTableColumn tableColumn, NSObject item) { var textCell = cell as MacImageListItemCell; if (textCell != null) { textCell.UseTextShadow = true; textCell.SetGroupItem (this.IsGroupItem (outlineView, item), outlineView, NSFont.SmallSystemFontSize, NSFont.SmallSystemFontSize); } }
public override bool IsGroupItem(NSOutlineView outlineView, NSObject item) { if (((SidebarListItem)item).IsHeader) { return true; } else { return false; } }
public override nint GetChildrenCount (NSOutlineView outlineView, NSObject item) { if (item == null) { return Products.Count; } else { return ((Product)item).Products.Count; } }
public override NSObject GetChild (NSOutlineView outlineView, nint childIndex, NSObject item) { if (item == null) { return Products [(int)childIndex]; } else { return ((Product)item).Products [(int)childIndex]; } }
public override bool ItemExpandable (NSOutlineView outlineView, NSObject item) { if (item == null) { return Products [0].IsProductGroup; } else { return ((Product)item).IsProductGroup; } }
public override int GetChildrenCount(NSOutlineView outlineView, NSObject item) { if (item == null) { return rootItems.Count; } else { return ((SidebarListItem)item).Children.Count; } }
public override NSObject GetChild(NSOutlineView outlineView, int childIndex, NSObject ofItem) { if (ofItem != null) { return ((SidebarListItem)ofItem).Children [childIndex]; } else { return rootItems [childIndex]; } }
public override int GetChildrenCount (NSOutlineView outlineView, NSObject item) { if (item is TreeDataNode) { TreeDataNode nodeItem = item as TreeDataNode; return nodeItem.Nodes.Count; } return _nodes.Count; }
public override NSObject GetChild (NSOutlineView outlineView, int childIndex, NSObject ofItem) { TreeDataNode nodeItem = ofItem as TreeDataNode; if (nodeItem != null) { return nodeItem.Nodes [childIndex]; } return Nodes[childIndex]; }
public override bool ItemExpandable (NSOutlineView outlineView, NSObject item) { TreeDataNode nodeItem = item as TreeDataNode; if (nodeItem != null) { return nodeItem.HasChildren; } return false; }
public override NSObject GetChild (NSOutlineView outlineView, nint childIndex, NSObject item) { // null means it's asking for the root if (item == null) { return (NSObject)RootNode; } else { return (NSObject)((item as ScopeNode).ChildAtIndex ((int)childIndex)); } }
public override void SortDescriptorsChanged (NSOutlineView outlineView, NSSortDescriptor[] oldDescriptors) { // Any sort direction given? if (oldDescriptors.Length <= 0) return; // Sort the data Sort (oldDescriptors [0].Key, oldDescriptors [0].Ascending); outlineView.ReloadData (); }
public override int GetChildrenCount(NSOutlineView outlineView, NSObject item) { // Check if this is a subitem if (item != null) { LibraryBrowserItem libraryBrowserItem = (LibraryBrowserItem)item; return libraryBrowserItem.SubItems.Count; } return Items.Count; }
public override NSObject GetChild(NSOutlineView outlineView, int childIndex, NSObject ofItem) { // Check if this is a subitem if(ofItem != null) { LibraryBrowserItem libraryBrowserItem = (LibraryBrowserItem)ofItem; return libraryBrowserItem.SubItems[childIndex]; } return Items[childIndex]; }
public override bool ItemExpandable (NSOutlineView outlineView, NSObject item) { if (item != null && (item is UsersNode || item is SolutionUsersNode || item is GroupsNode || item is TrustedCertificateNode || item is RelyingPartyNode || item is OidcClientNode || item is IdentityProvidersNode)) return false; if (item is ScopeNode) { ScopeNode passedNode = item as ScopeNode; // cast to appropriate type of node return (passedNode.NumberOfChildren () != 0); } return true; }
public override NSObject GetNextTypeSelectMatch (NSOutlineView outlineView, NSObject startItem, NSObject endItem, string searchString) { foreach(Product product in DataSource.Products) { if (product.Title.Contains (searchString)) { return product; } } // Not found return null; }
public override NSObject GetChild (NSOutlineView outlineView, int index, NSObject item) { WrapNode wrap; Node n = (Node) (item == null ? Root : (Node) GetNode (item)).Nodes [index]; if (nodeToWrapper.ContainsKey (n)) return nodeToWrapper [n]; wrap = new WrapNode (n); nodeToWrapper [n] = wrap; return wrap; }
public void doubleClicked(NSOutlineView sender) { NSIndexSet selections = m_table.selectedRowIndexes(); uint row = selections.firstIndex(); while (row != Enums.NSNotFound) { AssemblyItem item = (AssemblyItem) (m_table.itemAtRow((int) row)); DoOpen(item); row = selections.indexGreaterThanIndex(row); } }
public override NSObject GetChild (NSOutlineView outlineView, int childIndex, NSObject ofItem) { Console.Write ("GetChild called on " + animalsTree.ToString () + ", "); // null means it's asking for the root if (ofItem == null) { Console.WriteLine ("asked for root, returning " + animalsTree.Children [childIndex].ToString ()); return animalsTree.Children [childIndex]; } else { Console.WriteLine ("asked for child, returning " + ((ofItem as Animal).Children [childIndex]).ToString() ); return (NSObject)((ofItem as Animal).Children [childIndex]); } }
public override nint GetChildrenCount (NSOutlineView outlineView, NSObject item) { // if null, it's asking about the root element if (item == null) { return 1; } else { ScopeNode passedNode = item as ScopeNode; if (passedNode != null) { return passedNode.NumberOfChildren (); } else { System.Diagnostics.Debug.WriteLine ("could not cast, there is a problem here"); return 0; } } }
public override NSObject GetObjectValue (NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item) { if (item == null) { System.Diagnostics.Debug.WriteLine ("passed null, returning empty String"); return new NSString (" "); } else { ScopeNode passedNode = item as ScopeNode; if (passedNode != null) { return (NSString)passedNode.DisplayName; } else { System.Diagnostics.Debug.WriteLine ("returning an empty string, cast failed."); return new NSString (); } } }
public override bool AcceptDrop(NSOutlineView outlineView, NSDraggingInfo info, NSObject item, nint index) { return(false); }
public override string[] FilesDropped(NSOutlineView outlineView, NSUrl dropDestination, NSArray items) { throw new NotImplementedException(); }
public override nint GetChildrenCount(NSOutlineView outlineView, NSObject item) { var it = (TreeItem)item; return(source.GetChildrenCount(it != null ? it.Position : null)); }
public override NSObject GetObjectValue(NSOutlineView outlineView, NSTableColumn forTableColumn, NSObject byItem) { return(byItem); }
public ItemDelegate(NSOutlineView outlineView) { outlineView.RegisterNib(new NSNib(nameof(ItemView), NSBundle.MainBundle), nameof(ItemView)); }
public override bool ShouldSelectItem(NSOutlineView outlineView, NSObject item) { return(!(item is NSObjectFacade) || !(((NSObjectFacade)item).Target is PanelGroupViewModel)); }
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 labelContainer = (NSView)outlineView.MakeView(CategoryIdentifier, this); if (labelContainer == null) { labelContainer = new NSView { Identifier = CategoryIdentifier, }; var disclosure = outlineView.MakeView("NSOutlineViewDisclosureButtonKey", outlineView); disclosure.TranslatesAutoresizingMaskIntoConstraints = false; labelContainer.AddSubview(disclosure); var label = new UnfocusableTextField { TranslatesAutoresizingMaskIntoConstraints = false }; labelContainer.AddSubview(label); labelContainer.AddConstraints(new[] { NSLayoutConstraint.Create(disclosure, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, labelContainer, NSLayoutAttribute.CenterY, 1, 0), NSLayoutConstraint.Create(disclosure, NSLayoutAttribute.Left, NSLayoutRelation.Equal, labelContainer, NSLayoutAttribute.Left, 1, 4), NSLayoutConstraint.Create(label, NSLayoutAttribute.Left, NSLayoutRelation.Equal, disclosure, NSLayoutAttribute.Right, 1, 0), NSLayoutConstraint.Create(label, NSLayoutAttribute.Height, NSLayoutRelation.Equal, labelContainer, NSLayoutAttribute.Height, 1, 0), }); } ((UnfocusableTextField)labelContainer.Subviews[1]).StringValue = group.Category; if (this.dataSource.DataContext.GetIsExpanded(group.Category)) { SynchronizationContext.Current.Post(s => { outlineView.ExpandItem(item); }, null); } return(labelContainer); } 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); }
public override NSObject GetObjectValue(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item) { return(new NSString(((SourceListItem)item).Title)); }
public override NSObject PersistentObjectForItem(NSOutlineView outlineView, NSObject item) { return(null); }
public override NSDragOperation ValidateDrop(NSOutlineView outlineView, NSDraggingInfo info, NSObject item, nint index) { return(NSDragOperation.None); }
public override void SortDescriptorsChanged(NSOutlineView outlineView, NSSortDescriptor[] oldDescriptors) { }
public override bool ItemExpandable(NSOutlineView outlineView, Foundation.NSObject item) { return(((SourceListItem)item).HasChildren); }
public override bool OutlineViewwriteItemstoPasteboard(NSOutlineView outlineView, NSArray items, NSPasteboard pboard) { return(false); }
private NSView GetViewForItem(NSOutlineView outline, NSObjectFacade facade) { nint row = outline.RowForItem(facade); return(outline.GetView(0, row, false)); }
public override NSObject ItemForPersistentObject(NSOutlineView outlineView, NSObject theObject) { return(null); }
public override bool ItemExpandable(NSOutlineView outlineView, NSObject item) { return(GetChildrenCount(outlineView, item) > 0); }
public override void SetObjectValue(NSOutlineView outlineView, NSObject theObject, NSTableColumn tableColumn, NSObject item) { }
public override NSIndexSet GetSelectionIndexes(NSOutlineView outlineView, NSIndexSet proposedSelectionIndexes) { return(Backend.SelectionMode != SelectionMode.None ? proposedSelectionIndexes : new NSIndexSet()); }
public override NSTableRowView RowViewForItem(NSOutlineView outlineView, NSObject item) { return(outlineView.GetRowView(outlineView.RowForItem(item), false) ?? new TableRowView()); }