コード例 #1
0
        public TimeInfoViewModel(
            [NotNull] ILog logger,
            [NotNull] IActivityProcessor activityProcessor,
            [NotNull] IReportSerializer reportSerializer,
            [NotNull] IStatusChangeEventRepository statusChangeEventRepository)
        {
            _statusChangeEventRepository = statusChangeEventRepository ?? throw new ArgumentNullException(nameof(statusChangeEventRepository));
            activityProcessor            = activityProcessor ?? throw new ArgumentNullException(nameof(activityProcessor));

            ToggleCommand = new CorrelationCommand <ActivityReportItemViewModel>(Toggle);
            _report       = activityProcessor.GenerateReport(DateTime.Now);
            _timer        = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(1)
            };
            _timer.Start();
            _report = activityProcessor.GenerateReport(DateTime.Now);
            ActivityReportItems.Clear();
            foreach (var viewModelItem in _report.Items.Select(item => new ActivityReportItemViewModel(item)))
            {
                ActivityReportItems.Add(viewModelItem);
            }

            SetCurrentTimeInfo();
            _timer.Tick += Timer_Tick;
        }
コード例 #2
0
 public ActivityProcessor([NotNull] IStatusChangeEventRepository statusChangeEventRepository)
 {
     _statusChangeEventRepository = statusChangeEventRepository ?? throw new ArgumentNullException(nameof(statusChangeEventRepository));
     SystemEvents.SessionSwitch  += SystemEvents_SessionSwitch;
 }