Update the screen time feature

This commit is contained in:
Namhyeon Go 2024-08-24 14:57:01 +09:00
parent 7b62e47fd2
commit 66d4926bba
2 changed files with 39 additions and 5 deletions

View File

@ -56,8 +56,9 @@ public class ScreenMatching
private List<Bitmap> 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<Bitmap>();
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)

View File

@ -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