File tree 3 files changed +30
-19
lines changed
3 files changed +30
-19
lines changed Original file line number Diff line number Diff line change @@ -30,11 +30,21 @@ public void Terminate(bool waitForExit = false)
30
30
{
31
31
var process = GetClientProcess ( ) ;
32
32
33
- process ? . CloseMainWindow ( ) ;
34
-
35
- if ( waitForExit )
33
+ if ( process != null )
36
34
{
37
- process ? . WaitForExit ( ) ;
35
+ if ( settingsService . Settings ! . ReolinkClientGracefulExit )
36
+ {
37
+ process . CloseMainWindow ( ) ;
38
+ }
39
+ else
40
+ {
41
+ process . Kill ( ) ;
42
+ }
43
+
44
+ if ( waitForExit )
45
+ {
46
+ process . WaitForExit ( ) ;
47
+ }
38
48
}
39
49
}
40
50
Original file line number Diff line number Diff line change 2
2
{
3
3
public class Settings
4
4
{
5
- public required string ReolinkExecutableFilePath { get ; set ; }
5
+ public string ReolinkExecutableFilePath { get ; set ; } = @"%localAppData%\Programs\Reolink\Reolink.exe" ;
6
6
7
- public required int RestartIntervalMinutes { get ; set ; }
7
+ public int RestartIntervalMinutes { get ; set ; } = 60 ;
8
8
9
- public required bool UseFullscreen { get ; set ; }
9
+ public bool UseFullscreen { get ; set ; } = true ;
10
10
11
- public required int FullscreenDelaySeconds { get ; set ; }
11
+ public int FullscreenDelaySeconds { get ; set ; } = 4 ;
12
12
13
- public required int FullscreenXOffset { get ; set ; }
13
+ public int FullscreenXOffset { get ; set ; } = 50 ;
14
14
15
- public required int FullscreenYOffset { get ; set ; }
15
+ public int FullscreenYOffset { get ; set ; } = 40 ;
16
+
17
+ public bool ReolinkClientGracefulExit { get ; set ; } = true ;
16
18
}
17
19
}
Original file line number Diff line number Diff line change @@ -28,16 +28,12 @@ public bool ValidateAndLoadSettings(out string? message)
28
28
29
29
private void CreateSettings ( )
30
30
{
31
- var settings = new Settings
32
- {
33
- ReolinkExecutableFilePath = @"%localAppData%\Programs\Reolink\Reolink.exe" ,
34
- RestartIntervalMinutes = 60 ,
35
- UseFullscreen = true ,
36
- FullscreenDelaySeconds = 4 ,
37
- FullscreenXOffset = 50 ,
38
- FullscreenYOffset = 40
39
- } ;
31
+ var settings = new Settings ( ) ;
32
+ WriteSettings ( settings ) ;
33
+ }
40
34
35
+ private void WriteSettings ( Settings settings )
36
+ {
41
37
var json = JsonSerializer . Serialize ( settings , new JsonSerializerOptions { WriteIndented = true } ) ;
42
38
File . WriteAllText ( SettingsFileName , json ) ;
43
39
}
@@ -47,6 +43,9 @@ private void LoadSettings()
47
43
var json = File . ReadAllText ( SettingsFileName ) ;
48
44
Settings = JsonSerializer . Deserialize < Settings > ( json ) ! ;
49
45
46
+ // Write the settings back in-case there are new options
47
+ WriteSettings ( Settings ) ;
48
+
50
49
Settings ! . ReolinkExecutableFilePath = Environment . ExpandEnvironmentVariables ( Settings . ReolinkExecutableFilePath ) ;
51
50
}
52
51
You can’t perform that action at this time.
0 commit comments