/// <summary> /// Get data for the selected game. /// </summary> /// <param name="gameID"></param> /// <param name="variateur"></param> public void getActivityForGamesTimeGraphics(string gameID) { gameSeriesContener.Children.Clear(); GameActivityClass gameActivity = GameActivityDatabases.Get(Guid.Parse(gameID)); List <Activity> gameActivities = gameActivity.Activities; var graph = new GameActivityGameGraphicTime(settings, gameActivity, variateurTime); graph.gameSeriesDataClick += new DataClickHandler(GameSeries_DataClick); gameSeriesContener.Children.Add(graph); gameSeriesContener.UpdateLayout(); gameLabel.Content = resources.GetString("LOCGameActivityTimeTitle"); }
/// <summary> /// Get data detail for the selected game. /// </summary> /// <param name="gameID"></param> public void getActivityForGamesLogGraphics(string gameID, string dateSelected = "") { gameSeriesContener.Children.Clear(); GameActivityClass gameActivity = GameActivityDatabases.Get(Guid.Parse(gameID)); List <Activity> gameActivities = gameActivity.Activities; gameSeriesContener.Children.Add(new GameActivityGameGraphicLog(settings, gameActivity, dateSelected, variateurLog, false)); gameSeriesContener.UpdateLayout(); if (dateSelected == "") { gameLabel.Content = resources.GetString("LOCGameActivityLogTitle"); } else { gameLabel.Content = resources.GetString("LOCGameActivityLogTitleDate") + " " + Convert.ToDateTime(dateSelected).ToString(Playnite.Common.Constants.DateUiFormat); } }
/// <summary> /// Get data detail for the selected game. /// </summary> /// <param name="gameID"></param> public void getActivityForGamesLogGraphics(string gameID, string dateSelected = "") { // TODO Get by date for click on time sessions GameActivityClass gameActivity = GameActivityDatabases.Get(Guid.Parse(gameID)); List <ActivityDetailsData> gameActivitiesDetails = gameActivity.GetSessionActivityDetails(dateSelected); string[] activityForGameLogLabels = new string[0]; List <ActivityDetailsData> gameLogsDefinitive = new List <ActivityDetailsData>(); if (gameActivitiesDetails.Count > 0) { if (gameActivitiesDetails.Count > 10) { // Variateur int conteurEnd = gameActivitiesDetails.Count + variateurLog; int conteurStart = conteurEnd - 10; if (conteurEnd > gameActivitiesDetails.Count) { int temp = conteurEnd - gameActivitiesDetails.Count; conteurEnd = gameActivitiesDetails.Count; conteurStart = conteurEnd - 10; variateurLog = variateurLogTemp; } if (conteurStart < 0) { conteurStart = 0; conteurEnd = 10; variateurLog = variateurLogTemp; } variateurLogTemp = variateurLog; // Create data int sCount = 0; activityForGameLogLabels = new string[10]; for (int iLog = conteurStart; iLog < conteurEnd; iLog++) { gameLogsDefinitive.Add(gameActivitiesDetails[iLog]); activityForGameLogLabels[sCount] = Convert.ToDateTime(gameActivitiesDetails[iLog].Datelog).ToLocalTime().ToString("HH:mm"); sCount += 1; } } else { gameLogsDefinitive = gameActivitiesDetails; activityForGameLogLabels = new string[gameActivitiesDetails.Count]; for (int iLog = 0; iLog < gameActivitiesDetails.Count; iLog++) { activityForGameLogLabels[iLog] = Convert.ToDateTime(gameActivitiesDetails[iLog].Datelog).ToLocalTime().ToString("HH:mm"); } } } // Set data in graphic. ChartValues <int> CPUseries = new ChartValues <int>(); ChartValues <int> GPUseries = new ChartValues <int>(); ChartValues <int> RAMseries = new ChartValues <int>(); ChartValues <int> FPSseries = new ChartValues <int>(); for (int iLog = 0; iLog < gameLogsDefinitive.Count; iLog++) { CPUseries.Add(gameLogsDefinitive[iLog].CPU); GPUseries.Add(gameLogsDefinitive[iLog].GPU); RAMseries.Add(gameLogsDefinitive[iLog].RAM); FPSseries.Add(gameLogsDefinitive[iLog].FPS); } SeriesCollection activityForGameLogSeries = new SeriesCollection { new ColumnSeries { Title = "cpu usage (%)", Values = CPUseries }, new ColumnSeries { Title = "gpu usage (%)", Values = GPUseries }, new ColumnSeries { Title = "ram usage (%)", Values = RAMseries }, new LineSeries { Title = "fps", Values = FPSseries } }; Func <double, string> activityForGameLogFormatter = value => value.ToString("N"); gameSeries.DataTooltip = new LiveCharts.Wpf.DefaultTooltip(); gameSeries.DataTooltip.Background = (Brush)resources.GetResource("CommonToolTipBackgroundBrush"); gameSeries.DataTooltip.Padding = new Thickness(10); gameSeries.DataTooltip.BorderThickness = (Thickness)resources.GetResource("CommonToolTipBorderThickness"); gameSeries.DataTooltip.BorderBrush = (Brush)resources.GetResource("CommonToolTipBorderBrush"); gameSeries.DataTooltip.Foreground = (Brush)resources.GetResource("CommonToolTipForeground"); if (dateSelected == "") { gameLabel.Content = resources.GetString("LOCGameActivityLogTitle"); } else { gameLabel.Content = resources.GetString("LOCGameActivityLogTitleDate") + " " + dateSelected; } gameSeries.Series = activityForGameLogSeries; gameLabelsX.MinValue = 0; gameLabelsX.Labels = activityForGameLogLabels; gameLabelsY.LabelFormatter = activityForGameLogFormatter; }
/// <summary> /// Get data for the selected game. /// </summary> /// <param name="gameID"></param> /// <param name="variateur"></param> public void getActivityForGamesTimeGraphics(string gameID) { DateTime dateStart = DateTime.Now.AddDays(variateurTime); string[] listDate = new string[10]; ChartValues <CustomerForTime> series = new ChartValues <CustomerForTime>(); // Periode data showned for (int iDay = 0; iDay < 10; iDay++) { listDate[iDay] = dateStart.AddDays(iDay - 9).ToString("yyyy-MM-dd"); //series.Add(0); series.Add(new CustomerForTime { Name = dateStart.AddDays(iDay - 9).ToString("yyyy-MM-dd"), Values = 0, //ValuesFormat = (int)TimeSpan.FromSeconds(0).TotalHours + "h " + TimeSpan.FromSeconds(0).ToString(@"mm") + "min" }); } // Search data in periode GameActivityClass gameActivity = GameActivityDatabases.Get(Guid.Parse(gameID)); List <Activity> gameActivities = gameActivity.Activities; for (int iActivity = 0; iActivity < gameActivities.Count; iActivity++) { long elapsedSeconds = gameActivities[iActivity].ElapsedSeconds; string dateSession = Convert.ToDateTime(gameActivities[iActivity].DateSession).ToLocalTime().ToString("yyyy-MM-dd"); for (int iDay = 0; iDay < 10; iDay++) { if (listDate[iDay] == dateSession) { string tempName = series[iDay].Name; double tempElapsed = series[iDay].Values + elapsedSeconds; series[iDay] = new CustomerForTime { Name = tempName, Values = tempElapsed, }; } } } // Set data in graphic. SeriesCollection activityForGameSeries = new SeriesCollection { new ColumnSeries { Title = "", Values = series } }; string[] activityForGameLabels = listDate; //let create a mapper so LiveCharts know how to plot our CustomerViewModel class var customerVmMapper = Mappers.Xy <CustomerForTime>() .X((value, index) => index) .Y(value => value.Values); //lets save the mapper globally Charting.For <CustomerForTime>(customerVmMapper); Func <double, string> activityForGameLogFormatter = value => (int)TimeSpan.FromSeconds(value).TotalHours + "h " + TimeSpan.FromSeconds(value).ToString(@"mm") + "min"; gameLabelsY.LabelFormatter = activityForGameLogFormatter; gameSeries.DataTooltip = new CustomerToolTipForTime(); gameLabelsY.MinValue = 0; gameLabel.Content = resources.GetString("LOCGameActivityTimeTitle"); gameSeries.Series = activityForGameSeries; gameLabelsX.Labels = activityForGameLabels; }