예제 #1
0
            public override bool WriteRows(NSTableView tableView, NSIndexSet rowIndexes, NSPasteboard pboard)
            {
                var h = Handler;

                if (h == null)
                {
                    return(false);
                }

                if (h.IsMouseDragging)
                {
                    h.DragInfo = null;
                    // give MouseMove event a chance to start the drag
                    h.DragPasteboard = pboard;


                    // check if the dragged rows are different than the selection so we can fire a changed event
                    var  dragRows             = rowIndexes.Select(r => (int)r).ToList();
                    bool isDifferentSelection = (nint)dragRows.Count != h.Control.SelectedRowCount;
                    if (!isDifferentSelection)
                    {
                        // same count, ensure they're not different rows
                        // typically only tests one entry here, as there's no way to drag more than a single non-selected item.
                        var selectedRows = h.Control.SelectedRows.ToArray();
                        for (var i = 0; i < selectedRows.Length; i++)
                        {
                            if (!dragRows.Contains((int)selectedRows[i]))
                            {
                                isDifferentSelection = true;
                                break;
                            }
                        }
                    }

                    if (isDifferentSelection)
                    {
                        h.CustomSelectedRows = dragRows;
                        h.Callback.OnSelectionChanged(h.Widget, EventArgs.Empty);
                    }

                    var args = MacConversions.GetMouseEvent(h, NSApplication.SharedApplication.CurrentEvent, false);
                    h.Callback.OnMouseMove(h.Widget, args);
                    h.DragPasteboard = null;

                    return(h.DragInfo != null);
                }

                return(false);
            }
예제 #2
0
 public override NSIndexSet GetSelectionIndexes(NSTableView tableView, NSIndexSet proposedSelectionIndexes)
 {
     if (updating)
     {
         return(proposedSelectionIndexes);
     }
     Notify(() =>
     {
         owner.OnSelect?.Invoke(
             proposedSelectionIndexes
             .Select(row => dataSource.items[(int)row])
             .ToArray()
             );
     });
     return(proposedSelectionIndexes);
 }
예제 #3
0
 public override NSIndexSet GetSelectionIndexes(NSOutlineView outlineView, NSIndexSet proposedSelectionIndexes)
 {
     if (updating)
     {
         return(proposedSelectionIndexes);
     }
     Notify(() =>
     {
         owner.OnSelect?.Invoke(
             proposedSelectionIndexes
             .Select(row => outlineView.ItemAtRow((nint)row))
             .OfType <NSNodeItem>()
             .Select(n => n.ModelNode)
             .ToArray()
             );
     });
     return(proposedSelectionIndexes);
 }
예제 #4
0
            public override bool WriteRows(NSTableView tableView, NSIndexSet rowIndexes, NSPasteboard pboard)
            {
                var h = Handler;

                if (h == null)
                {
                    return(false);
                }

                if (h.IsMouseDragging)
                {
                    h.Control.AllowedOperation = null;
                    // give MouseMove event a chance to start the drag
                    h.DragPasteboard     = pboard;
                    h.CustomSelectedRows = rowIndexes.Select(r => (int)r).ToList();
                    var args = MacConversions.GetMouseEvent(h.ContainerControl, NSApplication.SharedApplication.CurrentEvent, false);
                    h.Callback.OnMouseMove(h.Widget, args);
                    h.DragPasteboard     = null;
                    h.CustomSelectedRows = null;
                    return(h.Control.AllowedOperation != null);
                }

                return(false);
            }