Esempio n. 1
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem item  = sender as MenuItem;
            Trace    tr    = lstYxis.SelectedItem as Trace;
            int      index = Traces.IndexOf(tr);

            if (item.Header.ToString() == "AutoScale")
            {
                AutoScale(index);
            }
            else if (item.Header.ToString() == "Add Marker")
            {
                if (lstYxis.SelectedItem != null)
                {
                    AddMarker(index);
                }
            }
            else if (item.Header.ToString() == "Delete Trace")
            {
                DeleteTrace(index);
            }
            else if (item.Header.ToString() == "Delete All Trace")
            {
                Traces.Clear();
                clearData();
            }
            else if (item.Header.ToString() == "Scale Couple")
            {
                scaleCouple();
            }
            else if (item.Header.ToString() == "Save Chart")
            {
                SaveChartImage("./1.jpg");
            }
            else if (item.Header.ToString() == "Set up")
            {
                WindowSetUp windowSetUp = new WindowSetUp();
                windowSetUp.Show();
            }
        }
Esempio n. 2
0
        private void lstYxis_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lstYxis.SelectedItem != null)
            {
                SelectedIndex = lstYxis.SelectedIndex;
                Trace trace = lstYxis.SelectedItem as Trace;
                if (_LastSelectedTrace == null)
                {
                    return;
                }
                if (_LastSelectedTrace != null)
                {
                    for (int i = 0; i < _LastSelectedTrace.LimitLineList.Count; i++)
                    {
                        graph.Plots.RemoveAt(graph.Plots.Count - 1);
                    }
                }
                _LastSelectedTrace = trace;
                AxisDouble yAxis = new AxisDouble();
                int        index = Traces.IndexOf(trace);
                if (isCouple.IsChecked == false)
                {
                    for (int i = 0; i < graph.Plots.Count; i++)
                    {
                        if (i == index)
                        {
                            graph.Axes[i].Visibility = Visibility.Visible;
                            yAxis = graph.Axes[i] as AxisDouble;
                        }
                        else
                        {
                            graph.Axes[i].Visibility = Visibility.Collapsed;
                            AxisDouble axis = graph.Axes[i] as AxisDouble;

                            axis.MinorGridLines = new GridLines()
                            {
                                Visibility = Visibility.Hidden
                            };
                            axis.MajorGridLines = new GridLines()
                            {
                                Visibility = Visibility.Hidden
                            };
                        }
                    }
                }
                else
                {
                    if (coupleIndex >= Traces.Count)
                    {
                        for (int i = 0; i < graph.Plots.Count; i++)
                        {
                            if (i == index)
                            {
                                graph.Axes[i].Visibility = Visibility.Visible;
                                yAxis = graph.Axes[i] as AxisDouble;
                                foreach (Plot plot in graph.Plots)
                                {
                                    plot.VerticalScale = graph.Axes[i];
                                }
                                coupleIndex = index;
                            }
                            else
                            {
                                graph.Axes[i].Visibility = Visibility.Collapsed;
                            }
                        }
                    }
                }
                int axisIndex = trace.AxisIndex;
                for (int i = 0; i < XAxisList.Count; i++)
                {
                    if (i == axisIndex)
                    {
                        XAxisList[i].ToolTip = ">";
                    }
                    else
                    {
                        XAxisList[i].ToolTip = "";
                    }
                }
                lstAxis.ItemsSource        = null;
                lstAxis.ItemsSource        = XAxisList;
                this.lstAxis.SelectedIndex = axisIndex;
                UpdateDataSource();
                yAxis.MajorDivisions = new RangeLabeledDivisions()
                {
                    LabelVisibility = Visibility.Visible, Mode = RangeDivisionsMode.CreateCountMode(trace.DivisionCount + 1)
                };
                yAxis.MinorGridLines = new GridLines()
                {
                    Stroke = new SolidColorBrush(Colors.White), Visibility = Visibility.Collapsed, StrokeThickness = 0.5
                };
                yAxis.MajorGridLines = new GridLines()
                {
                    Stroke = new SolidColorBrush(Colors.White), Visibility = Visibility.Visible, StrokeThickness = 0.5
                };
                double X = trace.ReferenceLevel - trace.Scale * trace.ReferencePosition;
                double Y = trace.ReferenceLevel + trace.Scale * (trace.DivisionCount - trace.ReferencePosition);
                if (X != Y)
                {
                    yAxis.Range = new Range <double>(X, Y);
                    graph.Axes[index].Adjuster = RangeAdjuster.None;
                }
                _SelectedPlot = graph.Plots[SelectedIndex];
                foreach (Plot p in graph.Plots)
                {
                    ((LinePlotRenderer)p.Renderer).StrokeThickness = 1.0;
                }
                ((LinePlotRenderer)_SelectedPlot.Renderer).StrokeThickness = 2.0;
            }
        }