Skip to content

Commit cda07d8

Browse files
committed
Use config file to store settings instead of My.Settings
1 parent 8747a28 commit cda07d8

File tree

6 files changed

+249
-385
lines changed

6 files changed

+249
-385
lines changed

src/GHOSTbackup/App.config

-52
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,8 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<configuration>
33
<configSections>
4-
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
5-
<section name="GHOSTbackup.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
6-
</sectionGroup>
74
</configSections>
85
<startup>
96
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
107
</startup>
11-
<userSettings>
12-
<GHOSTbackup.My.MySettings>
13-
<setting name="GameSavesDir" serializeAs="String">
14-
<value />
15-
</setting>
16-
<setting name="BackupDir" serializeAs="String">
17-
<value />
18-
</setting>
19-
<setting name="BackupInterval" serializeAs="String">
20-
<value>5</value>
21-
</setting>
22-
<setting name="ConfirmExit" serializeAs="String">
23-
<value>True</value>
24-
</setting>
25-
<setting name="ConfirmBackupInterruption" serializeAs="String">
26-
<value>False</value>
27-
</setting>
28-
<setting name="CheckUpdates" serializeAs="String">
29-
<value>False</value>
30-
</setting>
31-
<setting name="WriteLogFile" serializeAs="String">
32-
<value>False</value>
33-
</setting>
34-
<setting name="RememberFormPosition" serializeAs="String">
35-
<value>False</value>
36-
</setting>
37-
<setting name="WindowLocation" serializeAs="String">
38-
<value>-1, -1</value>
39-
</setting>
40-
<setting name="LogFilePath" serializeAs="String">
41-
<value />
42-
</setting>
43-
<setting name="MustUpgrade" serializeAs="String">
44-
<value>True</value>
45-
</setting>
46-
<setting name="DisableCloudSync" serializeAs="String">
47-
<value>False</value>
48-
</setting>
49-
<setting name="WhichBackup" serializeAs="String">
50-
<value>0</value>
51-
</setting>
52-
<setting name="NoUplay" serializeAs="String">
53-
<value>False</value>
54-
</setting>
55-
<setting name="CustomExeLoc" serializeAs="String">
56-
<value />
57-
</setting>
58-
</GHOSTbackup.My.MySettings>
59-
</userSettings>
608
</configuration>

src/GHOSTbackup/Form1.Designer.vb

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/GHOSTbackup/Form1.vb

+23-35
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,11 @@
11
Imports System.IO
22
Imports GHOSTbackup.BackupHelper
3-
Imports GHOSTbackup.Settings
43
Imports GHOSTbackup.Updater
54
Imports GHOSTbackup.UplayHelper
65
Imports GHOSTbackup.Var
76
Imports GHOSTbackup.WildlandsHelper
87

98
Public Class Form1
10-
Private Sub LoadFormPosition()
11-
If My.Settings.RememberFormPosition = True Then
12-
Dim FormLocation As Point = My.Settings.WindowLocation
13-
14-
If (FormLocation.X = -1) And (FormLocation.Y = -1) Then
15-
Return
16-
End If
17-
18-
Dim LocationVisible As Boolean = False
19-
For Each S As Screen In Screen.AllScreens
20-
If S.Bounds.Contains(FormLocation) Then
21-
LocationVisible = True
22-
End If
23-
Next
24-
25-
If Not LocationVisible Then
26-
Return
27-
End If
28-
29-
StartPosition = FormStartPosition.Manual
30-
Location = FormLocation
31-
End If
32-
End Sub
33-
349
Private Sub HelpToolTip_Draw(sender As Object, e As DrawToolTipEventArgs) Handles HelpToolTip.Draw
3510
'Draw tooltip with custom colors
3611
e.DrawBackground()
@@ -39,14 +14,29 @@ Public Class Form1
3914
e.DrawText()
4015
End Sub
4116

42-
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
43-
'Migrate settings from the old version
44-
UpgradeSettings()
17+
Private Sub LoadFormPosition()
18+
If Settings.RememberFormPosition = True Then
19+
Dim FormLocation As Point = Settings.FormPosition
20+
21+
If FormLocation.X <> -1 Or FormLocation.Y <> -1 Then
22+
Dim LocationVisible As Boolean = False
23+
For Each S As Screen In Screen.AllScreens
24+
If S.Bounds.Contains(FormLocation) Then
25+
LocationVisible = True
26+
End If
27+
Next
4528

46-
'Load settings and set defaults
47-
LoadSettings()
29+
If LocationVisible Then
30+
StartPosition = FormStartPosition.Manual
31+
Location = FormLocation
32+
End If
33+
End If
34+
End If
35+
End Sub
4836

49-
'Set window position
37+
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
38+
'Load settings and set defaults
39+
Settings.Init()
5040
LoadFormPosition()
5141

5242
'Start logging session
@@ -89,10 +79,10 @@ Public Class Form1
8979
If CustomMsgBox.DialogResult = DialogResult.No OrElse CustomMsgBox.DialogResult = DialogResult.Cancel Then
9080
e.Cancel = True
9181
Else
92-
SaveSettings()
82+
Settings.Save()
9383
End If
9484
Else
95-
SaveSettings()
85+
Settings.Save()
9686
End If
9787
End Sub
9888

@@ -430,7 +420,6 @@ Public Class Form1
430420
O.Description = "Select where you want to save the event log file to."
431421
If O.ShowDialog = DialogResult.OK Then
432422
SettingsLogFilePathTextBox.Text = O.SelectedPath & "\event.log"
433-
My.Settings.LogFilePath = SettingsLogFilePathTextBox.Text
434423
Logger.Log("[INFO] Log file path set to: " & SettingsLogFilePathTextBox.Text)
435424
End If
436425
End Using
@@ -465,7 +454,6 @@ Public Class Form1
465454
O.Title = "Select Wildlands executable"
466455
If O.ShowDialog = DialogResult.OK Then
467456
SettingsCustomExeTextBox.Text = O.FileName
468-
My.Settings.CustomExeLoc = SettingsCustomExeTextBox.Text
469457
Logger.Log("[INFO] Custom Wildlands executable set: " & O.FileName)
470458
End If
471459
End Using

src/GHOSTbackup/My Project/Settings.Designer.vb

-180
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)