コード例 #1
0
        private void OnDateChanged(DateTime?date)
        {
            PowerLogs.Clear();
            Rounding.Value = PreferenceService.Preference.Rounding;
            var summary = new PowerLogEntry();

            if (date.HasValue)
            {
                var entries = PowerLogService.GetPowerLogEntries(date.Value);
                PowerLogs.AddRange(entries);
                if (PowerLogs.Count > 0)
                {
                    var startTime = PowerLogs.FirstOrDefault(x => x.StartTime != null)?.StartTime;
                    if (startTime.HasValue)
                    {
                        summary.StartTime = PowerLogService.GetNormalizeStart(startTime.Value);
                    }
                    var endTime = PowerLogs.Reverse().FirstOrDefault(x => x.EndTime != null)?.EndTime;
                    if (endTime.HasValue)
                    {
                        summary.EndTime = PowerLogService.GetNormalizeEnd(endTime.Value);
                    }
                }
            }
            Summary.Value = summary;
        }