Page 1 of 1

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

Posted: Wed Jul 10, 2013 2:08 am
by jhyap
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 19637 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

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

Posted: Thu Jul 11, 2013 1:27 pm
by ArctionPasi
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

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

Posted: Thu Jul 11, 2013 2:33 pm
by jhyap
:o I will try it tomorrow! Thanks Mr. Pasi

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

Posted: Tue Jul 16, 2013 5:16 am
by jhyap
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 19606 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();
        }

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

Posted: Wed Aug 21, 2013 12:39 pm
by ArctionPasi
This answer seems to be delayed because of expired subscription.

set anno.AnchorAdjustByMouse = false; :firing: