forked from Jessecar96/SteamDesktopAuthenticator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SettingsForm.cs
73 lines (60 loc) · 2.55 KB
/
SettingsForm.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
63
64
65
66
67
68
69
70
71
72
73
using System;
using System.Windows.Forms;
namespace Steam_Desktop_Authenticator
{
public partial class SettingsForm : Form
{
Manifest manifest;
bool fullyLoaded = false;
public SettingsForm()
{
InitializeComponent();
// Get latest manifest
manifest = Manifest.GetManifest(true);
chkPeriodicChecking.Checked = manifest.PeriodicChecking;
numPeriodicInterval.Value = manifest.PeriodicCheckingInterval;
chkCheckAll.Checked = manifest.CheckAllAccounts;
chkConfirmMarket.Checked = manifest.AutoConfirmMarketTransactions;
chkConfirmTrades.Checked = manifest.AutoConfirmTrades;
SetControlsEnabledState(chkPeriodicChecking.Checked);
fullyLoaded = true;
}
private void SetControlsEnabledState(bool enabled)
{
numPeriodicInterval.Enabled = chkCheckAll.Enabled = chkConfirmMarket.Enabled = chkConfirmTrades.Enabled = enabled;
}
private void ShowWarning(CheckBox affectedBox)
{
if (!fullyLoaded) return;
var result = MessageBox.Show("Warning: enabling this will severely reduce the security of your items! Use of this option is at your own risk. Would you like to continue?", "Warning!", MessageBoxButtons.YesNo);
if (result == DialogResult.No)
{
affectedBox.Checked = false;
}
}
private void btnSave_Click(object sender, EventArgs e)
{
manifest.PeriodicChecking = chkPeriodicChecking.Checked;
manifest.PeriodicCheckingInterval = (int)numPeriodicInterval.Value;
manifest.CheckAllAccounts = chkCheckAll.Checked;
manifest.AutoConfirmMarketTransactions = chkConfirmMarket.Checked;
manifest.AutoConfirmTrades = chkConfirmTrades.Checked;
manifest.Save();
this.Close();
}
private void chkPeriodicChecking_CheckedChanged(object sender, EventArgs e)
{
SetControlsEnabledState(chkPeriodicChecking.Checked);
}
private void chkConfirmMarket_CheckedChanged(object sender, EventArgs e)
{
if (chkConfirmMarket.Checked)
ShowWarning(chkConfirmMarket);
}
private void chkConfirmTrades_CheckedChanged(object sender, EventArgs e)
{
if (chkConfirmTrades.Checked)
ShowWarning(chkConfirmTrades);
}
}
}