private NSIndexSet GetSelectionIndexesFilter(NSTableView tableView, NSIndexSet proposedSelectionIndexes) { var selectionIndexes = new NSMutableIndexSet(proposedSelectionIndexes); foreach (int index in proposedSelectionIndexes) { if (index < DataContext.AvailableSerialPorts.Count()) { var port = DataContext.AvailableSerialPorts[(int)index]; if (DataContext.DisabledSerialPorts.Contains(port.PortName)) { selectionIndexes.Remove((nuint)index); } } } return(selectionIndexes); }
/// <inheritdoc/> public override NSIndexSet GetSelectionIndexes(NSTableView tableView, NSIndexSet proposedSelectionIndexes) { var selectionIndexes = new NSMutableIndexSet(proposedSelectionIndexes); if (proposedSelectionIndexes.Count > 0) { foreach (var index in proposedSelectionIndexes) { if ((int)index < DataContext.AvailableSerialPorts.Count()) { var port = DataContext.AvailableSerialPorts[(int)index]; if (DataContext.DisabledSerialPorts.Contains(port.PortName)) { selectionIndexes.Remove(index); } } } } return(selectionIndexes); }
public override void MouseDown(NSEvent theEvent) { if (theEvent.Type == NSEventType.LeftMouseDown) { uint index; bool haveIndex = RectangleFromPoint(theEvent.LocationInWindow, out index); NSMutableIndexSet indexSet = new NSMutableIndexSet(selectionIndexesBinding.GetData<NSIndexSet>()); if ((theEvent.ModifierFlags & NSEventModifierMask.CommandKeyMask) != 0) { if (!haveIndex) // We did not select or unselect anything. Don't mess with the current selection return; if (indexSet.Contains(index)) indexSet.Remove(index); else indexSet.Add(index); } else { indexSet.Clear(); if (haveIndex) indexSet.Add(index); } selectionIndexesBinding.SetData(indexSet); // TODO: Start a drag operation } else base.MouseDown(theEvent); }