SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components
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]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
Please login first to submit.