Can't make cursortool work in WPF

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
BlueMonkey
Newbie
Newbie
Posts: 20
Joined: Mon Feb 14, 2005 5:00 am
Location: Eastern Washington, US

Can't make cursortool work in WPF

Post by BlueMonkey » Fri Aug 07, 2009 4:35 pm

I am porting a TeeChart application from Delphi to WPF/dotNET. I cannot get the cursor tool to work with WPF.

Here is a code snippet. During execution, the P.Y coordinate is always negative, and I never get match = true; I have uploaded my complete application for another issue that Sandra is investigating (3D rotation crash). To enable the cursor tool in that application, choose the icon from the bottom toolbar that looks like a crosshair (7th from the left).

Code: Select all

                // P=FChartTimeSeries.ChartDisplay.GetCursorPos();
                P = FChartTimeSeries.ChartDisplay.PointFromScreen(e.MouseDevice.GetPosition(this));

                ecount = GetActiveEventCount();   // number of active events

                // Compare mouse location to each point in each series

                for(i=0; i< FChartTimeSeries.ChartDisplay.Series.Count; i++)
                {
                    match = FChartTimeSeries.ChartDisplay.Series[i].Clicked(P.X,P.Y);
                    if (match != -1)      // match is matching record in series
                    {
                        FChartTimeSeries.CursorTool.Series = FChartTimeSeries.ChartDisplay.Series[i];
                        if((!isCBEMA) &&
                                !(FChartTimeSeries.ChartDisplay.Series[i] is Steema.TeeChart.WPF.Styles.Bar)) 
                        {
                            match = FChartTimeSeries.CursorTool.SnapToPoint();   // not a point series, must identify data point
                        }
                        myX = FChartTimeSeries.ChartDisplay.Series[i].XValues[match];
                        myY = FChartTimeSeries.ChartDisplay.Series[i].YValues[match];


I also tried the method of registering a callback like the following, but it is never called.

ChartTool1.Change += new Steema.TeeChart.WPF.Tools.CursorChangeEventHandler(ChartCursor_Change);

public void ChartCursor_Change(object sender, Steema.TeeChart.WPF.Tools.CursorChangeEventArgs e) {}

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Can't make cursortool work in WPF

Post by Sandra » Tue Aug 11, 2009 9:46 am

Hello BlueMonkey,

I made a simple project, because we can not execute correctly your complete application. Please, check next code works in your computer using your version of TeeChartFor .Net . If the code not works, please you could said what is your version of TeeChartFor.Net ?

Code: Select all

        Steema.TeeChart.WPF.Styles.Bar bar;
        Steema.TeeChart.WPF.Tools.CursorTool cursorTool1;
        int index;
        private void InitializeForm()
        {
            tChart1.Aspect.View3D = false;
            bar = new Steema.TeeChart.WPF.Styles.Bar(tChart1.Chart);
            bar.FillSampleValues(5);
            bar.Marks.Visible = true;
            
            //-------------------CURSORTOOL---------------------------------//
            cursorTool1 = new Steema.TeeChart.WPF.Tools.CursorTool(tChart1.Chart);
            cursorTool1.Pen.Color = Colors.Red;
            cursorTool1.Series = bar;
            cursorTool1.Snap = true;
            index = cursorTool1.SnapToPoint();
            cursorTool1.Change += new Steema.TeeChart.WPF.Tools.CursorChangeEventHandler(cursorTool1_Change);
      

        }
        void cursorTool1_Change(object sender, Steema.TeeChart.WPF.Tools.CursorChangeEventArgs e)
        {
            if (index != -1)
            {
                tChart1.Header.Text = e.XValue+","+" "+e.YValue.ToString();
            }
            
        }
Therefore, if don't want of that code do, please send a simple project us, as I commented in your previous post(3D rotation crash) ,because we can reproduce issue here.

On the other hand, you could said,if you has modified the source code?

I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply