public Coach(Profile userProfile, TipStore tips) : this(userProfile, tips, new TipScheduler(userProfile, tips), new List <Monitor> { new MoodMonitor(userProfile), new ActivityMonitor(userProfile) } ) { }
public Coach(Profile userProfile, TipStore tips, TipScheduler tipScheduler, List <Monitor> monitors) { UserProfile = userProfile; Tips = tips; Scheduler = tipScheduler; Monitors = monitors; NotificationCenter.NotificationRecieved += async(sender, e) => { await PerformChecks(false); }; }
public TipScheduler(Profile profile, TipStore tips, List <TimeSpan> initTimes = null) { this.profile = profile; this.tips = tips; this.schedule = Preferences.GetOr(profile.ID + "_schedule", new TipSchedule()); this.times = new ObservableCollection <TimeSpan>(); PropertyChanged += (sender, e) => { if (e.PropertyName == "CurrentTipID") { var tde = new DisplayTipEvent(CurrentTipID); profile.Add(tde); schedule.CheckFrom = tde.Time; SaveSchedule(); if (NewTip != null) { NewTip(this, new NewTipEventArgs { Tip = tips.Get(CurrentTipID) }); } } }; schedule.Times.Add(initTimes); if (schedule.Tips == null || CurrentTipID == 0) { BuildSchedule(); SetNextTip(); } /* else * { * lastTipTime = profile.QueryEvents().Where(e => e.Type == typeof(TipDisplayEvent).Name) * .OrderByDescending(e => e.Time).First().Time; * } */ tips.EnabledChange += (sender, e) => { BuildSchedule(); }; this.times.Add(schedule.Times); }