Exemplo n.º 1
0
 static public void Run()
 {
     if (ConsoleFunc.IsOutputRedirected)
     {
         return;
     }
     t = new System.Threading.Timer((o) =>
     {
         Console.Clear();
         var height  = Console.WindowHeight;
         var width   = Console.WindowWidth;
         var joblist = JobControler.JobList();
         var i       = 0;
         foreach (var j in joblist.Where(x => !x.IsHidden).OrderBy(x => x.index))
         {
             Console.SetCursorPosition(0, i++);
             Console.Write(j.DisplayName);
             if (i > height - 1)
             {
                 break;
             }
             Console.SetCursorPosition(4, i++);
             Console.Write(j.ProgressStr);
             if (i > height - 1)
             {
                 break;
             }
         }
     }, null, 0, 1000);
 }
Exemplo n.º 2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            tic++;
            if (tic > 10000)
            {
                tic = 0;
            }
            listView1.Invalidate();
            if (tic % 10 != 0)
            {
                return;
            }

            var joblist = JobControler.JobList();

            if (joblist == null)
            {
                return;
            }
            var now = DateTime.Now;

            internalJobList = joblist.Where(x => !x.IsHidden)
                              .OrderBy(x => (x.IsInfo)? 0: (x.IsDone) ? 1 : (x.IsRunning) ? 2 : 3)
                              .ThenBy(x => x.index)
                              .ThenBy(x => (x.StartTime == default(DateTime)) ? now : x.StartTime)
                              .ThenBy(x => x.QueueTime).ToArray();
            listView1.VirtualListSize = internalJobList.Length;
            if (listView1.VirtualListSize > 0)
            {
                var str = new StringBuilder();
                str.AppendFormat("All:{0} ", internalJobList.Length);
                int d = JobControler.JobTypeCount(JobControler.JobClass.Download);
                int u = JobControler.JobTypeCount(JobControler.JobClass.Upload);
                int p = JobControler.JobTypeCount(JobControler.JobClass.PlayDownload);
                int o = internalJobList.Length - (d + u + p);
                if (d > 0)
                {
                    str.AppendFormat("Download:{0} ", d);
                }
                if (u > 0)
                {
                    str.AppendFormat("Upload:{0} ", u);
                }
                if (p > 0)
                {
                    str.AppendFormat("Play:{0} ", p);
                }
                if (o > 0)
                {
                    str.AppendFormat("Other:{0} ", o);
                }
                label1.Text = str.ToString();
            }
            else
            {
                label1.Text = "";
            }
            if (internalJobList.Length == 0)
            {
                Stop();
            }
        }