Pre loader

How to modify the official sample program: DigitalAnalyzerPerformanceDemo

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

Answered
1
0

How to modify the official sample program: DigitalAnalyzerPerformanceDemo,
Implement [MouseWheel] to scroll up and down the channel, [CTRL + MouseWheel] to enlarge and narrow the channel data?
I found that [CTRL + MouseWheel] is used by default to shift the Y-axis up and down.

Example program RUL:https://github.com/ABTSoftware/SciChart.Wpf.Examples/tree/master/Sandbox/CustomerExamples/DigitalAnalyzerPerformanceDemo

Version
7.0.1.27135
  • Lex
    • Lex
    • 11 months ago
    Hello, Thanks for your inquiry. We’ll discuss this and will get back to you with an update soon. With best regards, Lex, SciChart Technical Support Engineer
  • You must to post comments
Best Answer
0
0

Hello Hundun wds,

I’m not quite sure if this is what you’re asking about, but still here is some info on it:

  1. in the example you’ve mentioned we use custom behavior [DigitalAnalyzerScrollBehavior] for scrolling channels that are outside the visible range of Window.
    This behavior handles two cases:

– Scrolling Up\Down btw channels(rows) via using Shift-key + MouseWheel
– Changing Height\Width of the channel(row) via using Ctrl-key + MouseWheel

https://github.com/ABTSoftware/SciChart.Wpf.Examples/blob/master/Sandbox/CustomerExamples/DigitalAnalyzerPerformanceDemo/Behaviors/DigitalAnalyzerScrollBehavior.cs

As you can see in both cases we set: e.Handled = true; so this (scrolling) event isn’t passed anywhere more.
so in order to have different behavior on combination Ctrl-key + MouseWheel you have to change this method

private void ScrollViewer_OnPreviewMouseWheel(object sender, MouseWheelEventArgs e)
    {
        if (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
        {
            if (ChangeChannelHeightCommand?.CanExecute(null) != true) return;
            ChangeChannelHeightCommand.Execute(e.Delta > 0 ? ChannelHeightDelta : -ChannelHeightDelta);
            e.Handled = true;
        }
        else if (Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
        {
            // leave it empty
        }
        else
        {
            if (!(sender is ScrollViewer scroll)) return;
            scroll.ScrollToVerticalOffset(scroll.VerticalOffset - e.Delta);
            e.Handled = true;
        }
    }

Then moving to SciChart MouseWheelZoomModifier:
It has handler for mouseWheel called OnModifierMouseWheel which is virtual and is able to be overriden. When this method called there are some calculations under the hood, and one of which is overriding of the keyboard action(changing behavior when some key is pressed). This is done in a method called OverrideKeyboardAction() which is also virtual. By default that method handles such keys:
– if no Key is pressed but MouseWheel – it zooms on X and Y directions
– if Ctrl key is pressed – it zooms only on YDirection
it’s basically sets XyDirectionProperty

 this.SetCurrentValue(XyDirectionProperty, XyDirection.YDirection);
  • if Shift key is pressed – it zooms only on XDirection
    the same is here but another direction.

As I’ve mentioned before this logic can be overrided in OverrideKeyboardAction, So you can give it any behavior or login you’ve wanted.

If I understand you correctly you’re trying to swap behavior on scrolling btw channels and zooming the data
you can use changes mentioned above(in the behavior), and also create a custom MouseWheelZoomModifierEx that may look something like this:

public class MouseWheelZoomModifierEx : MouseWheelZoomModifier
{
    protected override void OverrideKeyboardAction(MouseModifier btn)
    {
        // leave empty for ignoring changing of the XYDirection mode
    }

    public override void OnModifierMouseWheel(ModifierMouseArgs e)
    {
        if (Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
        {
            base.OnModifierMouseWheel(e);
        }
    }
}

Please try it, and if you have any further question please ask.
Also if I understand you wrong, can you maybe clarify it better via providing additional info?

Best regards

  • 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