Пример #1
0
        private void GraphItem(LogItemSchema schema)
        {
            if (schema.IsNumeric)
            {
                ChartStack.Visibility = Visibility.Visible;
                ChartStack.UpdateLayout();
                SimpleLineChart chart = new SimpleLineChart();
                chart.Margin          = defaultChartMargin;
                chart.Focusable       = false;
                chart.Closed         += OnChartClosed;
                chart.LineColor       = GetRandomColor();
                chart.StrokeThickness = 1;
                chart.Tag             = schema;

                if (currentFlightLog != null && schema.Root == currentFlightLog.Schema)
                {
                    List <DataValue> values = new List <DataValue>(currentFlightLog.GetDataValues(schema, DateTime.MinValue, TimeSpan.MaxValue));
                    InitializeChartData(schema, chart, values);

                    // now turn on live scrolling...
                    chart.LiveScrolling = true;
                    // the X values are in microseconds (s0 the numerator is the speed of scrolling).
                    chart.LiveScrollingXScale = 50.0 / 1000000.0;

                    liveScrolling.Add(chart);

                    // now start watching the live update for new values that need to be added to this chart.
                    Task.Run(() =>
                    {
                        LiveUpdate(chart, currentFlightLog, schema);
                    });
                }
                else
                {
                    List <DataValue> values = new List <DataValue>(GetSelectedDataValues(schema));
                    if (values.Count > 0)
                    {
                        InitializeChartData(schema, chart, values);
                    }
                    else
                    {
                        chart = null;
                    }
                    ShowStatus(string.Format("Found {0} data values", values.Count));
                }

                if (chart != null)
                {
                    if (chartGroup != null)
                    {
                        chartGroup.AddChart(chart);
                        if (chartGroup.Parent == null)
                        {
                            ChartStack.AddChartGroup(chartGroup);
                        }
                    }
                    else
                    {
                        ChartStack.AddChart(chart);
                    }
                    LayoutCharts();
                }

                ConsoleButton.IsChecked = false;
                SystemConsole.Hide();
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                foreach (var value in GetSelectedDataValues(schema))
                {
                    sb.AppendLine(value.Label);
                }

                SystemConsole.Write(sb.ToString());
                ConsoleButton.IsChecked = true;
                SystemConsole.Show();
            }
        }