コード例 #1
0
        private void LoadTimeStatisticFromJson(string path)
        {
            if (String.IsNullOrWhiteSpace(path) || !File.Exists(path))
            {
                return;
            }

            DailyTimeStatistic ingametime = null;

            using (var reader = new StreamReader(path)) {
                ingametime = JsonConvert.DeserializeObject <DailyTimeStatistic>(reader.ReadToEnd());
            }

            lock (statisticThreadLock) {
                this.DailyTimeStatistics.Add(ingametime);
            }
        }
コード例 #2
0
        private DailyTimeStatistic AddDaily()
        {
            string date = Utils.DateUtils.GetTodaysDate();

            foreach (var entry in this.mainWindow.DailyTimeStatistics)
            {
                if (date == entry.Date)
                {
                    return(entry);
                }
            }
            var newDaily = new DailyTimeStatistic();
            List <DailyTimeStatistic> tempList = new List <DailyTimeStatistic>(mainWindow.DailyTimeStatistics)
            {
                newDaily
            };

            tempList = tempList.OrderByDescending(s => s.Date).ToList();
            this.mainWindow.DailyTimeStatistics = new System.Collections.ObjectModel.ObservableCollection <DailyTimeStatistic>(tempList);
            this.TimeStatisticsView.ItemsSource = this.mainWindow.DailyTimeStatistics;
            this.TimeStatisticsView.Items.Refresh();
            this.TimeStatisticsView.UpdateLayout();
            return(newDaily);
        }