Page 1 of 1

EndDragLine event sent multiple times for no reason

Posted: Tue Apr 10, 2007 7:36 pm
by 9641603
Hi,

I'm using TeeChart version 2.0.2546.16098. I have a chart where I create (programatically) 7 (seven) ColorLines. Each of them has AllowDrag = true. Six of them are vertical and one is horizontal. All of them use the EndDragLine event:

Code: Select all

Steema.TeeChart.Tools.ColorLine line = new Steema.TeeChart.Tools.ColorLine();
line.Active = true;
line.AllowDrag = true;
line.Axis = ( isHorizontalLine ? chart.Axes.Left : chart.Axes.Bottom );
line.Draw3D = false;
line.DrawBehind = false;
line.Pen.Color = someColor;
line.Value = someValue;
line.EndDragLine
    += new Steema.TeeChart.Tools.ColorLineToolOnDragEventHandler( OnLineMoved );
chart.Tools.Add( line );
When the user drags one of the lines, the event handler is invoked seven times, i.e. for each line - even though only one line was dragged.

Are we doing something wrong or is this (a) a bug, or (b) desired behaviour and we have to live with it?

Best,
Michal Blazejczyk

Posted: Wed Apr 11, 2007 10:00 am
by 9348258
Hi Michal

I could reproduce the issue here and this seems to be a bug. I've added it (TF02012165) to our defect list to be fixed for future releases.

In the meantime, a workaround can be to use the "DragLine" event to know which is the ColorLine, for example:

Code: Select all

 private void Form1_Load(object sender, EventArgs e)
        {
            line1.FillSampleValues();
            tChart1.Aspect.View3D = false;
            
            for (int i = 0; i < 7; i++)
            {
                Steema.TeeChart.Tools.ColorLine ColorLine = new Steema.TeeChart.Tools.ColorLine();
                ColorLine.Active = true;
                ColorLine.AllowDrag = true;
                ColorLine.Axis = (i == 0 ? tChart1.Axes.Left : tChart1.Axes.Bottom);
                ColorLine.Draw3D = false;
                ColorLine.DrawBehind = false;
                ColorLine.Pen.Color = Color.Green;
                ColorLine.Value = i;
                ColorLine.DragLine += new EventHandler(ColorLine_DragLine);
                ColorLine.EndDragLine += new Steema.TeeChart.Tools.ColorLineToolOnDragEventHandler(ColorLine_EndDragLine);
                tChart1.Tools.Add(ColorLine);
            }
        }
        
        private int CurrentColorLine = 0;
        
        void ColorLine_DragLine(object sender, EventArgs e)
        {
            int i = 1;
            foreach (Steema.TeeChart.Tools.ColorLine cl in tChart1.Tools)
            {
                if (cl == sender)
                {
                    CurrentColorLine = i;
                    break;
                }
                i++;
            }
        }

        void ColorLine_EndDragLine(object sender)
        {
            int i = 1;
            foreach (Steema.TeeChart.Tools.ColorLine cl in tChart1.Tools)
            {
                if (i==CurrentColorLine)
                {
                    //Now cl is the tool, which has been dragged
                    listBox1.Items.Add("Event: " +i.ToString());
                    break;
                }
                i++;
            }
            CurrentColorLine = 0;
        }

Posted: Thu Apr 12, 2007 8:44 pm
by 9641603
A related question: while a ColorLine is being dragged, it is not visible on the screen, even if the mouse doesn't move. Is this normal?

Best,
Michal

Posted: Fri Apr 13, 2007 10:03 am
by narcis
Hi Michal,

I'm not able to reproduce this here using the latest version available at the client area. Please notice that a new version was posted on Friday 6th April 2007. Could you please check if this version solves the problem at your end?

Thanks in advance.

Posted: Fri Apr 13, 2007 4:43 pm
by 9641603
I switched to version 2.0.2652.22324 a couple days ago and the problem still happens there. When I start dragging a ColorLine, it isn't painted anymore and the mouse cursor flickers between the arrow and the hourglass.

Best,
Michal

Posted: Mon Apr 16, 2007 7:53 am
by narcis
Hi Michal,

I'm still unable to reproduce the issue here. Would you be so kind to send us a simple example project we can run "as-is" to reproduce the problem here?

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.