001.
using
System;
002.
using
System.Collections.Generic;
003.
using
System.ComponentModel;
004.
using
System.Data;
005.
using
System.Drawing;
006.
using
System.Linq;
007.
using
System.Text;
008.
using
System.Windows.Forms;
009.
010.
namespace
NCN_Mng
011.
{
012.
public
partial
class
Form1 : Form
013.
{
014.
public
Form1()
015.
{
016.
InitializeComponent();
017.
}
018.
019.
List<
string
> lstLYR;
020.
List<
string
> lstEMK;
021.
022.
string
[] Symbol =
new
string
[] {
"0"
,
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
,
"7"
,
"8"
,
"9"
,
"A"
,
"B"
,
"C"
,
"D"
,
"E"
,
"F"
,
"G"
,
"H"
,
"I"
,
"J"
,
"K"
,
"L"
,
"M"
,
"N"
,
"O"
,
"P"
,
"Q"
,
"R"
,
"S"
,
"T"
,
"U"
,
"V"
,
"W"
,
"X"
,
"Y"
,
"Z"
};
023.
024.
private
void
button1_Click(
object
sender, EventArgs e)
025.
{
026.
FolderBrowserDialog fol =
new
FolderBrowserDialog();
027.
fol.ShowDialog();
028.
textBox1.Text = fol.SelectedPath;
029.
}
030.
031.
private
void
button2_Click(
object
sender, EventArgs e)
032.
{
033.
FolderBrowserDialog fol =
new
FolderBrowserDialog();
034.
fol.ShowDialog();
035.
textBox2.Text = fol.SelectedPath;
036.
}
037.
038.
private
void
button3_Click(
object
sender, EventArgs e)
039.
{
040.
lstLYR = System.IO.Directory.GetFiles(textBox1.Text,
"*.LYR"
, System.IO.SearchOption.AllDirectories).ToList<
string
>();
041.
lstEMK = System.IO.Directory.GetFiles(textBox1.Text,
"*.EMK"
, System.IO.SearchOption.AllDirectories).ToList<
string
>();
042.
label3.Text =
"file LYR ทั้งหมด "
+ (lstLYR.Count - 1) +
" ไฟล์."
+ Environment.NewLine +
"file EMK ทั้งหมด "
+ (lstEMK.Count - 1) +
" ไฟล์."
;
043.
progressBar1.Maximum = lstLYR.Count - 1;
044.
progressBar2.Maximum = lstEMK.Count - 1;
045.
}
046.
047.
private
void
button4_Click(
object
sender, EventArgs e)
048.
{
049.
050.
new
System.Threading.Thread(SetSongNCN).Start();
051.
new
System.Threading.Thread(SetSongEMK).Start();
052.
}
053.
void
SetSongNCN()
054.
{
055.
056.
int
iSymbol = 0, nsong = 0;
057.
foreach
(
string
s
in
Symbol)
058.
{
059.
System.IO.Directory.CreateDirectory(textBox2.Text +
"\\Cursor\\"
+ s);
060.
System.IO.Directory.CreateDirectory(textBox2.Text +
"\\Lyrics\\"
+ s);
061.
System.IO.Directory.CreateDirectory(textBox2.Text +
"\\Song\\"
+ s);
062.
}
063.
064.
string
s_S =
""
, t_S =
""
, s_L =
""
, t_L =
""
, s_C =
""
, t_C =
""
;
065.
066.
for
(
int
i = 0; i < lstLYR.Count - 1; i++)
067.
{
068.
069.
s_L = lstLYR[i].ToLower();
070.
s_S = s_L.Replace(
"\\lyrics\\", "
\\song\\
").Replace("
.lyr
", "
.mid");
071.
s_C = s_L.Replace(
"\\lyrics\\", "
\\cursor\\
").Replace("
.lyr
", "
.cur");
072.
073.
074.
if
(System.IO.File.Exists(s_C) && System.IO.File.Exists(s_S))
075.
{
076.
do
077.
{
078.
if
(nsong > 20000) { iSymbol++; nsong = 0; }
079.
t_S = textBox2.Text +
"\\Song\\" + Symbol[iSymbol] + "
\\
" + Symbol[iSymbol] + string.Format("
{0:00000}
", nsong) + "
.mid";
080.
t_C = textBox2.Text +
"\\Cursor\\" + Symbol[iSymbol] + "
\\
" + Symbol[iSymbol] + string.Format("
{0:00000}
", nsong) + "
.cur";
081.
t_L = textBox2.Text +
"\\Lyrics\\" + Symbol[iSymbol] + "
\\
" + Symbol[iSymbol] + string.Format("
{0:00000}
", nsong) + "
.lyr";
082.
nsong++;
083.
}
while
(System.IO.File.Exists(t_L) || System.IO.File.Exists(t_C) || System.IO.File.Exists(t_S));
084.
085.
086.
try
{ System.IO.File.Move(s_S, t_S); System.IO.File.Move(s_C, t_C); System.IO.File.Move(s_L, t_L); }
087.
catch
{ }
088.
}
089.
try
090.
{
091.
092.
label4.Invoke(
new
Action(() => { label4.Text =
"Move"
+ s_L + Environment.NewLine + t_L; }));
093.
progressBar1.Invoke(
new
Action(() => { progressBar1.Value = i; }));
094.
}
095.
catch
{ }
096.
097.
System.Threading.Thread.Sleep(50);
098.
099.
100.
}
101.
}
102.
void
SetSongEMK()
103.
{
104.
105.
int
iSymbol = 0,nsong = 0;
106.
foreach
(
string
s
in
Symbol)
107.
{
108.
System.IO.Directory.CreateDirectory(textBox2.Text +
"\\EMK\\"
+ s);
109.
}
110.
111.
string
s_E =
""
, t_E =
""
;
112.
113.
for
(
int
i = 0; i < lstEMK.Count - 1; i++)
114.
{
115.
116.
s_E = lstEMK[i].ToLower();
117.
118.
119.
120.
do
121.
{
122.
if
(nsong > 20000) { iSymbol++; nsong = 0; }
123.
t_E = textBox2.Text +
"\\EMK\\" + Symbol[iSymbol] + "
\\
" + Symbol[iSymbol] + string.Format("
{0:00000}
", nsong) + "
.EMK";
124.
nsong++;
125.
}
while
( System.IO.File.Exists(t_E));
126.
127.
128.
try
{ System.IO.File.Move(s_E, t_E); }
129.
catch
{ }
130.
131.
try
132.
{
133.
134.
label5.Invoke(
new
Action(() => { label5.Text =
"Move"
+ s_E + Environment.NewLine + t_E; }));
135.
progressBar2.Invoke(
new
Action(() => { progressBar2.Value =i; }));
136.
}
137.
catch
{ }
138.
System.Threading.Thread.Sleep(50);
139.
}
140.
}
141.
}
142.
}