Ejemplo n.º 1
0
        /// <summary>
        /// 只更新数据源
        /// </summary>
        public void UpdatePointData(int traceIndex)
        {
            if (Traces.Count() == 0)
            {
                return;
            }
            isCouple.IsChecked       = false;
            graph.RenderMode         = RenderMode.Hardware;
            this.lstYxis.ItemsSource = Traces;
            List <Point[]>    dataSource = new List <Point[]>();
            List <AxisDouble> axisDouble = new List <AxisDouble>();

            listMarker.ItemsSource = null;
            int index = 0;

            foreach (var tr in Traces)
            {
                if (index > 7)
                {
                    index = 0;
                }
                dataSource.Add(ProcessData(tr.TraceData));
                Plot p = new Plot()
                {
                    Renderer = new LinePlotRenderer()
                    {
                        Stroke = Brushes[index], StrokeThickness = 1.5
                    }
                };
                tr.Color = (SolidColorBrush)(p.Renderer as LinePlotRenderer).Stroke;
                graph.Plots.Add(p);
                foreach (Marker marker in tr.Markers)
                {
                    NationalInstruments.Controls.Cursor cursor = GetCursor();
                    cursor.Plot = p;

                    graph.Children.Add(cursor);
                    double x1 = tr.TraceData.Select(x => x.X).Min();
                    double x2 = tr.TraceData.Select(x => x.X).Max();
                    cursor.SetDataPosition(new List <double>()
                    {
                        (marker.X - x1) / (x2 - x1), marker.Y
                    });
                    cursor.Tag   = marker.DisplayName;
                    cursor.Label = new Label()
                    {
                        Content = tr.Markers.IndexOf(marker), Foreground = (p.Renderer as LinePlotRenderer).Stroke
                    };
                    cursor.CrosshairBrush = (p.Renderer as LinePlotRenderer).Stroke;
                }
                p.VerticalScale = graph.Axes[traceIndex];
                index++;
            }
            getlimitPoint(Traces[traceIndex]);
            listMarker.ItemsSource = graph.Children;
            _LastSelectedTrace     = Traces[traceIndex];
            if (_limitPointlist.Count() > 0)
            {
                foreach (var points in _limitPointlist)
                {
                    dataSource.Add(ProcessData(points));
                    Plot p = new Plot()
                    {
                        Renderer = new LinePlotRenderer()
                        {
                            Stroke = new SolidColorBrush(Colors.Red)
                        }
                    };
                    graph.Plots.Add(p);
                }
            }
            graph.DataSource     = dataSource;
            lstYxis.SelectedItem = Traces[traceIndex];
            isCouple.IsChecked   = true;
        }