Пример #1
0
        /// <summary>
        /// AddChartPoint adds the current Point to the
        /// Collection in a thread-safe manner.
        /// </summary>
        /// <param name="points">The current Point Array to add</param>
        /// <param name="zMax">The Maximum current of the plot</param>
        private void AddPointsToChart(Point[] points, Double zMax)
        {
            //If the Series hasn't been created yet, create it
            Syncfusion.Windows.Chart.ChartSeries series = null;

            if (this._view._chartArea.Series.Count == 0)
            {
                //Create the Series and set some properties
                series = new Syncfusion.Windows.Chart.ChartSeries();
                series.BindingPathsY = new String[] { "Y" };
                series.BindingPathX  = "X";
                series.IsIndexed     = false;
                series.Template      = this._view.Resources["seriesPresenter"] as System.Windows.DataTemplate;
                series.Type          = Syncfusion.Windows.Chart.ChartTypes.FastLine;
                series.MouseMove    += new Syncfusion.Windows.Chart.ChartMouseEventHandler(series_MouseMove);
                series.SetBinding(Syncfusion.Windows.Chart.ChartSeries.DataSourceProperty, "ChartPoints");
            }

            //If the Point Array has more than one Point in it, then
            //this is a File being read, so create a new ObservableCollection
            //from a List.  If not, then just add the point and update
            //the subscribers.
            if (points.GetLength(0) > 1)
            {
                //Create a new List to hold the points
                List <ChartPoint> tempList = new List <ChartPoint>();

                //Iterate through the Points and put them in the List
                foreach (Point p in points)
                {
                    tempList.Add(new ChartPoint(p, zMax));
                }

                //Set the DataSource
                series.DataSource = new ObservableCollection <ChartPoint>(tempList);
            }
            else
            {
                //Set the point and fire the event
                this._chartPoints.Add(new ChartPoint(points[0], zMax));
                this.FirePropertyChanged("ChartPoints");
            }

            //Add the Series if it was created
            if (series != null)
            {
                this._view._chartArea.Series.Add(series);
            }
        }
Пример #2
0
        /// <summary>
        /// series_MouseMove is called when the user has
        /// put the Mouse over the Series in the Chart.
        /// </summary>
        /// <param name="sender">The Series on which the Mouse has moved</param>
        /// <param name="e">The EventArgs sent by the System</param>
        void series_MouseMove(Object sender, Syncfusion.Windows.Chart.ChartMouseEventArgs e)
        {
            //Cast the sender to a ChartSeries
            Syncfusion.Windows.Chart.ChartSeries series = sender as Syncfusion.Windows.Chart.ChartSeries;

            //Get the HitTestResult using the Windows
            //VisualTreeHelper
            HitTestResult htr = VisualTreeHelper.HitTest(this._view, e.MouseEventArgs.GetPosition(this._view));

            //If the hit test was successful, set the Member
            //Variable and fire the event
            if (htr != null && htr.VisualHit is ChartPoint)
            {
                //Cast the VisualHit to a ChartPoint
                ChartPoint cp = htr.VisualHit as ChartPoint;

                //Set the Member Variable
                this._currPoint = new Point(cp.X, cp.Y, cp.Z);

                //Fire the event
                this._eventAggregator.GetEvent <SpectrumChangedEvent>().Publish(this.GetActiveSpectrumInfo());
            }
        }