public DiscordStatusPage() { this.InitializeComponent(); DataContext = App.Current.Services.GetRequiredService <DiscordStatusViewModel>(); ViewModel.ChartDataLoaded += (m, args) => { chartCanvas.Invalidate(); if (HideChart.GetCurrentState() != ClockState.Stopped) { HideChart.Stop(); } ShowChart.Begin(); }; // Change everything's color by status ViewModel.StatusLoaded += (m, args) => { var statusBrush = new SolidColorBrush(StatusColor); StatusContainer.Background = statusBrush; detailsButton.Foreground = statusBrush; dayDuration.Foreground = statusBrush; weekDuration.Foreground = statusBrush; monthDuration.Foreground = statusBrush; IncidentsScroller.Background = new SolidColorBrush(statusBrush.Color) { Opacity = 0.25 }; }; }
private async void ShowMetrics(string duration) { if (ChangedMetricsDisplay) { HideChart.Begin(); } ChangedMetricsDisplay = true; var metrics = await StatusPage.GetMetrics(duration); if (metrics != null && metrics.Metrics != null && metrics.Metrics.Length > 0) { var metric = metrics.Metrics[0]; int pos = 0; _data.Clear(); datavalues.Clear(); _max = 0; _min = 0; for (var i = 0; i < metric.Data.Length; i++) { datavalues.Add(i, metric.Data[i]); _data.Add(metric.Data[i].Value); if (metric.Data[i].Value > _max) { _max = metric.Data[i].Value; } if (metric.Data[i].Value < _min || _min == 0) { _min = metric.Data[i].Value; } } chartCanvas.Invalidate(); if (HideChart.GetCurrentState() != ClockState.Stopped) { HideChart.Stop(); } ShowChart.Begin(); } }
void ViewModel_ValidChartDataFound(object sender, EventArgs e) { MainChart.Visibility = System.Windows.Visibility.Visible; ShowChart.Begin(); }