static void Main(string[] args) { var awtWatch = AutoHotKeyObservable.WatchAwt(TimeSpan.FromMilliseconds(2000)); var windows = awtWatch.OfType <ProcessInfo>().Select(p => p.ToString()).DistinctUntilChanged(); var personActive = awtWatch.MouseMoving().PersonActive(); var all = windows.CombineLatest(personActive, (w, a) => a == PersonInfo.ActiveStatus.Active ? w : a.ToString()). CombineLatest(SessionObservable.SessionSwitched(), (w, s) => s == SessionSwitchReason.SessionUnlock ? w : s.ToString()). TimeInterval().HowLongHas("Active"); using (all.Dump("Windows")) { Console.ReadKey(); } }
internal void Load() { Questions = new ObservableDictionary <Work, Project>(); var awtWatch = AutoHotKeyObservable.WatchAwt(TimeSpan.FromMilliseconds(2000)); var windows = awtWatch.OfType <ProcessInfo>().Select(p => p.ToString()).DistinctUntilChanged(); var personActive = awtWatch.MouseMoving().PersonActive(); PublicEvents = windows.CombineLatest(personActive, (w, a) => a == PersonInfo.ActiveStatus.Active ? w : a.ToString()). CombineLatest(SessionObservable.SessionSwitched(), (w, s) => s == SessionSwitchReason.SessionUnlock ? w : s.ToString()). TimeInterval().HowLongHas("Active").Timestamp().Select(i => { return(new Timestamped <TimeInterval <string> >(i.Value, i.Timestamp.RoundDown())); }).Publish(); WhatWereYouDoing = PublicEvents.Where(evt => { return(!Rules. Where(r => r.Enabled). Where(r => evt.Timestamp.TimeOfDay >= r.From). Where(r => evt.Timestamp.TimeOfDay <= r.To). Where(r => r.Comparison == RuleType.Equals). Where(r => r.What == evt.Value.Value).Any()); }).ObserveOnDispatcher().Subscribe((i) => { Work w = new Work() { What = i.Value.Value, When = i.Timestamp.ToLocalTime() }; if (Questions.ContainsKey(w)) { Questions[w].Interval += i.Value.Interval; } else { Questions.Add(w, new Project(i.Value.Interval, w)); } }); PublicEventConnection = PublicEvents.Connect(); }