PopupMenu for ColorLine

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
stratadat
Newbie
Newbie
Posts: 13
Joined: Mon Feb 13, 2006 12:00 am

PopupMenu for ColorLine

Post by stratadat » Thu May 03, 2007 9:02 am

I am using ColorLine tool and would like to be able to envoke a popup menu when user right clicks it. The popup menu will have line formatting settings and "Remove" items. Can you please advise me how to do that? Color line seem to have no onclick event.

Edu
Advanced
Posts: 206
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Post by Edu » Thu May 03, 2007 10:01 am

Hi Stratadat

Yes, the colorLine hasn't this event, you should to use the event of the chart and then calculate if the colorLine has been click. You can do something similar, as below code:

Code: Select all

 
        private bool Clicked(int x, int y)
        {
            int tmp = colorLine1.Axis.Horizontal ? x : y;
            int ClickTolerance = 3;
            if (Math.Abs(tmp - colorLine1.Axis.CalcPosValue(colorLine1.Value)) < ClickTolerance)
            {
                Rectangle r = tChart1.Chart.ChartRect;
                return colorLine1.Axis.Horizontal ? (y >= r.Y) && (y <= r.Bottom) : (x >= r.X) && (x <= r.Right);
            }
            else return false;
        }

        private void tChart1_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right && Clicked(e.X, e.Y))
                tChart1.Text = "Show Popup";
            else tChart1.Text = "Not show Popup";
        }
Best Regards,
Edu

Steema Support Central
http://support.steema.com/

Post Reply