Changing arrow colors on mouse hover
-
- Newbie
- Posts: 1
- Joined: Mon May 15, 2017 12:00 am
Changing arrow colors on mouse hover
Is it possible to change the arrows color on mouse hover over the arrows? Thanks for any help.
- Attachments
-
- 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 7789 times
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Changing arrow colors on mouse hover
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:
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 |