void _presenter_MetricsUpdated(object sender, Presenters.TeamCityMetricsEventArgs e) { Dispatcher.Invoke(new Action(() => { messageText.Visibility = System.Windows.Visibility.Hidden; graph.Visibility = System.Windows.Visibility.Visible; var data = this.DataContext as ViewCommon.ZeroToAutoScaleByDateGraphModel; if (data != null) { var series = data.Model.Series; series.Clear(); foreach (var metricSeries in e.Series) { var seriesData = new OxyPlot.Series.LineSeries { Title = metricSeries.Name }; seriesData.MarkerType = OxyPlot.MarkerType.Circle; seriesData.MarkerSize = 4; foreach (var metricPoint in metricSeries.Points) { seriesData.Points.Add(OxyPlot.Axes.DateTimeAxis.CreateDataPoint(metricPoint.X, metricPoint.Y)); } seriesData.StrokeThickness = 4; series.Add(seriesData); } } graph.Model.InvalidatePlot(true); })); }
void _presenter_MetricsUpdated(object sender, Presenters.TeamCityMetricsEventArgs e) { Dispatcher.Invoke(new Action(() => { messageText.Visibility = System.Windows.Visibility.Hidden; gridMetrics.Visibility = System.Windows.Visibility.Visible; gridMetrics.Children.Clear(); gridMetrics.RowDefinitions.Clear(); foreach (var metricSeries in e.Series) { var row = new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) }; gridMetrics.RowDefinitions.Add(row); var rowIndex = gridMetrics.RowDefinitions.IndexOf(row); var textBrush = new SolidColorBrush(Colors.White); // Create the metric name TextBox wrapped in a Viewbox for auto scaling var viewBoxMetricName = new Viewbox(); var textBoxMetricName = new TextBlock(); viewBoxMetricName.Child = textBoxMetricName; textBoxMetricName.Foreground = textBrush; gridMetrics.Children.Add(viewBoxMetricName); Grid.SetColumn(viewBoxMetricName, 0); Grid.SetRow(viewBoxMetricName, rowIndex); textBoxMetricName.Text = metricSeries.Name; // Create the metric value TextBox wrapped in a Viewbox for auto scaling var viewBoxMetricValue = new Viewbox(); var textBoxMetricValue = new TextBlock(); viewBoxMetricValue.Child = textBoxMetricValue; textBoxMetricValue.Foreground = textBrush; gridMetrics.Children.Add(viewBoxMetricValue); Grid.SetColumn(viewBoxMetricValue, 1); Grid.SetRow(viewBoxMetricValue, rowIndex); var lastPoint = metricSeries.Points.Last(); textBoxMetricValue.Text = lastPoint.Y.ToString("0.00"); } })); }