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 AbortRecord(record r) { var cl = new ConsoleWriter(); ElementOfThread element = cl.SearchThread(r); PlayingRecords.Remove(element); if(PlayingRecords.Count == 0) PlayingRecords.Clear(); }
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(); }
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; }