Changing arrow colors on mouse hover

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.

Changing arrow colors on mouse hover

Postby peterkrauss » Tue Jun 12, 2018 8:17 am

Is it possible to change the arrows color on mouse hover over the arrows? Thanks for any help.
Attachments
Unbenannt.png
On mouse hover I would like to change color for each arrows and reset to previous color when mouse leaves the arrow
Unbenannt.png (22.31 KiB) Viewed 40 times
peterkrauss
Newbie
Newbie
 
Posts: 1
Joined: Mon May 15, 2017 12:00 am

Re: Changing arrow colors on mouse hover

Postby Christopher » Wed Jun 13, 2018 8:22 am

Hello,

this is possible, but unfortunately it seems there is a bug in the Arrow Series by which the Clicked() method is not returning the correct series point index - I have added this issue to our bug-tracking software with id=2041. However, there is a simple workaround which involves deriving a new class from the Arrow series and overriding the Clicked() method, which can be seen here:

Code: Select all
   public partial class Form1 : Form
   {
      private MyArrow series;
      public Form1()
      {
         InitializeComponent();

         series = new MyArrow(tChart1.Chart);
         series.FillSampleValues();
         tChart1.MouseMove += TChart1_MouseMove;
      }

      int oldIndex = -1;
      private void TChart1_MouseMove(object sender, MouseEventArgs e)
      {
         int index = series.Clicked(e.X, e.Y);
         Color oldColor = Utils.EmptyColor;
         if (index > -1)
         {
            oldColor = series[index].Color;
            series[index].Color = Color.Red;
            if (oldIndex > -1)
            {
               series[oldIndex].Color = oldColor;
            }
            oldIndex = index;
         }

         tChart1.Invalidate();
      }
   }

   public class MyArrow : Arrow
   {
      public MyArrow(Chart c) : base(c) {}

      public override int Clicked(int x, int y)
      {
         Graphics3D g = Chart.Graphics3D;
         for (int i = 0; i < Count; i++)
         {
            Point p0 = new Point(CalcXPos(i), CalcYPos(i));
            Point p1 = new Point(CalcXPosValue(EndXValues[i]), CalcYPosValue(EndYValues[i]));

            Point[] points = g.GetArrowPoints(p0, p1, Pointer.HorizSize, Pointer.VertSize, MiddleZ, 50.0);

            if (points!= null && Graphics3D.PointInPolygon(new Point(x, y), points)) return i;
         }

         return -1;
      }
   }
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum
Christopher
Guru
 
Posts: 1055
Joined: Fri Nov 15, 2002 12:00 am


Return to .NET

Who is online

Users browsing this forum: No registered users and 5 guests