private static IUsageKeeper CreateOrLoadKeeper(ref ISaveService saveService, DataPrecision dataPrecision, Resolution chosenResolution, SaveType saveType) { IUsageKeeper keeper = saveService.GetSavedUsages(saveType); if (keeper == null) { if (dataPrecision == DataPrecision.High) { if (saveType == SaveType.Today) { keeper = new HighPrecisionUsageToday(chosenResolution); } else { keeper = new HighPrecisionUsageArchive(); } } else { throw new NotImplementedException(); } } return(keeper); }
/// <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); IUsageKeeper keeper = CreateKeeper(ref saveService, dataPrecision, chosenResolution); IStorage store = new UsageStore(keeper); wService = new WatcherService(ref store, ref saveService); }
public MouseDetector(Resolution resolution, DataPrecision precision) { lastMousePos = MouseDetector.GetMousePosition(); double frequency = CalcTimerFrequency(resolution, precision); timer = new Timer(frequency); timer.Elapsed += Timer_Elapsed; timer.AutoReset = true; timer.Start(); }
/// <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); }
private static IUsageKeeper CreateKeeper(ref ISaveService saveService, DataPrecision dataPrecision, Resolution chosenResolution) { IUsageKeeper keeper = saveService.GetSavedUsages(); if (keeper == null) { switch (dataPrecision) { case DataPrecision.HighPrecision: keeper = new HighPrecisionUsageKeeper(chosenResolution); break; case DataPrecision.LowPrecision: throw new NotImplementedException(); //break; default: break; } } return(keeper); }
private static double CalcTimerFrequency(Resolution resolution, DataPrecision precision) { double slashAmount = precision == DataPrecision.HighPrecision ? 4 : 2; return((double)resolution / slashAmount); }
public SaveService(string savePrefix, SavePreference preference, DataPrecision precision) { this.savePrefix = savePrefix; this.preference = preference; this.precision = precision; }
public SaveService(string appName, SavePreference preference, DataPrecision precision) { this.appName = appName; this.preference = preference; this.precision = precision; }