Hi,
I have a chart with a ColorBand tool active on the Bottom Axis. What I'm trying to do is drag the entire ColorBand like you can when using the ScrollPager Tool but I can't find any example of doing this.
I'm already dragging the StartLine and EndLine using the DragLine events for each but also want to move the entire ColorBand when the left mouse is down and moving on the ColorBand.
Kind regards,
Sean
ColorBand Tool dragging
Re: ColorBand Tool dragging
Hello Sean,
This code will do it:
Regards,
Marc Meumann
This code will do it:
Code: Select all
//disable zoom somewhere in your code:
tChart1.Zoom.Direction = ZoomDirections.None;
...... // ..........
//declare
bool mouseDown = false;
Point startPoint;
double startValue;
private void tChart1_MouseDown(object sender, MouseEventArgs e)
{
//check the mousedown is in the band area
if ((tChart1.Axes.Bottom.CalcPosPoint(e.X) > colorBand1.Start)
&& (tChart1.Axes.Bottom.CalcPosPoint(e.X) < colorBand1.End))
{
mouseDown = true;
startPoint = new Point(e.X, e.Y);
startValue = colorBand1.Start;
}
}
private void tChart1_MouseMove(object sender, MouseEventArgs e)
{
if (mouseDown)
{
//assume horiz axis displacement for this example
double displacementX = tChart1.Axes.Bottom.CalcPosPoint(e.X) - tChart1.Axes.Bottom.CalcPosPoint(startPoint.X);
double colorBandWidth = colorBand1.End - colorBand1.Start;
colorBand1.Start = startValue + (displacementX);
colorBand1.End = colorBand1.Start + colorBandWidth;
}
}
private void tChart1_MouseUp(object sender, MouseEventArgs e)
{
mouseDown = false;
}
Marc Meumann
Steema Support