Pre loader

SciChartSurface Mouse Down event

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

Hi there

I got 2(or more) charts, and want to make line annotation on both
So i create 2 or more annotationCreationModifier, and want to releaseMouseCapture after the first point of line is placed at any of charts, for this im using SciChartSurface.MouseDown event

    List<AnnotationCreationModifier> AnnotationCreatorsList = new List<AnnotationCreationModifier>();

    public void LineAnotationCreaterModifier() 
    {
        AnnotationCreatorsList.Clear();

        AnnotationCreater = new AnnotationCreationModifier() { AnnotationType = typeof(LineAnnotation) };
        AnnotationCreater.AnnotationCreated += new EventHandler(AnnotationCreater_LineAnnotationCreated);
        PriceChart.ChartControl.ChartModifier = AnnotationCreater;
        PriceChart.ChartControl.MouseDown += new MouseButtonEventHandler(ChartControl_MouseDown);


        AnnotationCreatorsList.Add(AnnotationCreater);

        foreach (ChartArea a in SecondaryCharts)
        {
            AnnotationCreater = new AnnotationCreationModifier() { AnnotationType = typeof(LineAnnotation) };
            AnnotationCreater.AnnotationCreated += new EventHandler(AnnotationCreater_LineAnnotationCreated);
            a.ChartControl.MouseDown += new MouseButtonEventHandler(ChartControl_MouseDown);
            a.ChartControl.ChartModifier = AnnotationCreater;
            AnnotationCreatorsList.Add(AnnotationCreater);
        }
    }


    void ChartControl_MouseDown(object sender, MouseButtonEventArgs e)
    {
        PriceChart.ChartControl.MouseDown -= new MouseButtonEventHandler(ChartControl_MouseDown);
        foreach (ChartArea a in SecondaryCharts)
        {
            a.ChartControl.MouseDown -= new MouseButtonEventHandler(ChartControl_MouseDown);
        }

        if (e.ChangedButton == MouseButton.Left)
        {
            var area = sender as SciChartSurface;

            foreach (var ancr in AnnotationCreatorsList)
            {
                if (ancr.ParentSurface == area) { }
                else { ancr.ReleaseMouseCapture(); }
            }
        }
    }

But i cant understand when mousedown event executes
It allways executes when i click on a board
And sometimes executes at the second click (after first click, when the first point is placed)

I made video, and will post it

Here is link for video:

[video] https://http://www.youtube.com/watch?v=p9z0K09xRGI [/video]
  • You must to post comments
0
0

Hi there,

I think the better solution for you is to create your own modifier and share this modifier across all charts. You need to inherit it from the AnnotationCreationModifier, and override OnModifierMouseDown. It takes ModifierMouseArgs as argument, and there is IsMaster property, indicating whether event occurred on ParentSurface or not. Also there is Source property, from where you can get the master surface. Please, take a look at this topic to find info how to share only one modifier through all charts (find there MasterRolloverModifier there).

Please, try this approach and let us know if you need any assistance!

Best regards,
Yuriy

  • Yuriy Zadereckiy
    One more remark: you could try subscribing to SciChartSurface.RootGrid.MouseDown or SciChartSurface.ModifierSurface.MouseDown instead of listening to direct event from SciChartSurface. Yuriy
  • 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