-
Notifications
You must be signed in to change notification settings - Fork 3
/
frmSettings.cs
88 lines (77 loc) · 2.68 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MiniPlayerClassic.Core;
namespace MiniPlayerClassic
{
public partial class frmSettings : Form
{
ConfigManager conmgr;
public frmSettings(ConfigManager configManager)
{
InitializeComponent();
this.conmgr = configManager;
}
private void frmSettings_Load(object sender, EventArgs e)
{
if (!conmgr.Read())
{
conmgr.SetDefault();
if (!conmgr.Save())
{
MessageBox.Show("配置文件读取出错。");
Dispose();
return;
}
}
refreshInterface();
}
private void refreshInterface()
{
chkDevelopMode.Checked = conmgr.IsDeveloperMode;
chkCreateWhenOpen.Checked = conmgr.NewListAtLaunch;
chkForceWindow.Checked = conmgr.WindowAlwaysTop;
chkRemeberLast.Checked = conmgr.RememberLists;
tbListFolder.Text = conmgr.ListFilesPath;
}
private void label1_Click_1(object sender, EventArgs e)
{
MessageBox.Show("启动一些开发的时候会用到的功能\n可能会影响正常使用\n不建议正常使用时开启。\n\n这些功能有:\n"+
"在终端显示键盘按键值"+
"在终端显示窗体高度");
}
private void btnOK_Click(object sender, EventArgs e)
{
conmgr.IsDeveloperMode = chkDevelopMode.Checked;
conmgr.NewListAtLaunch = chkCreateWhenOpen.Checked;
conmgr.WindowAlwaysTop = chkForceWindow.Checked;
conmgr.RememberLists = chkRemeberLast.Checked;
conmgr.ListFilesPath = tbListFolder.Text;
if(!conmgr.Save()) MessageBox.Show("保存失败");
Dispose();
}
private void btnReset_Click(object sender, EventArgs e)
{
conmgr.SetDefault();
refreshInterface();
}
private void frmSettings_FormClosing(object sender, FormClosingEventArgs e)
{
}
private void btnSelectFolder_Click(object sender, EventArgs e)
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
fbd.ShowDialog(this);
if(fbd.SelectedPath != "")
{
conmgr.ListFilesPath = fbd.SelectedPath;
tbListFolder.Text = fbd.SelectedPath;
}
}
}
}