From 66d4926bba1cb32cd67ffecd8fb98b005bc89f3e Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Sat, 24 Aug 2024 14:57:01 +0900 Subject: [PATCH] Update the screen time feature --- .../WelsonJS.Service/ScreenMatching.cs | 42 +++++++++++++++++-- settings.example.ini | 2 +- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/WelsonJS.Toolkit/WelsonJS.Service/ScreenMatching.cs b/WelsonJS.Toolkit/WelsonJS.Service/ScreenMatching.cs index 72c2175..a54ff44 100644 --- a/WelsonJS.Toolkit/WelsonJS.Service/ScreenMatching.cs +++ b/WelsonJS.Toolkit/WelsonJS.Service/ScreenMatching.cs @@ -56,8 +56,9 @@ public class ScreenMatching private List templateImages; private string templateDirectoryPath; private int templateCurrentIndex = 0; - private double threshold = 0.5; - private string mode = "screen"; + private double threshold = 0.4; + private string mode; + private string[] _params; public ScreenMatching(ServiceBase parent, string workingDirectory) { @@ -65,13 +66,46 @@ public class ScreenMatching templateDirectoryPath = Path.Combine(workingDirectory, "app/assets/img/_templates"); templateImages = new List(); - SetMode("screen"); + // Read values from configration file + string mode; + string _params; + try + { + mode = this.parent.GetSettingsFileHandler().Read("SCREEN_TIME_MODE", "Service"); + _params = this.parent.GetSettingsFileHandler().Read("SCREEN_TIME_PARAMS", "Service"); + } + catch (Exception ex) + { + this.parent.Log($"Failed to read from configration file: {ex.Message}"); + } + + SetMode(mode); + SetParams(_params); LoadTemplateImages(); } public void SetMode(string mode) { - this.mode = mode; + if (!String.IsNullOrEmpty(mode)) + { + this.mode = mode; + } + else + { + this.mode = "screen"; + } + } + + public void SetParams(string[] _params) + { + if (!String.IsNullOrEmpty(mode)) + { + this._params = _params; + } + else + { + this._params = null; + } } public void SetThreshold(double threshold) diff --git a/settings.example.ini b/settings.example.ini index 9a950fb..5e5a8ca 100644 --- a/settings.example.ini +++ b/settings.example.ini @@ -8,7 +8,7 @@ NONFREE_STRICT=false ;User consent may be required when using third-party soft DISABLE_SCREEN_TIME=false DISABLE_FILE_MONITOR=false SCREEN_TIME_MODE=screen ;screen or window -SCREEN_TIME_PARAMS= +SCREEN_TIME_PARAMS= ;filename.exe GRPC_HOST=http://localhost:50051 ES_HOST=http://localhost:9200 ES_USER=elastic