public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row) { // 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 NSTextField view = (NSTextField)tableView.MakeView(CellIdentifier, this); if (view == null) { view = new NSTextField(); view.Identifier = CellIdentifier; view.BackgroundColor = NSColor.Clear; view.Bordered = false; view.Selectable = true; view.Editable = false; view.Font = NSFont.FromCTFont(new CoreText.CTFont("Courier", 14)); tableView.Font = NSFont.FromCTFont(new CoreText.CTFont("Courier", 14)); } // Setup view based on the column selected switch (tableColumn.Title) { case "Value": view.StringValue = DataSource.Products[(int)row].Value; break; case "Offset": view.StringValue = DataSource.Products[(int)row].Offset; break; } return(view); }
public void GetBoundingRect_WithEmptyGlyphs() { CGFont cgFont = CGFont.CreateWithFontName("Arial"); ushort [] glyphs = new ushort [] {}; CTFont ctFont = new CTFont(cgFont, 14, new CTFontDescriptor("Arial", 14)); NSFont nsFont = NSFont.FromCTFont(ctFont); Assert.Throws <ArgumentException> (() => nsFont.GetBoundingRects(glyphs)); Assert.Throws <ArgumentException> (() => nsFont.GetAdvancements(glyphs)); }
public void GetBoundingRect_WithEmptyGlyphs() { if (!PlatformHelper.CheckSystemVersion(10, 13)) { return; } CGFont cgFont = CGFont.CreateWithFontName("Arial"); ushort [] glyphs = new ushort [] {}; CTFont ctFont = new CTFont(cgFont, 14, new CTFontDescriptor("Arial", 14)); NSFont nsFont = NSFont.FromCTFont(ctFont); Assert.Throws <ArgumentException> (() => nsFont.GetBoundingRects(glyphs)); Assert.Throws <ArgumentException> (() => nsFont.GetAdvancements(glyphs)); }
public void GetBoundingRect_SmokeTest() { CGFont cgFont = CGFont.CreateWithFontName("Arial"); ushort [] glyphs = new ushort [5]; for (int i = 0; i < 5; ++i) { glyphs[i] = cgFont.GetGlyphWithGlyphName("Hello"[i].ToString()); } CTFont ctFont = new CTFont(cgFont, 14, new CTFontDescriptor("Arial", 14)); NSFont nsFont = NSFont.FromCTFont(ctFont); var bounding = nsFont.GetBoundingRects(glyphs); var advancement = nsFont.GetAdvancements(glyphs); Assert.AreEqual(5, bounding.Length); Assert.AreEqual(5, advancement.Length); }