Pre loader

DataPointSelectionModifier - can an operation be cancelled and How to invert the selection

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

I’m playing with the DatPointSelectionModifier which seems mostly what i need but I have two problems as follows:

1/ I have started a selection operation by dragging over an area containing some points and I decide that I don’t want that area after all and want to cancel the operation (much like file explorer file dragging – hitting escape cancels the operation) – How do I do that?

2/ I have a set of selected points and drag to select another set which overlaps the first set. I would like the any points in the overlap to invert from selected to unselected and vice versa. How would I know which points are encompassed by the drag operation so i can work out the overlap?

Thanks for any suggestions
/Stuart

Version
5.1.0.11450
  • Stuart McCullough
    I’ve had a further play with some breakpoints in place and it seems if you click a point it sets the metadata property once as you’d expect but if you drag over an already selected point it calls the property twice – the first time it sets it to false (as I’d expect) but then calls it again to set it back to true. This means you can never un-select a point by dragging over it. Is this the correct behaviour?
  • Stuart McCullough
    As per the the examples, the answer to one of my problems seems to be setting the “SelectionMode” to “Inverse” – the problem is that this isn’t a recognised property of the DataPointSelectionModifier in version 5.1.0.11450 :-(
  • You must to post comments
1
0

Hi Stuart,

As per a customer feature request, we made it easier to override the DataPointSelectionModifier SelectionMode.

See this snippet of code.

    /// <summary>
    /// When overriden in derived classes, is used to override the default selection behavior.
    /// </summary>
    /// <param name="modifierKey">The modifier key which has been pressed.</param>
    /// <param name="isAreaSelection"><value>True</value> when selection was performed by dragging a reticule, othetwise <value>False</value>.</param>
    /// <returns></returns>
    protected virtual SelectionMode GetSelectionMode(MouseModifier modifierKey, bool isAreaSelection)
    {
        var selectionMode = SelectionMode.Replace;
        if (!AllowsMultiSelection)
        {
            return selectionMode;
        }

        switch (modifierKey)
        {
            case MouseModifier.Ctrl:
                selectionMode = isAreaSelection ? SelectionMode.Union : SelectionMode.Inverse;
                break;
            case MouseModifier.Shift:
                selectionMode = SelectionMode.Inverse;
                break;
        }

        return selectionMode;
    }

This is taken from DataPointSelectionModifier.cs. As you can see SelectionMode depends on the key currently pressed (CTRL or SHIFT).

If you derive a class from DataPointSelectionModifier and override this method you should be able to implement the desired behaviour.

Best regards,
Andrew

  • Stuart McCullough
    Hi Andrew, nice to see you’re still pointing us infrequent users in the right direction :-) Anyway – nice solution but, as usual, the goal posts moved on me. It turns out I really only need to set the SelectionMode to be “Inverse” at all times (which I can’t do from XAML) as the actual required behaviour is the following: On left mouse button click use the RubberBandXYZoomModifier as normal BUT if the CTRL key is pressed then use the DataPointSelectionModifier instead. I can do this by capturing the chart key events and setting the modifiers to true and false according to what position the key is in BUT if I do a CTRL down and start a drag with the PointSelect modifier then let go of the CTRL key before the mousebutton it goes into the keyup event which disables the PointSelect and leaves the drag area annotation stuck on the chart surface. Any thoughts would be appreciated (as usual) :-)
  • Andrew Burnett-Thompson
    Hi Stuart, we are pointing in the right direction but we’re not doing custom work for free any more (custom work defined as modifying SciChart for use outside of documented features). We can build this requirement for you as a short project or show you where in the code to modify or inherit if you have source-code access, but not do the work. My suggestion (for pointing in right direction) would be. 1.) Subscribe to KeyDown and set DataPointSelectionModifier.IsEnabled when CTRL pressed, enable rubber band when not pressed. 2.) override DataPointSelectionModifier GetSelectionMode and always return SelectionMode.Inverse.
  • Stuart McCullough
    Hi Andrew, Sorry I’m a bit late in getting back. Anyway, I’d already implemented your suggestion which is why I could see the problem with the drag annotation being left on the screen but I’m sure I’ll find a solution to that. The key information was in your previous code snippet which also pointed me in the right direction for sorting out capturing the SelectionChanged event in my ViewModel. Many thanks again for the help and keep up the excellent work :-)
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies