partial void CustomSuppression(NSObject sender) { var alert = new NSAlert { MessageText = "Subscribe to CatOverflow.com", InformativeText = "CatOverflow.com features the best cats the Internet has to offer.\n\nUpdated regularly and curated by a professional cat analyist, CatOverflow.com cannot be missed. Make it part of your daily regimen now!\n", ShowsSuppressionButton = true }; alert.SuppressionButton.Title = "Go away forever, meow"; alert.SuppressionButton.Font = NSFont.ControlContentFontOfSize(NSFont.SmallSystemFontSize); alert.AddButton("YES YES YES"); alert.AddButton("Remind me later"); alert.AddButton("I prefer DogOverflow.com"); Run(alert); }
public static int DetermineFitWidth(this NSCell cell, NSObject objectValueAtCell, int minWidth = 10) { int width; if (cell is NSTextFieldCell) { var font = cell.Font ?? NSFont.ControlContentFontOfSize(-1); var attrs = NSDictionary.FromObjectAndKey(font, NSAttributedString.FontAttributeName); // Determine the text on the cell NSString cellText; if (objectValueAtCell is NSString) { cellText = (NSString)objectValueAtCell; } else if (cell.Formatter != null) { cellText = cell.Formatter.StringFor(objectValueAtCell).ToNSString(); } else { cellText = objectValueAtCell.Description.ToNSString(); } width = (int)cellText.StringSize(attrs).Width + minWidth; } else if (cell.Image != null) { // if cell has an image, use that images width width = (int)Math.Max(minWidth, (int)cell.Image.Size.Width); } else { // cell is something else, just use its width width = (int)Math.Max(minWidth, (int)cell.CellSize.Width); } return(width); }