public void ProcessingMenuPlayList(List <record> list) { int sel = -1; while (sel != 0) { sel = MenuPlayList(list); if ((sel != 0) && (list != null)) { int ch = sel; ch--; if (list != null) { record r = null; foreach (var next in list) { if (ch < 1) { r = next; break; } ch--; } ProcessingMenuRecord(r); } } else if (list == null) { Console.WriteLine("PlayList is empty\nPress any key to back"); Console.ReadLine(); } } }
public ElementOfThread SearchThread(record rec) { var clas = new WorkWithThreads(); if (clas.GetExectionThreads() != null) { ElementOfThread t = null; foreach (var temp in clas.GetExectionThreads()) { if (temp.GetName() == rec) { t = temp; } } if (t == null) { return(null); } else { return(t); } } else { return(null); } }
public void AbortRecord(record r) { var cl = new ConsoleWriter(); ElementOfThread element = cl.SearchThread(r); PlayingRecords.Remove(element); if(PlayingRecords.Count == 0) PlayingRecords.Clear(); }
public void AddPlaingRecord(record rec) { Thread ExThread = new Thread(rec.WriteToConsoleAndWait); ElementOfThread element = new ElementOfThread(ExThread, rec); if(PlayingRecords == null) CreateNewQueue(); PlayingRecords.Add(element); ExThread.Start(); }
public void AbortRecord(record r) { var cl = new ConsoleWriter(); ElementOfThread element = cl.SearchThread(r); PlayingRecords.Remove(element); if (PlayingRecords.Count == 0) { PlayingRecords.Clear(); } }
public void AddPlaingRecord(record rec) { Thread ExThread = new Thread(rec.WriteToConsoleAndWait); ElementOfThread element = new ElementOfThread(ExThread, rec); if (PlayingRecords == null) { CreateNewQueue(); } PlayingRecords.Add(element); ExThread.Start(); }
public static void ReadFromXml() { XDocument doc = XDocument.Load("records.xml"); XElement xml_list = doc.Root; foreach(XElement xml_record in xml_list.Elements()) { record newRecord = new record(xml_record.Element("artist").Value, xml_record.Element("name").Value, new TimeSpan(10000000*int.Parse(xml_record.Element("duration").Value)), xml_record.Element("about").Value); if(ListOfAllComposition == null) ListOfAllComposition = new List<record>(); ListOfAllComposition.Add(newRecord); } }
public static void ReadFromXml() { XDocument doc = XDocument.Load("records.xml"); XElement xml_list = doc.Root; foreach (XElement xml_record in xml_list.Elements()) { record newRecord = new record(xml_record.Element("artist").Value, xml_record.Element("name").Value, new TimeSpan(10000000 * int.Parse(xml_record.Element("duration").Value)), xml_record.Element("about").Value); if (ListOfAllComposition == null) { ListOfAllComposition = new List <record>(); } ListOfAllComposition.Add(newRecord); } }
private int MenuRecord(record r) ///////////////// { Console.SetCursorPosition(0, 0); CountStringsFromConsole = 7; ConsoleCLear(); r.WriteToConsole(); string str = "0) Press to back.\n" + "1) Press to play record.\n" + "2) Press to stop record.\n" + "3) Press to view record's information"; Console.WriteLine(str); try { int sel = int.Parse(Console.ReadLine()); return(sel); } catch { return(FormatException()); } }
public void ProcessingMenuRecord(record r) { Console.SetCursorPosition(0, 0); if(r == null) { Console.Clear(); Console.WriteLine("none record doesn't play\nPress any key to back"); Console.ReadLine(); } else { int sel = -1; while(sel != 0) { sel = MenuRecord(r); Console.Clear(); Console.SetCursorPosition(0, 0); switch(sel) { case 0: break; case 1: var th =SearchThread(r); if(th == null) { var cl = new WorkWithThreads(); ConsoleCLear(); cl.AddPlaingRecord(r); Console.SetCursorPosition(0, 0); Console.WriteLine("Your record is started successfull\nPress any key to back"); Console.ReadLine(); } else { Console.WriteLine("this record is plying now"); Console.WriteLine("Press any key to back"); Console.ReadLine(); } sel = 0; break; case 2: try { var thr =SearchThread(r); var cl = new WorkWithThreads(); cl.AbortRecord(r); Console.SetCursorPosition(0, 0); Console.WriteLine("Your record is stoped successfull"); } catch { Console.SetCursorPosition(0, 0); Console.WriteLine("Your record doesn't playing now"); } Console.WriteLine("Press any key to back"); Console.ReadLine(); sel = 0; break; case 3: r.WriteToConsole(); r.WriteAbout(); Console.WriteLine("Press any key to back"); Console.ReadLine(); break; } } } }
public ElementOfThread SearchThread(record rec) { var clas = new WorkWithThreads(); if(clas.GetExectionThreads() != null) { ElementOfThread t=null; foreach(var temp in clas.GetExectionThreads()) { if(temp.GetName() == rec) t = temp; } if(t == null) return null; else return t; } else { return null; } }
private int MenuRecord(record r) ///////////////// { Console.SetCursorPosition(0, 0); CountStringsFromConsole = 7; ConsoleCLear(); r.WriteToConsole(); string str = "0) Press to back.\n" + "1) Press to play record.\n" + "2) Press to stop record.\n" + "3) Press to view record's information"; Console.WriteLine(str); try { int sel = int.Parse(Console.ReadLine()); return sel; } catch { return FormatException(); } }
public void ProcessingMenuRecord(record r) { Console.SetCursorPosition(0, 0); if (r == null) { Console.Clear(); Console.WriteLine("none record doesn't play\nPress any key to back"); Console.ReadLine(); } else { int sel = -1; while (sel != 0) { sel = MenuRecord(r); Console.Clear(); Console.SetCursorPosition(0, 0); switch (sel) { case 0: break; case 1: var th = SearchThread(r); if (th == null) { var cl = new WorkWithThreads(); ConsoleCLear(); cl.AddPlaingRecord(r); Console.SetCursorPosition(0, 0); Console.WriteLine("Your record is started successfull\nPress any key to back"); Console.ReadLine(); } else { Console.WriteLine("this record is plying now"); Console.WriteLine("Press any key to back"); Console.ReadLine(); } sel = 0; break; case 2: try { var thr = SearchThread(r); var cl = new WorkWithThreads(); cl.AbortRecord(r); Console.SetCursorPosition(0, 0); Console.WriteLine("Your record is stoped successfull"); } catch { Console.SetCursorPosition(0, 0); Console.WriteLine("Your record doesn't playing now"); } Console.WriteLine("Press any key to back"); Console.ReadLine(); sel = 0; break; case 3: r.WriteToConsole(); r.WriteAbout(); Console.WriteLine("Press any key to back"); Console.ReadLine(); break; } } } }
public ElementOfThread(Thread _thread, record _record) { thread = _thread; record = _record; }