Changing arrow colors on mouse hover
Posted: 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.
Steema Software - Customer Support Forums
http://216.92.101.67/support/
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;
}
}