/
Form1.cs
99 lines (81 loc) · 2.97 KB
/
Form1.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
89
90
91
92
93
94
95
96
97
using System;
using System.IO;
using System.Windows.Forms;
namespace TagEdit
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
listView1.Columns.Add("Title");
listView1.Columns.Add("Album");
listView1.Columns.Add("Extension");
listView1.Columns.Add("Path");
listView1.Columns[0].Width = 200;
listView1.Columns[1].Width = 110;
listView1.Columns[2].Width = 90;
listView1.View = View.Details;
this.FormBorderStyle = FormBorderStyle.FixedSingle;
this.MinimizeBox = false;
//saveDataBtn.Enabled = false;
}
private void button1_Click(object sender, EventArgs e)
{
using (FolderBrowserDialog dialog = new FolderBrowserDialog())
{
if (dialog.ShowDialog() == DialogResult.OK)
{
foreach (var file in Directory.GetFiles(dialog.SelectedPath))
{
var tFile = TagLib.File.Create(file);
var info = new FileInfo(file.ToString());
string name = info.Name;
ListViewItem item = new ListViewItem(tFile.Tag.Title);
item.SubItems.Add(tFile.Tag.Album);
item.SubItems.Add(info.Extension);
item.SubItems.Add(Path.GetFullPath(file));
listView1.Items.Add(item);
}
}
}
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
foreach (ListViewItem item in listView1.SelectedItems)
{
var tFile = TagLib.File.Create(item.SubItems[3].Text);
albumBox.Text = tFile.Tag.Album.ToString();
titleBox.Text = tFile.Tag.Title.ToString();
artistBox.Text = tFile.Tag.Performers.ToString();
pathBox.Text = item.SubItems[3].Text;
}
}
/*
* The function below receives the path from the third column
* and writes the information to the file and then saves the file.
*/
private void button2_Click(object sender, EventArgs e)
{
foreach (ListViewItem item in listView1.SelectedItems)
{
var tFile = TagLib.File.Create(item.SubItems[3].Text);
tFile.Tag.Album = albumBox.Text;
tFile.Tag.Title = titleBox.Text;
tFile.Tag.Performers = new string[] { artistBox.Text };
//pathBox.Text = item.SubItems[3].Text;
tFile.Save();
}
}
}
public class ListItem
{
public string Name;
public string Album;
public string Value;
public override string ToString()
{
return Name;
}
}
}