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 YouNumberInQueue() { var t = new ConsoleWriter(); int c = 0; var clas = new WorkWithThreads(); if (clas.GetExectionThreads() != null) { ElementOfThread p = null; foreach (var temp in clas.GetExectionThreads()) { if (temp.GetName() == this) { p = temp; c--; } c++; } return(c); } else { return(-1); } }
public void WriteToConsoleAndWait() { System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); int p = (int)duration.TotalSeconds + 1; var cl = new ConsoleWriter(); int youoffset = YouNumberInQueue(); while (p != -1) { Console.SetCursorPosition(0, youoffset + cl.GetCountStringsFromConsole()); Console.WriteLine("::" + ((int)((duration.TotalSeconds - p) / 60)).ToString() + ":" + ((duration.TotalSeconds - p) % 60).ToString() + "::" + duration.Minutes.ToString() + ':' + duration.Seconds.ToString() + "::" + artist + " - " + name + "::" + "playing now"); Thread.Sleep(990); stopWatch.Stop(); p--; } var cl1 = new WorkWithThreads(); cl1.AbortRecord(this); Console.SetCursorPosition(0, youoffset + cl.GetCountStringsFromConsole()); string s = "::" + ((int)((duration.TotalSeconds - p) / 60)).ToString() + ":" + ((duration.TotalSeconds - p) % 60).ToString() + "::" + duration.Minutes.ToString() + ':' + duration.Seconds.ToString() + "::" + artist + " - " + name + "::" + "playing now"; string news = ""; for (int i = 0; i <= s.Length; i++) { news = news + ' '; } Console.WriteLine(news); Console.SetCursorPosition(0, cl.GetCountStringsFromConsole() - 2); }
public void WriteToConsoleAndWait() { System.Diagnostics.Stopwatch stopWatch=new System.Diagnostics.Stopwatch(); int p = (int)duration.TotalSeconds+1; var cl = new ConsoleWriter(); int youoffset = YouNumberInQueue(); while(p!=-1) { Console.SetCursorPosition(0,youoffset+cl.GetCountStringsFromConsole()); Console.WriteLine("::" + ((int)((duration.TotalSeconds - p) / 60)).ToString() + ":" + ((duration.TotalSeconds - p) % 60).ToString() + "::" + duration.Minutes.ToString() + ':' + duration.Seconds.ToString() + "::" + artist + " - " + name + "::" + "playing now"); Thread.Sleep(990); stopWatch.Stop(); p--; } var cl1 = new WorkWithThreads(); cl1.AbortRecord(this); Console.SetCursorPosition(0, youoffset + cl.GetCountStringsFromConsole()); string s="::" + ((int)((duration.TotalSeconds - p) / 60)).ToString() + ":" + ((duration.TotalSeconds - p) % 60).ToString() + "::" + duration.Minutes.ToString() + ':' + duration.Seconds.ToString() + "::" + artist + " - " + name + "::" + "playing now"; string news = ""; for(int i = 0;i <= s.Length;i++) { news = news + ' '; } Console.WriteLine(news); Console.SetCursorPosition(0, cl.GetCountStringsFromConsole()-2); }
static void Main(string[] args) { var cl = new WorkWithThreads(); //cl.PlayingRecords = new Queue<ElementOfThread>(); /*record rec=new record("Bob Marley","Woman no cry",new TimeSpan(0,0,05)); record rec1= new record("Evanescence", "Imaginary", new TimeSpan(0, 0, 17)); record rec2 = new record("Evanescence", "Snow White Queen", new TimeSpan(0, 0, 30)); WorkWithXml.ListOfAllComposition.Add(rec); WorkWithXml.ListOfAllComposition.Add(rec1); WorkWithXml.ListOfAllComposition.Add(rec2); // WorkWithXml.WriteToXml();*/ //WorkWithXml.ReadFromXml(); var cl1 = new ConsoleWriter(); cl1.ProcessingMenu(); }
static void Main(string[] args) { var cl = new WorkWithThreads(); //cl.PlayingRecords = new Queue<ElementOfThread>(); /*record rec=new record("Bob Marley","Woman no cry",new TimeSpan(0,0,05)); * record rec1= new record("Evanescence", "Imaginary", new TimeSpan(0, 0, 17)); * record rec2 = new record("Evanescence", "Snow White Queen", new TimeSpan(0, 0, 30)); * WorkWithXml.ListOfAllComposition.Add(rec); * WorkWithXml.ListOfAllComposition.Add(rec1); * WorkWithXml.ListOfAllComposition.Add(rec2); * // WorkWithXml.WriteToXml();*/ //WorkWithXml.ReadFromXml(); var cl1 = new ConsoleWriter(); cl1.ProcessingMenu(); }
public void ProcessingMenu() { int sel = -1; while (sel != 0) { sel = Menu(); switch (sel) { case 4: Console.Clear(); CountStringsFromConsole = 4; if (WorkWithXml.ListOfAllComposition != null) { WorkWithXml.WriteToXml(); Console.WriteLine("PlayList is saved successfull\nPress any key to back"); } else { Console.WriteLine("PlayList is empty\nPress any key to back"); } Console.ReadLine(); break; case 3: Console.Clear(); CountStringsFromConsole = 4; WorkWithXml.ReadFromXml(); Console.WriteLine("PlayList is opened successfull\nPress any key to back"); Console.ReadLine(); break; case 2: ProcessingMenuPlayList(WorkWithXml.GetQueue()); break; case 1: var cl = new WorkWithThreads(); ProcessingMenuPlayList(cl.GetExectionThreads()); break; case 0: break; } } }
private int YouNumberInQueue() { var t = new ConsoleWriter(); int c = 0; var clas = new WorkWithThreads(); if(clas.GetExectionThreads() != null) { ElementOfThread p=null; foreach(var temp in clas.GetExectionThreads()) { if(temp.GetName() == this) { p = temp; c--; } c++; } return c; } else return -1; }
public void ProcessingMenu() { int sel = -1; while(sel!=0) { sel = Menu(); switch (sel) { case 4: Console.Clear(); CountStringsFromConsole = 4; if(WorkWithXml.ListOfAllComposition != null) { WorkWithXml.WriteToXml(); Console.WriteLine("PlayList is saved successfull\nPress any key to back"); } else Console.WriteLine("PlayList is empty\nPress any key to back"); Console.ReadLine(); break; case 3: Console.Clear(); CountStringsFromConsole = 4; WorkWithXml.ReadFromXml(); Console.WriteLine("PlayList is opened successfull\nPress any key to back"); Console.ReadLine(); break; case 2: ProcessingMenuPlayList(WorkWithXml.GetQueue()); break; case 1: var cl = new WorkWithThreads(); ProcessingMenuPlayList(cl.GetExectionThreads()); break; case 0: break; } } }
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; } }
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; } } } }