Attaching an annotation to a DrawLine line

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Attaching an annotation to a DrawLine line

Post by Yeray » Tue May 17, 2011 10:42 am

Hello Christian,

I've added the possibility to add a new property to control whether the arrow is draw from/to the annotation (TF02015572). In the meanwhile you could draw the arrow manually. Here is how I modified your project to do it:

Code: Select all

        public TeeChartSandbox()
        {
            //...
            tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
        }

        void tChart1_MouseClick(object sender, MouseEventArgs e)
        {
            //...
            //annotation1.Callout.Arrow.Visible = true;
        }

        void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            Point tmpTo = new Point(annotation1.Callout.XPosition, annotation1.Callout.YPosition);
            Point tmpFrom = CloserPoint(annotation1.Shape.ShapeBounds, tmpTo);

            g.Brush.Color = annotation1.Callout.Color;
            g.Arrow(true, tmpFrom, tmpTo, annotation1.Callout.ArrowHeadSize, annotation1.Callout.ArrowHeadSize, annotation1.Callout.ZPosition);
        }

        Point CloserPoint(Rectangle R, Point P)
        {
            int tmpX, tmpY;

            if (P.X > R.Right) tmpX = R.Right;
            else
                if (P.X < R.Left) tmpX = R.Left;
                else tmpX = (R.Left + R.Right) / 2;

                if (P.Y > R.Bottom) tmpY = R.Bottom;
                else
                    if (P.Y < R.Top) tmpY = R.Top;
                    else tmpY = (R.Top + R.Bottom) / 2;

            return (new Point(tmpX, tmpY));
        }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

CKBN
Newbie
Newbie
Posts: 21
Joined: Mon Apr 11, 2011 12:00 am

Re: Attaching an annotation to a DrawLine line

Post by CKBN » Tue May 17, 2011 11:06 am

Hello Yeray,

Fantastic – this was excatly what I was looking for.
Actually I half expected you guys to tell me that I was a noob, and that I just had to set this or that bool to false :D
Anyway – thanks for your great support.

BR,
Christian

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Attaching an annotation to a DrawLine line

Post by Yeray » Tue May 17, 2011 3:34 pm

Hi Christian,

I'm glad to be helpful.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply