How to create mouse event for the "added control" in m_chart

Need help in implementing some specific function to your LightningChart Ultimate powered application? Post a question and get code snippets from other LightningChart Ultimate community members.

Moderator: Queue Moderators

Post Reply
jhyap
Posts: 28
Joined: Tue Apr 16, 2013 12:07 am

How to create mouse event for the "added control" in m_chart

Post by jhyap » Wed Jul 10, 2013 2:08 am

I do a drag drop image on m_chart as shown below

Code: Select all

        private void m_chart_DragDrop(object sender, DragEventArgs e)
        {
            PictureBox pb = new PictureBox();
            pb.Image = (Bitmap)e.Data.GetData(typeof(Bitmap));
            pb.Size = pictureBox1.Size;
            pb.SizeMode = pictureBox1.SizeMode;

            pb.Location = this.PointToClient(new Point(e.X - pb.Width / 2, e.Y - pb.Height / 2));
            m_chart.Controls.Add(pb); 
        }
and the result is like this
result of drag and drop image on m_chart
result of drag and drop image on m_chart
drag and drop image on m_chart.JPG (28.72 KiB) Viewed 19610 times
After the picture box has been added to m_chart, I would like to drag and drop the "added picture box" from its existing location to another location of the m_chart.

But here gives me a pause. How to create a mouse event for the "added control" in m_chart ? Any idea?

Regards,
:firing: JH

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: How to create mouse event for the "added control" in m_c

Post by ArctionPasi » Thu Jul 11, 2013 1:27 pm

Hi Jhyap,

why not adding AnnotationXY object in Annotations collection, and setting a bitmap fill into it. That way, you don't need to use a PictureBox. And annotations support moving, scaling, rotating etc. with mouse.

:o
LightningChart Support Team, PT

jhyap
Posts: 28
Joined: Tue Apr 16, 2013 12:07 am

Re: How to create mouse event for the "added control" in m_c

Post by jhyap » Thu Jul 11, 2013 2:33 pm

:o I will try it tomorrow! Thanks Mr. Pasi

jhyap
Posts: 28
Joined: Tue Apr 16, 2013 12:07 am

Re: How to create mouse event for the "added control" in m_c

Post by jhyap » Tue Jul 16, 2013 5:16 am

Hi Pasi,

When I click on the annotation, the center marker is appeared (the dim grey circle marker as shown below). How can I remove or set the center marker to be invisible?
How to get rid of the center marker when annotation is clicked
How to get rid of the center marker when annotation is clicked
how to get rid of the center marker when annotation is clicked.JPG (11.78 KiB) Viewed 19579 times
I am using the annotaion.MouseOverOn and annotation.MouseOverOff event, hence, I cannot set the annotation.MouseInteraction to false.

below is my code for setting the annotation

Code: Select all

        private void m_chart_DragDrop(object sender, DragEventArgs e)
        {
            m_chart.BeginUpdate();
            anno = new AnnotationXY(m_chart.ViewXY, m_chart.ViewXY.XAxes[0], m_chart.ViewXY.YAxes[0]);
            anno.Fill.Bitmap.Image = (Bitmap)e.Data.GetData(typeof(Bitmap));
            anno.Fill.Bitmap.Layout = BitmapFillLayout.Stretch;
            anno.Fill.Style = RectFillStyle.Bitmap;
            anno.Style = AnnotationStyle.Ellipse;
            anno.Sizing = AnnotationXYSizing.ScreenCoordinates;
            anno.SizeScreenCoords.Width = pictureBox1.Size.Width;
            anno.SizeScreenCoords.Height = pictureBox1.Size.Height;
            anno.LocationCoordinateSystem = CoordinateSystem.ScreenCoordinates; 
            anno.Shadow.Visible = false;
            anno.BorderLineStyle.Width = 1.5f;
            anno.MoveByMouse = false;
            anno.ResizeByMouse = false;
            anno.MouseHighlight = MouseOverHighlight.None;
            anno.RotateByMouse = false;
            anno.Text = annoText;
            anno.TextStyle.Visible = false;

            Point a = this.PointToClient(new Point(e.X - (int)anno.SizeScreenCoords.Width / 2, e.Y - (int)anno.SizeScreenCoords.Height / 2));
            anno.LocationScreenCoords.X = a.X;
            anno.LocationScreenCoords.Y = a.Y;
            m_chart.ViewXY.Annotations.Add(anno);

            anno.MouseOverOn += new MouseEventHandler(anno_MouseOverOn);
            anno.MouseOverOff += new MouseEventHandler(anno_MouseOverOff);

            m_chart.EndUpdate();
        }

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: How to create mouse event for the "added control" in m_c

Post by ArctionPasi » Wed Aug 21, 2013 12:39 pm

This answer seems to be delayed because of expired subscription.

set anno.AnchorAdjustByMouse = false; :firing:
LightningChart Support Team, PT

Post Reply