-
Notifications
You must be signed in to change notification settings - Fork 5
/
FileRecord.cs
executable file
·108 lines (88 loc) · 2.88 KB
/
FileRecord.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;
using System.IO;
//using System.Xml.Serialization;
namespace MarkAble2
{
[System.Xml.Serialization.XmlInclude(typeof(CDTrackRecord))]
[System.Xml.Serialization.XmlInclude(typeof(SeparateRecord))]
public abstract class FileRecord
{
[System.Xml.Serialization.XmlAttribute]
public Global.FileTypes FileType = Global.FileTypes.AAC;
//this is what we'll use for chapter stops
[System.Xml.Serialization.XmlAttribute]
public string ChapterName = "";
[System.Xml.Serialization.XmlAttribute]
public string FilePath { get; set; }
[System.Xml.Serialization.XmlElement]
public long DurationTicks;
[System.Xml.Serialization.XmlIgnore]
public TimeSpan Duration
{
get { return new TimeSpan(DurationTicks); }
set
{
DurationTicks = value.Ticks;
}
}
[System.Xml.Serialization.XmlIgnore]
public long CumulativeTicks = 0;
[System.Xml.Serialization.XmlIgnore]
public TimeSpan CumulativeDuration
{
get { return new TimeSpan(CumulativeTicks); }
set
{
CumulativeTicks = value.Ticks;
}
}
[System.Xml.Serialization.XmlElement]
public long Size = 0;
public FileRecord()
{
FilePath = "";
}
public enum StringTypes
{
FullPath,
FileName,
Trimmed,
ChapterName
}
[System.Xml.Serialization.XmlIgnore]
public StringTypes StringType = StringTypes.FullPath;
public override string ToString()
{
switch(StringType)
{
case StringTypes.FullPath:
return FilePath;
case StringTypes.FileName:
return Global.GetFilename(FilePath, true);
case StringTypes.Trimmed:
return TrimmedPath(85);
case StringTypes.ChapterName:
return ChapterName;
default:
return base.ToString();
}
}
private string TrimmedPath(int maxlen)
{
if ((maxlen < 23) || (FilePath.Length <= maxlen))
{
return FilePath;
}
string path = Global.GetPath(FilePath);
string fname = @"\" + Global.GetFilename(FilePath, true);
if (fname.Length >= (maxlen - 3))
return "..." + fname;
int maxpath = maxlen - fname.Length - 3;
if ((maxpath % 2 == 1) && (maxpath > 2))
maxpath--;
return path.Substring(0, (maxpath/2)) + "..." + path.Substring(path.Length - (maxpath/2)) + fname;
}
}
}