System.IndexOutOfRangeException WPF NearestPoint

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
ibsd
Newbie
Newbie
Posts: 5
Joined: Wed Feb 12, 2014 12:00 am

System.IndexOutOfRangeException WPF NearestPoint

Post by ibsd » Fri Jun 06, 2014 2:36 pm

Hi Steema Team,

I'm using the TeeChart NET 2014 4.1.2014.02060 inside a WPF-UserControl. And causing the following Exception.

Code: Select all

System.IndexOutOfRangeException wurde nicht behandelt.
  HResult=-2146233080
  Message=Index was outside the bounds of the array.
  Source=TeeChart.WPF
  StackTrace:
       at Steema.TeeChart.WPF.Styles.Series.CalcXPos(Int32 index)
       at Steema.TeeChart.WPF.Tools.NearestPoint.PaintHint()
       at Steema.TeeChart.WPF.Tools.NearestPoint.ChartEvent(EventArgs e)
       at Steema.TeeChart.WPF.Chart.BroadcastToolEvent(EventArgs e)
       at Steema.TeeChart.WPF.Chart.InternalDraw(DrawingContext g, Boolean noTools)
       at Steema.TeeChart.WPF.TChart.Draw(DrawingContext g)
       at Steema.TeeChart.WPF.TChart.OnRender(DrawingContext drawingContext)
       at System.Windows.UIElement.Arrange(Rect finalRect)
       at System.Windows.ContextLayoutManager.UpdateLayout()
       at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
       at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
       at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
       at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
       at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.DispatcherOperation.InvokeImpl()
       at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.ProcessQueue()
       at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at CWinThread.Run(CWinThread* )
       at AIS.VAC.Sys.Runtime.CIFDispatcher.Run(CIFDispatcher* )
The Nearestpoint.Series is filled by a FastLine.
Before removing old Points and adding new ones from the FastLine, I deactivate the NearestPointtool by setting NearestPoint.Active = false and NearestPoint.Series = null.
After adding the new points I set the NearestPoint.Series to the new FastLine and NearestPoint.Active = true.
Then the Exception occurs.

When not setting the NearestPoint.Active = true everything runs well. The Exception also occurs only when the NearestPoint-Marker was displayed on the Chart.

Is there a workaround available for this bug?

Best regards

Franz

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: System.IndexOutOfRangeException WPF NearestPoint

Post by Christopher » Fri Jun 06, 2014 2:48 pm

Hello Franz,
ibsd wrote: The Nearestpoint.Series is filled by a FastLine.
Before removing old Points and adding new ones from the FastLine, I deactivate the NearestPointtool by setting NearestPoint.Active = false and NearestPoint.Series = null.
After adding the new points I set the NearestPoint.Series to the new FastLine and NearestPoint.Active = true.
Then the Exception occurs.
Would you be so kind as to post a short, self contained, correct (compilable) example I can use to reproduce the problem here?

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

ibsd
Newbie
Newbie
Posts: 5
Joined: Wed Feb 12, 2014 12:00 am

Re: System.IndexOutOfRangeException WPF NearestPoint

Post by ibsd » Tue Jun 10, 2014 7:42 am

Hello Christopher,

I build a litle application that reproduce exactly the problem.
The Exception occurs only when the Point count of the line is getting smaller. If the Point count is getting bigger or stays consitent the Exception is not thrown.

I hope this helps.

Best regards

Franz
Attachments
TeeChart_Fehler.zip
Visual Studio 2010 Project
(11.09 KiB) Downloaded 554 times

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: System.IndexOutOfRangeException WPF NearestPoint

Post by Christopher » Tue Jun 10, 2014 10:38 am

Hello Franz,
ibsd wrote:
I build a litle application that reproduce exactly the problem.
The Exception occurs only when the Point count of the line is getting smaller. If the Point count is getting bigger or stays consitent the Exception is not thrown.
Thank you very much, I can now reproduce the issue here. Probably the easiest solution is to add the following line:

Code: Select all

                fl1.Visible = true;
                fl1.ShowInLegend = true;

                NearPoint.Point = -1; //new line
                NearPoint.Series = fl1;
                NearPoint.Active = true;
                #endregion bw_Done
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

ibsd
Newbie
Newbie
Posts: 5
Joined: Wed Feb 12, 2014 12:00 am

Re: System.IndexOutOfRangeException WPF NearestPoint

Post by ibsd » Tue Jun 10, 2014 11:43 am

Thanks for your help, it works.

Post Reply