-
Notifications
You must be signed in to change notification settings - Fork 4
/
Descriptor.cs
executable file
·108 lines (84 loc) · 3.03 KB
/
Descriptor.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
98
99
100
101
102
103
104
105
106
107
108
using System;
using System.Collections.Generic;
using System.Text;
namespace MarkAble2
{
public class Descriptor
{
//these are for use in making example strings
private const int exampleDiscNum = 3;
private const int exampleTrackNum = 5;
private const string exampleArtist = "H.G.Wells";
private const string exampleAlbum = "The Time Machine";
private const string exampleSong = "The White Sphinx";
private const string exampleFile = "tm_chap3";
private const string exampleParent = "folder1";
public string Artist = "";
public string Album = "";
public string SongTitle = "";
public string FileName = "";
public string ParentFolder = "";
public int DiscNumber = 1;
public int TrackNumber = 1;
public Descriptor()
{
}
public void UseAudioCDExampleData()
{
Artist = exampleArtist;
Album = exampleAlbum;
DiscNumber = exampleDiscNum;
TrackNumber = exampleTrackNum;
FileName = "";
SongTitle = "Track 05";
ParentFolder = "";
}
public void UseSeparateExampleData()
{
Artist = exampleArtist;
Album = exampleAlbum;
SongTitle = exampleSong;
DiscNumber = 1;
TrackNumber = 3;
FileName = exampleFile;
ParentFolder = exampleParent;
}
public string QualifyString(string astring)
{
var sb = new StringBuilder();
sb.Append(astring);
sb.Replace("%S", SongTitle);
sb.Replace("%s", SongTitle);
sb.Replace("%A", Artist);
sb.Replace("%a", Artist);
sb.Replace("%B", Album);
sb.Replace("%b", Album);
sb.Replace("%F", FileName);
sb.Replace("%f", FileName);
sb.Replace("%P", ParentFolder);
sb.Replace("%p", ParentFolder);
sb.Replace("%D", DiscNumber.ToString());
sb.Replace("%d", DiscNumber.ToString());
sb.Replace("%T", TrackNumber.ToString());
sb.Replace("%t", TrackNumber.ToString());
return sb.ToString();
}
//this version doesn't insert book title (album) or author (artist), so we can defer this until we have it.
public string PartQualifyString(string astring)
{
var sb = new StringBuilder();
sb.Append(astring);
sb.Replace("%S", SongTitle);
sb.Replace("%s", SongTitle);
sb.Replace("%F", FileName);
sb.Replace("%f", FileName);
sb.Replace("%P", ParentFolder);
sb.Replace("%p", ParentFolder);
sb.Replace("%D", DiscNumber.ToString());
sb.Replace("%d", DiscNumber.ToString());
sb.Replace("%T", TrackNumber.ToString());
sb.Replace("%t", TrackNumber.ToString());
return sb.ToString();
}
}
}