Пример #1
0
 public Interface()
 {
     InitializeComponent();
     instancelist = csvmanager.load();
     if (instancelist.Count > 0)
     { currentinstance = instancelist[instancelist.Count - 1]; }//the last songinstance.
 }
Пример #2
0
 private void UI_recordBtn_Click(object sender, EventArgs e)
 {
     UI_Statusbar.Text = "Recording";
     UI_Statusbar.Show();
     UI_Statusbar.Text = "Recording";
     //UI_progressBar.Show(); // needs to be repeating. No fixed end time.
     currentinstance = new songinstance();
     instancelist.Add(currentinstance);
     currentinstance.record();
     recordtime.Text = currentinstance.getrecordtime().Hour + ":" + currentinstance.getrecordtime().Minute + " " + currentinstance.getrecordtime().DayOfWeek;
     //DynamicRecord.start();
     //Thread record = new Thread(link_RecordViaThread);
     //record.Name = "recorder";
     //record.IsBackground = true;
     //record.Start();
     //Recordtimer.Enabled = true;
 }
Пример #3
0
        private void nextinstance_Click(object sender, EventArgs e)
        {
            int i = instancelist.IndexOf(currentinstance);
            if (i < instancelist.Count - 1)
            {
#if VERBOSE
                MessageBox.Show("going to next instance");
#endif
                currentinstance = instancelist[i + 1];
                recordtime.Text = currentinstance.getrecordtime().Hour + ":" + currentinstance.getrecordtime().Minute + " " + currentinstance.getrecordtime().DayOfWeek;
            }
        }
Пример #4
0
 private void instancedelete_Click(object sender, EventArgs e)
 {
     currentinstance.delete();
     int i = instancelist.IndexOf(currentinstance);
     instancelist.Remove(currentinstance);
     if ((i > 0) && (i < instancelist.Count - 1))
     { currentinstance = instancelist[i - 1];
     recordtime.Text = currentinstance.getrecordtime().Hour + ":" + currentinstance.getrecordtime().Minute + " " + currentinstance.getrecordtime().DayOfWeek;
     }
 }
Пример #5
0
        public static List<songinstance> load()
        {
            string fileName = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
            fileName = Path.GetDirectoryName(fileName);
            fileName = Path.Combine(fileName, SAVEFILE);
            List<songinstance> returnlist = new List<songinstance>();
            try
            {
                TextReader tr = new StreamReader(fileName);
                string line;
                string value;
                while ((line = tr.ReadLine()) != null)
                {

//#if VERBOSE
//                    MessageBox.Show("csv loader: "+ line);
//#endif
                    songinstance si = new songinstance();

                    value = line.Substring(0, line.IndexOf(","));
                    line = line.Substring(line.IndexOf(",") + 1);
                    si.setwaveurl(value);

                    value = line.Substring(0, line.IndexOf(","));
                    line = line.Substring(line.IndexOf(",") + 1);
                    si.setdatetime(value);

                    value = line.Substring(0, line.IndexOf(","));
                    line = line.Substring(line.IndexOf(",") + 1);
                    si.setfingerprint(value); //this will not handle error.

                    SongList sl = new SongList();
                    int cindex;
                    while ((cindex = line.IndexOf(",")) != -1) //-1?
                    {
//#if VERBOSE
//                        MessageBox.Show(line);
//#endif                       
                        
                        Song s = new Song();
                        value = line.Substring(0, line.IndexOf(","));
                        line = line.Substring(line.IndexOf(",")+1);
                        s.artist = value;
                        value = line.Substring(0, line.IndexOf(","));
                        line = line.Substring(line.IndexOf(",") + 1);
                        s.title = value;
                        value = line.Substring(0, line.IndexOf(","));
//#if VERBOSE
//                        MessageBox.Show(line);
//#endif
                        line = line.Substring(line.IndexOf(",") + 1);
                        s.match = Int32.Parse(value);
//#if VERBOSE
//                        MessageBox.Show("csv adding match");
//#endif

                        //sl.Add(s); //add doesnt work.
                        sl.Insert(0, s);
                    } //this will not handle error. and is untested.
                    si.setmatches(sl);
#if VERBOSE
                    MessageBox.Show("csv matches count :"+sl.Count.ToString());
#endif

                    returnlist.Add(si);
                   
                }
#if VERBOSE
                MessageBox.Show("csv loader: list<instance>.lengith " + returnlist.Count.ToString());
#endif
                return returnlist;
            }
            catch (FileNotFoundException) { return returnlist; }//returnlist is empty, that should be fine.
            catch (IOException)
            {
                System.Windows.Forms.MessageBox.Show("IOException, this is odd.");
                return returnlist;
            }
        }