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 109
|
/***************************************************************************
copyright : (C) 2005 by Brian Nickel
email : brian.nickel@gmail.com
based on : tag.cpp from TagLib
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
* USA *
***************************************************************************/
namespace TagLib
{
public class Tag
{
public virtual string Title {get {return null;} set {}}
public virtual string [] Artists {get {return new string [] {};} set {}}
public virtual string [] Performers {get {return new string [] {};} set {}}
public virtual string [] Composers {get {return new string [] {};} set {}}
public virtual string Album {get {return null;} set {}}
public virtual string Comment {get {return null;} set {}}
public virtual string [] Genres {get {return new string [] {};} set {}}
public virtual uint Year {get {return 0;} set {}}
public virtual uint Track {get {return 0;} set {}}
public virtual uint TrackCount {get {return 0;} set {}}
public virtual uint Disc {get {return 0;} set {}}
public virtual uint DiscCount {get {return 0;} set {}}
public virtual IPicture [] Pictures { get { return new Picture [] { }; } set { } }
public string FirstArtist { get { return FirstInGroup(Artists); } }
public string FirstPerformer { get { return FirstInGroup(Performers); } }
public string FirstComposer { get { return FirstInGroup(Composers); } }
public string FirstGenre { get { return FirstInGroup(Genres); } }
public string JoinedArtists { get { return JoinGroup(Artists); } }
public string JoinedPerformers { get { return JoinGroup(Performers); } }
public string JoinedComposers { get { return JoinGroup(Composers); } }
public string JoinedGenres { get { return JoinGroup(Genres); } }
private static string FirstInGroup(string [] group)
{
return group == null || group.Length == 0 ? null : group[0];
}
private static string JoinGroup(string [] group)
{
return new StringList(group).ToString(", ");
}
public virtual bool IsEmpty
{
get
{
return ((Title == null || Title.Trim () == "") &&
(Artists == null || Artists.Length == 0) &&
(Performers == null || Performers.Length == 0) &&
(Composers == null || Composers.Length == 0) &&
(Album == null || Album.Trim () == "") &&
(Comment == null || Comment.Trim () == "") &&
(Genres == null || Genres.Length == 0) &&
Year == 0 &&
Track == 0 &&
TrackCount == 0 &&
Disc == 0 &&
DiscCount == 0);
}
}
public static void Duplicate (Tag source, Tag target, bool overwrite)
{
if (overwrite || target.Title == null || target.Title.Trim () == "")
target.Title = source.Title;
if (overwrite || target.Artists == null || target.Artists.Length == 0)
target.Artists = source.Artists;
if (overwrite || target.Performers == null || target.Performers.Length == 0)
target.Performers = source.Performers;
if (overwrite || target.Composers == null || target.Composers.Length == 0)
target.Composers = source.Composers;
if (overwrite || target.Album == null || target.Album.Trim () == "")
target.Album = source.Album;
if (overwrite || target.Comment == null || target.Comment.Trim () == "")
target.Comment = source.Comment;
if (overwrite || target.Genres == null || target.Genres.Length == 0)
target.Genres = source.Genres;
if (overwrite || target.Year == 0)
target.Year = source.Year;
if (overwrite || target.Track == 0)
target.Track = source.Track;
if (overwrite || target.TrackCount == 0)
target.TrackCount = source.TrackCount;
if (overwrite || target.Disc == 0)
target.Disc = source.Disc;
if (overwrite || target.DiscCount == 0)
target.DiscCount = source.DiscCount;
}
}
}
|