Page 1 of 1

Can't make cursortool work in WPF

Posted: Fri Aug 07, 2009 4:35 pm
by 9340973
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) {}

Re: Can't make cursortool work in WPF

Posted: Tue Aug 11, 2009 9:46 am
by 10050769
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,