Esempio n. 1
0
        public void Draw(NSRect aCellFrame, NSView aControlView)
        {
            BookmarkData item = ObjectValue.CastAs <BookmarkData>();

            // create attributes for the title and subtitle text
            NSMutableParagraphStyle style = new NSMutableParagraphStyle();

            style.SetParagraphStyle(NSParagraphStyle.DefaultParagraphStyle);
            style.SetLineBreakMode(NSLineBreakMode.NSLineBreakByTruncatingTail);

            NSDictionary titleAttr = NSDictionary.DictionaryWithObjectsAndKeys(FontManager.FontMedium, NSAttributedString.NSFontAttributeName,
                                                                               NSColor.WhiteColor, NSAttributedString.NSForegroundColorAttributeName,
                                                                               style, NSAttributedString.NSParagraphStyleAttributeName,
                                                                               null);
            NSDictionary subtitleAttr = NSDictionary.DictionaryWithObjectsAndKeys(FontManager.FontSmall, NSAttributedString.NSFontAttributeName,
                                                                                  NSColor.WhiteColor, NSAttributedString.NSForegroundColorAttributeName,
                                                                                  style, NSAttributedString.NSParagraphStyleAttributeName,
                                                                                  null);

            style.Release();

            NSPoint pt = aCellFrame.origin;

            // draw title
            NSString title = NSString.StringWithUTF8String(item.Bookmark.Title);

            title.DrawAtPointWithAttributes(pt, titleAttr);

            NSSize size = title.SizeWithAttributes(titleAttr);

            pt.y += size.height;

            // draw breadcrumb
            List <string> titleTrail = new List <string>();

            foreach (Breadcrumb bc in item.Bookmark.BreadcrumbTrail)
            {
                titleTrail.Add(bc.Title);
            }
            string   breadcrumb  = string.Join("/", titleTrail.ToArray());
            NSString breadcrumb2 = NSString.StringWithUTF8String(breadcrumb);

            breadcrumb2.DrawAtPointWithAttributes(pt, subtitleAttr);
        }