コード例 #1
0
        private void OnChartClosed(object sender, EventArgs e)
        {
            SimpleLineChart chart = sender as SimpleLineChart;

            ChartStack.RemoveChart(chart);
            chart.LiveScrolling = false;
            liveScrolling.Remove(chart);
            LayoutCharts();

            LogItemSchema item = (chart.Tag as LogItemSchema);

            if (item != null)
            {
                UnselectCategory(item);
            }
        }
コード例 #2
0
 private void OnClear(object sender, RoutedEventArgs e)
 {
     ChartStack.ClearCharts();
     liveScrolling.Clear();
     logs.Clear();
     CategoryList.SelectedItem = null;
     allFlights.Clear();
     if (currentFlightLog != null)
     {
         currentFlightLog.Clear();
         logs.Add(currentFlightLog);
     }
     if (currentFlight != null)
     {
         currentFlight.Locations = new LocationCollection();
     }
     SystemConsole.Clear();
     myMap.Children.Clear();
     ImageViewer.Source = null;
     ShowSchema();
 }
コード例 #3
0
        private void LayoutCharts()
        {
            // layout charts to fill the space available.
            double height = ChartStack.ActualHeight;
            double count  = ChartStack.ChartCount;

            height -= (count * (defaultChartMargin.Top + defaultChartMargin.Bottom)); // remove margins
            double chartHeight = Math.Min(MaxChartHeight, height / count);
            bool   found       = false;

            foreach (FrameworkElement c in ChartStack.Charts)
            {
                found    = true;
                c.Height = chartHeight;
            }

            // give all the charts the same min/max on the X dimension so that the charts are in sync (even when they are not grouped).
            ChartScaleInfo combined = new ChartScaleInfo();

            foreach (SimpleLineChart chart in ChartStack.FindCharts())
            {
                var info = chart.ComputeScaleSelf(0);
                combined.Combine(info);
            }

            // now set the min/max on each chart.
            foreach (SimpleLineChart chart in ChartStack.FindCharts())
            {
                chart.FixMinimumX = combined.minX;
                chart.FixMaximumX = combined.maxX;
                chart.InvalidateArrange();
            }

            if (!found)
            {
                ChartStack.Visibility = Visibility.Collapsed;
            }
        }
コード例 #4
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();
            }
        }
コード例 #5
0
 private void OnClearZoom(object sender, RoutedEventArgs e)
 {
     ChartStack.ResetZoom();
 }