-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.cs
77 lines (70 loc) · 2.14 KB
/
data.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Microsoft.Win32;
namespace WindowsFormsApplication3
{
static class data
{
static public List<string> files = new List<string>();
static public int gDur = 60;
static public int mDur = 10;
static public bool randStart = false;
static public string lastFold = "";
static public bool subDir = true;
static public string song = "";
static public void loadList()
{
try
{
string[] ml = Directory.GetFiles(lastFold, "*.mp3", subDir ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
files.Clear();
files.AddRange(ml);
} catch
{
}
}
static string regKey = "SoftWare\\GuessMelody";
static public void saveReg()
{
RegistryKey rk = null;
try
{
rk = Registry.CurrentUser.CreateSubKey(regKey);
if (rk == null) return;
rk.SetValue("gDur", gDur);
rk.SetValue("mDur", mDur);
rk.SetValue("lastFold", lastFold);
rk.SetValue("randStart", randStart);
rk.SetValue("subDir", subDir);
}
finally
{
if (rk != null) rk.Close();
}
}
static public void openReg()
{
RegistryKey rk = null;
try
{
rk = Registry.CurrentUser.OpenSubKey(regKey);
if (rk != null)
{
gDur = (int)rk.GetValue("gDur");
mDur = (int)rk.GetValue("mDur");
lastFold = (string)rk.GetValue("lastFold");
randStart = Convert.ToBoolean(rk.GetValue("randStart"));
subDir = Convert.ToBoolean(rk.GetValue("subDir"));
}
}
finally
{
if (rk != null) rk.Close();
}
}
}
}