コード例 #1
0
        void DrawBookmark()
        {
            bool bookmarked = owner.ViewModel.OnGetHistoryItemBookmarked(owner.StateHistoryDataSource.data[row]);

            if (bookmarked)
            {
                var   frame = this.Frame.ToRectangleF();
                float itemH = frame.Height;
                using (var g = new LogJoint.Drawing.Graphics())
                {
                    var sz = bookmarkImage.GetSize(width: 9);
                    g.DrawImage(bookmarkImage, new RectangleF(new PointF(
                                                                  (float)owner.HistoryTableView.GetCellFrame(0, row).Left + 1,
                                                                  itemH * row + itemH / 2 - frame.Y - sz.Height / 2), sz));
                }
            }
        }
コード例 #2
0
        public override NSView GetView(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item)
        {
            var sourceItem = item as SourcesListItem;

            if (tableColumn == sourceCheckedColumn)
            {
                if (sourceItem.isChecked == null)
                {
                    return(null);
                }

                var cellIdentifier = "checked_cell";
                var view           = (NSButton)outlineView.MakeView(cellIdentifier, this);

                if (view == null)
                {
                    view            = new NSButton();
                    view.Identifier = cellIdentifier;
                    view.SetButtonType(NSButtonType.Switch);
                    view.BezelStyle    = 0;
                    view.ImagePosition = NSCellImagePosition.ImageOnly;
                    view.Action        = new ObjCRuntime.Selector("ItemChecked:");
                }

                view.Target = sourceItem;
                view.State  = sourceItem.isChecked.GetValueOrDefault(false) ?
                              NSCellStateValue.On : NSCellStateValue.Off;
                return(view);
            }
            else if (tableColumn == sourceDescriptionColumn)
            {
                var cellIdentifier = "description_cell";
                var view           = (NSLinkLabel)outlineView.MakeView(cellIdentifier, this);

                if (view == null)
                {
                    view             = NSLinkLabel.CreateLabel();
                    view.Identifier  = cellIdentifier;
                    view.LinkClicked = (sender, e) =>
                    {
                        if (e.NativeEvent.ClickCount == 2)
                        {
                            viewEvents.OnEnterKeyPressed();
                        }
                    };
                }

                view.BackgroundColor = sourceItem.color != null?
                                       sourceItem.color.Value.ToColor().ToNSColor() : NSColor.Clear;

                view.StringValue = sourceItem.text;
                return(view);
            }
            else if (tableColumn == currentSourceColumn)
            {
                var cellIdentifier = "current_source_mark_cell";
                var view           = (NSCustomizableView)outlineView.MakeView(cellIdentifier, this);

                if (view == null)
                {
                    view            = new NSCustomizableView();
                    view.Identifier = cellIdentifier;
                }

                view.OnPaint = (ditryRect) =>
                {
                    var focusedItem = viewEvents.OnFocusedMessageSourcePainting() as SourcesListItem;
                    if (focusedItem == null)
                    {
                        return;
                    }
                    if (!(focusedItem == sourceItem || focusedItem.parent == sourceItem))
                    {
                        return;
                    }
                    using (var g = new LJD.Graphics())
                    {
                        var s = currentSourceImage.GetSize(height: 9);
                        var r = view.Bounds;
                        r = new CoreGraphics.CGRect((r.Left + r.Right - s.Width) / 2,
                                                    (r.Top + r.Bottom - s.Height) / 2, s.Width, s.Height);
                        g.DrawImage(currentSourceImage, r.ToRectangleF());
                    }
                };
                return(view);
            }


            return(null);
        }