-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrmSettings.cs
62 lines (53 loc) · 1.62 KB
/
frmSettings.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.IO;
using System.Windows.Forms;
using DCS_Module_Manager.Properties;
namespace DCS_Module_Manager
{
public partial class FrmSettings : Form
{
public FrmSettings()
{
InitializeComponent();
}
private void btnSave_Click(object sender, EventArgs e)
{
bool anyFail = false;
string dcsInstallPath = txtPath.Text;
if (validateInstallPath(dcsInstallPath))
{
Settings.Default.dcsInstallPath = dcsInstallPath;
}
else
{
txtPath.Text = "";
anyFail = true;
}
Settings.Default.Save();
if (!anyFail)
{
Close();
}
}
private bool validateInstallPath(string path)
{
if (!Directory.Exists(path))
{
MessageBox.Show(@"Install Path: Folder does no exist", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
string dcsUpdaterPath = $@"{path}\Bin\DCS_Updater.exe";
if (!File.Exists(dcsUpdaterPath))
{
MessageBox.Show(@"Install Path: Cannot find DCS_Updater.exe", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
return true;
}
private void FrmSettings_Load(object sender, EventArgs e)
{
Settings.Default.Reload();
txtPath.Text = Settings.Default.dcsInstallPath;
}
}
}