/// <summary> /// You must pass the smallest timeframe the software will watch for. /// Eg.: If set to TEN_MINUTES, then one mouse movement or keypress in that timeframe /// will be considered an active time. /// DataPrecision is not implemented fully, only High precision works /// </summary> /// <param name="appName">If saving is enabled the resulting file will have this as prefix</param> /// <param name="resolution">The smallest timeframe the software will watch for</param> /// <param name="savePreference">Dictates how usage data will be saved/stored</param> /// <param name="dataPrecision">Sets how fine grained the data will be</param> public Watcher(string appName, Resolution chosenResolution, SavePreference preference, DataPrecision dataPrecision) { ISaveService saveService = new SaveService(appName, preference, dataPrecision); IUsageToday today = (IUsageToday)CreateOrLoadKeeper(ref saveService, dataPrecision, chosenResolution, SaveType.Today); IUsageArchive archive = (IUsageArchive)CreateOrLoadKeeper(ref saveService, dataPrecision, chosenResolution, SaveType.Archive); IStorage store = new UsageStorage(ref today, ref archive, ref saveService); wService = new WatcherService(ref store); }
public UsageStorage(ref IUsageToday usageToday, ref IUsageArchive usageArchive, ref ISaveService saveService) { this.usageToday = usageToday ?? throw new ArgumentNullException(nameof(usageToday)); this.usageArchive = usageArchive ?? throw new ArgumentNullException(nameof(usageArchive)); this.saveService = saveService ?? throw new ArgumentNullException(nameof(saveService)); noArchiveList = new List <SavePreference>() { SavePreference.KeepDataForToday, SavePreference.NoSave }; SystemEvents.SessionSwitch += new SessionSwitchEventHandler(OnWindowsLockUnlock); usageTimer = new UsageTimer(usageToday.GetCurrentResolution()); saveTimer = new SaveTimer(); saveTimer.Elapsed += SaveTimer_Elapsed; }