-
Notifications
You must be signed in to change notification settings - Fork 0
/
Library.cs
58 lines (52 loc) · 1.3 KB
/
Library.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
using System.IO;
using System.Text;
using System.Collections;
using System.Text.RegularExpressions;
using System;
using Gtk;
using Gdk;
using GLib;
namespace Mp3
{
public class Library
{
public ArrayList songList;
public Library(){
songList = new ArrayList();
}
// will search for a song based on a field
public ArrayList Search(string search, string field){
ArrayList returnList = new ArrayList();
//Regex reg = new Regex(".*"+search.ToLower()+".*");
foreach (Song x in this.songList){
if (x.partialSearch(search,field)==true){
returnList.Add(x);
}
}
return returnList;
}
public void AddSong(Song song){
this.songList.Add(song);
}
// Checks that a given song exists, if it does then it removes the song
// Removes a song that matches the filename
public bool RemoveSong(string filename){
Song tempSong = new Song(filename,"","", "","","","","");
int index = songList.BinarySearch(tempSong);
if (index == 0){
// Console.WriteLine("File exists. Removing file");
this.songList.RemoveAt(index);
return true;
}
else
return false;
}
override public string ToString(){
String returnValue = "";
foreach (Song x in this.songList){
returnValue+= x.ToString() + "\n";
}
return returnValue;
}
}
}