public LayerCollectionViewDataSource(NSCollectionView parent) { ParentCollectionView = parent; // Attach to collection view parent.DataSource = this; }
public override void FinishedLaunching(NSObject notification) { mainWindowController = new MainWindowController (); var window = mainWindowController.Window; window.MakeKeyAndOrderFront (this); titles = new NSObject[] { new NSString("Item 1"), new NSString("Item 2"), new NSString("Item 3"), new NSString("Item 4"), new NSString("Item 5"), new NSString("Item 6"), new NSString("Item 7"), new NSString("Item 8"), }; cv = new NSCollectionView(window.ContentView.Frame); cvi = new MyCollectionViewItem(); cv.ItemPrototype = cvi; cv.Content = titles; cv.AutoresizingMask = NSViewResizingMask.MinXMargin | NSViewResizingMask.WidthSizable | NSViewResizingMask.MaxXMargin | NSViewResizingMask.MinYMargin | NSViewResizingMask.HeightSizable | NSViewResizingMask.MaxYMargin; window.ContentView.AddSubview(cv); }
public override void ItemsSelected(NSCollectionView collectionView, NSSet indexPaths) { var paths = indexPaths.ToArray <NSIndexPath>(); var index = (int)paths[0].Item; // Datasource.Data[index]; }
public override NSCollectionViewItem GetItem(NSCollectionView collectionView, NSIndexPath indexPath) { var item = collectionView.MakeItem("HexArchiveCell", indexPath) as HexArchiveItemController; item.HexArchive = Data[(int)indexPath.Item]; return(item); }
public override NSCollectionViewItem GetItem(NSCollectionView collectionView, NSIndexPath indexPath) { var item = collectionView.MakeItem("LegendItemCell", indexPath) as LegendItemController; item.Init(Data[(int)indexPath.Item], Resources, Events); return(item); }
public override void ItemsSelected(NSCollectionView collectionView, NSSet indexPaths) { var paths = indexPaths.ToArray <NSIndexPath>(); var index = (int)paths[0].Item; ParentViewController.ThumbnailSelected = ParentViewController.Source.Data[index]; }
public override void ItemsDeselected(NSCollectionView collectionView, NSSet indexPaths) { var paths = indexPaths.ToArray <NSIndexPath>(); var index = paths[0].Item; ParentViewController.ThumbnailSelected = null; }
public override NSCollectionViewItem GetItem(NSCollectionView collectionView, NSIndexPath indexPath) { var item = collectionView.MakeItem(nameof(ImageListItem), indexPath) as ImageListItemController; item.View.ImageView.SetImage(new NSUrl(images[(int)indexPath.Item]), NSImage.ImageNamed("placeholder")); return(item); }
public override NSSet ShouldSelectItems(NSCollectionView collectionView, NSSet indexPaths) { //HACK: This allows handle the selection when using the keyboard. //this is necessary to break the default behaviour of NSCollectionView while keypress UP between sections //the hack allows select last item from next section instead the first one. //we avoid to use this in mouse down events if (!IsLastSelectionFromMouseDown) { var toolboxWidget = (MacToolboxWidget)collectionView; var lastSelectedItem = toolboxWidget.SelectedIndexPath; if (indexPaths.AnyObject is NSIndexPath indexPath) { if (indexPath != null && lastSelectedItem != null && lastSelectedItem.Section > indexPath.Section) { var lastItemFromSection = toolboxWidget.GetNumberOfItems(indexPath.Section) - 1; return(new NSSet <NSIndexPath> (NSIndexPath.FromItemSection(lastItemFromSection, indexPath.Section))); } } } else { IsLastSelectionFromMouseDown = false; } return(indexPaths); }
public override NSCollectionViewItem GetItem(NSCollectionView collectionView, NSIndexPath indexPath) { var item = collectionView.MakeItem(IsOnlyImage ? MacInspectorToolbarImageCollectionViewItem.Name : MacInspectorToolbarCollectionViewItem.Name, indexPath); if (item is MacInspectorToolbarCollectionViewItem itmView) { var selectedItem = items[(int)indexPath.Section].Items[(int)indexPath.Item]; itmView.View.ToolTip = selectedItem.ToolTip ?? ""; itmView.TextField.StringValue = selectedItem.Label; itmView.DescriptionTextField.StringValue = string.Format("- {0}", selectedItem.Description); itmView.TextField.AccessibilityTitle = selectedItem.AccessibilityLabel ?? ""; itmView.TextField.AccessibilityHelp = selectedItem.AccessibilityHelp ?? ""; itmView.ImageView.Image = selectedItem.Image?.NativeObject as NSImage; //TODO: carefull wih this deprecation (we need a better fix) //ImageView needs modify the AccessibilityElement from it's cell, doesn't work from main view itmView.ImageView.Cell.AccessibilityElement = false; } else if (item is MacInspectorToolbarImageCollectionViewItem imgView) { var selectedItem = items[(int)indexPath.Section].Items[(int)indexPath.Item]; imgView.View.ToolTip = selectedItem.Label ?? ""; imgView.Image = selectedItem.Image?.NativeObject as NSImage; imgView.ImageView.AccessibilityTitle = selectedItem.Label ?? ""; imgView.ImageView.AccessibilityElement = true; } return(item); }
public override CGSize SizeForItem(NSCollectionView collectionView, NSCollectionViewLayout collectionViewLayout, NSIndexPath indexPath) { var macToolboxWidget = (MacToolboxWidget)collectionView; var dataSource = (MacToolboxWidgetDataSource)collectionView.DataSource; var flowLayout = (NSCollectionViewFlowLayout)collectionViewLayout; return(flowLayout.ItemSize); }
public override void ItemsDeselected(NSCollectionView collectionView, NSSet indexPaths) { var paths = indexPaths.ToArray <NSIndexPath>(); var index = paths[0].Item; // Clear selection // ParentViewController.PersonSelected = null; }
public override NSCollectionViewItem GetItem(NSCollectionView collectionView, NSIndexPath indexPath) { var item = collectionView.MakeItem("ItemViewCell", indexPath) as ItemViewController; item.ViewModel = Data[(int)indexPath.Item]; item.UpdateUI(); return(item); }
/// <summary> /// Initializes a new instance of the <see cref="T:MacCollectionNew.CollectionViewDataSource"/> class. /// </summary> /// <param name="parent">The parent collection that this datasource will provide data for.</param> public CollectionViewDataSource(NSCollectionView parent) { // Initialize ParentCollectionView = parent; // Attach to collection view parent.DataSource = this; }
/// <summary> /// Gets the item for the give section and item index. /// </summary> /// <returns>The item.</returns> /// <param name="collectionView">The parent Collection view.</param> /// <param name="indexPath">Index path specifying the section and index.</param> public override NSCollectionViewItem GetItem(NSCollectionView collectionView, NSIndexPath indexPath) { var item = collectionView.MakeItem("EmployeeCell", indexPath) as EmployeeItemController; item.Person = Data[(int)indexPath.Item]; return(item); }
/// <summary> /// Handles one or more items being selected. /// </summary> /// <param name="collectionView">The parent Collection view.</param> /// <param name="indexPaths">The Index paths of the items being selected.</param> public override void ItemsSelected(NSCollectionView collectionView, NSSet indexPaths) { // Dereference path var paths = indexPaths.ToArray <NSIndexPath>(); var index = (int)paths[0].Item; // Save the selected item ParentViewController.PersonSelected = ParentViewController.Datasource.Data[index]; }
public NSCollectionViewItem GetItem(NSCollectionView collectionView, NSIndexPath indexPath) { var item = collectionView.MakeItem("ArtistItemView", indexPath) as ArtistItemView; var artist = viewModel.Search.Artists [(int)indexPath.Item]; item.Artist = artist; return(item); }
public override CGSize ReferenceSizeForHeader(NSCollectionView collectionView, NSCollectionViewLayout collectionViewLayout, nint section) { if (!IsShowCategories) { return(CGSize.Empty); } var delegateFlowLayout = ((MacToolbarFlowLayout)collectionViewLayout); var sectionInset = delegateFlowLayout.SectionInset; return(new CGSize(collectionView.Frame.Width, MacInspectorToolbarHeaderCollectionViewItem.SectionHeight)); }
public override NSCollectionViewItem GetItem(NSCollectionView collectionView, NSIndexPath indexPath) { var item = collectionView.MakeItem("LayerCell", indexPath) as LayerItemController; item.Layer = Data[(int)indexPath.Item]; // set item's background color based on index number NSColor color = indexPath.Item % 2 == 0 ? LayerItemController.EvenColor : LayerItemController.OddColor; item.SetBackgroundColor(color); return(item); }
protected override void OnElementChanged(ElementChangedEventArgs <View> e) { this.OnElementChanged(e); var uiCollectionView = new NSCollectionView(new CGRect((nfloat)0, (nfloat)0, (nfloat)100, (nfloat)100)); uiCollectionView.MinItemSize = new CGSize(220, 44); uiCollectionView.DataSource = new NavigationMenuRenderer.DataSource((NavigationMenu)Element); uiCollectionView.SetBackgroundColor(NSColor.White); uiCollectionView.RegisterClassForItem(typeof(NavigationMenuRenderer.NavigationCell), "NavigationCell"); collectionView = uiCollectionView; SetNativeControl((NSView)this.collectionView); }
public override void ItemsSelected(NSCollectionView collectionView, NSSet indexPaths) { var indexPath = indexPaths.ToArray <NSIndexPath>().FirstOrDefault(); if (indexPath != null) { var image = parent.images[(int)indexPath.Item]; parent.imageView.SetImage(new NSUrl(image), NSImage.ImageNamed("placeholder")); } else { parent.imageView.Image = null; } }
public override CGSize SizeForItem(NSCollectionView collectionView, NSCollectionViewLayout collectionViewLayout, NSIndexPath indexPath) { var delegateFlowLayout = (MacToolbarFlowLayout)collectionViewLayout; if (delegateFlowLayout.SectionAtIndexIsCollapsed((nuint)indexPath.Section)) { return(new CGSize(0, 0)); } if (IsOnlyImage) { return(MacInspectorToolbarImageCollectionViewItem.Size); } var sectionInset = delegateFlowLayout.SectionInset; return(new CGSize(collectionView.Frame.Width - sectionInset.Left - sectionInset.Right, MacInspectorToolbarCollectionViewItem.ItemHeight)); }
public NSCollectionViewItem GetCollectionCell(NSCollectionView collectionView, Foundation.NSIndexPath indexPath) { var cell = collectionView.MakeItem ("cell", indexPath); if (cell == null) { cell = new NSCollectionViewItem (){ }; cell.View = new NSTextField (new CGRect (0, 0, 100, 100)) { Editable = false, }; } var text = cell.View as NSTextField; //var cell = collectionView.NewItemForRepresentedObject ((NSString)Caption); //var cell = collectionView.GetItem ( indexPath) ; cell.Identifier = "cell"; text.StringValue = Caption; return cell; }
public override CoreGraphics.CGSize SizeForItem(NSCollectionView collectionView, NSCollectionViewLayout collectionViewLayout, NSIndexPath indexPath) { // NSCollectionView sucks. It's hard to make it calc items sizes. // Calculating the size manually here. var i = dataSource.Data[(int)indexPath.Item]; using (var g = new Graphics()) { var sz = g.MeasureString(i.Label, resources.AxesFont); sz.Width += 40 /* preview width */ + 3 /* preview left padding */ + 3 /* space between preview and label */ + 1 /* extra space just in case */; sz.Height += 1 /* extra space just in case */; return(sz.ToCGSize()); } }
public override NSCollectionViewItem GetItem(NSCollectionView collectionView, NSIndexPath indexPath) { // No view recycling on Mac //var navigationCell = (NavigationMenuRenderer.NavigationCell)collectionView.DequeueReusableCell (new NSString ("NavigationCell"), indexPath); var navigationCell = new NavigationMenuRenderer.NavigationCell(collectionView.Frame); var target = menu.Targets.Skip((int)indexPath.Item).FirstOrDefault(); if (target != null) { navigationCell.Name = target.Title; navigationCell.Icon = (string)target.Icon; navigationCell.Selected = (Action)(() => menu.SendTargetSelected(target)); } else { navigationCell.Selected = (Action)null; navigationCell.Icon = ""; navigationCell.Name = ""; } return(navigationCell); }
public override nint GetNumberofItems(NSCollectionView collectionView, nint section) => Data.Count;
public override nint GetNumberofItems(NSCollectionView collectionView, nint section) { return(images.Count); }
public NSSet ShouldSelectItems(NSCollectionView collectionView, NSSet indexPaths) { return(indexPaths); }
public nint GetNumberofItems(NSCollectionView collectionView, nint section) { return(viewModel.Search.Artists.Count); }
public nint GetNumberOfSections(NSCollectionView collectionView) { return(1); }
public HexArchiveCollectionViewDataSource(NSCollectionView parent) { ParentCollectionView = parent; parent.DataSource = this; }
public override nint GetNumberOfSections(NSCollectionView collectionView) => 1;