Example #1
0
 // ******************************************************************
 void AddAnotherPointAsync(AlgorithmOnline algoOnline, AlgorithmStat algoOnlineStat, int index, LineSeries oxyPlotSeries)
 {
     Task.Run(new Action(() =>
     {
         Thread.Sleep(1000);
         Dispatcher.BeginInvoke(DispatcherPriority.ContextIdle, new Action(
                                    () => ProcessNextAlgorithmOnlinePoint(algoOnline, algoOnlineStat, index, oxyPlotSeries)));
     }
                         ));
 }
Example #2
0
        // ******************************************************************
        private void ProcessNextAlgorithmOnlinePoint(AlgorithmOnline algoOnline, AlgorithmStat algoOnlineStat, int index, LineSeries oxyPlotSeries)
        {
            if (index < 0 || index >= Model.Points.Length)
            {
                Model.AddMessage($"Online test completed. {index} points processed.");
                return;
            }

            Point pt = Model.Points[index];

            index++;

            Model.Iteration = index;

            if (algoOnline.AddPoint(pt))
            {
                oxyPlotSeries.Points.Clear();

                IReadOnlyCollection <Point> results = algoOnline.GetResult();

                algoOnline.Stat.PointCount  = index;
                algoOnline.Stat.ResultCount = results.Count;

                if (results.Count > 0)
                {
                    foreach (var point in results)
                    {
                        oxyPlotSeries.Points.Add(new DataPoint(point.X, point.Y));
                    }
                }

                Model.PlotModel.PlotView?.InvalidatePlot();
            }


            if (Global.Instance.IsCancel)
            {
                Model.AddMessage("Convex Hull Online test canceled");
                Global.Instance.ResetCancel();
                return;
            }

            AddAnotherPointAsync(algoOnline, algoOnlineStat, index, oxyPlotSeries);
        }