public void TableViewWillDisplayCell(NSTableView aView, Id aCell, NSTableColumn aTableColumn, int aRow) { NSString identifier = aTableColumn.Identifier.CastTo <NSString>(); if (identifier.Compare(NSString.StringWithUTF8String("standby")) == NSComparisonResult.NSOrderedSame) { NSButtonCell cell = aCell.CastTo <NSButtonCell>(); Room r = iModel.Items[aRow]; cell.Image = r.Standby ? Properties.Resources.IconStandby : Properties.Resources.IconStandbyOn; cell.AlternateImage = r.Standby ? Properties.Resources.IconStandby : Properties.Resources.IconStandbyOn; cell.IsEnabled = !r.Standby; } if (identifier.Compare(NSString.StringWithUTF8String("selected")) == NSComparisonResult.NSOrderedSame) { NSImageCell cell = aCell.CastTo <NSImageCell>(); if (aRow == SelectedIndex) { cell.Image = Properties.Resources.IconTick; cell.IsEnabled = true; } else { cell.Image = null; cell.IsEnabled = false; } } }
public void TableViewWillDisplayCell(NSTableView aView, NSCell aCell, NSTableColumn aTableColumn, int aRow) { NSString identifier = aTableColumn.Identifier.CastTo <NSString>(); if (identifier.Compare(NSString.StringWithUTF8String("selected")) == NSComparisonResult.NSOrderedSame) { NSImageCell cell = aCell.CastTo <NSImageCell>(); if (aRow == SelectedIndex) { cell.Image = Properties.Resources.IconTick; cell.IsEnabled = true; } else { cell.Image = null; cell.IsEnabled = false; } } else { aCell.RepresentedObject = iSources.ObjectAtIndex((uint)aRow); } }
/// <summary> /// This is a work-around to deal with the fact that NSImageCell won't tell me the rectangle *actually* covered by its image, but NSCell will. /// </summary> public static NSRect RectCoveredByImageInBounds(NSImageCell imageCell, NSRect bounds) { return imageCell.SendMessageSuper<NSRect>(NSImageCell.NSImageCellClass, "imageRectForBounds:", bounds); }