async void displayTorrents(int page)
        {
            Thread.Sleep(500);
            pnlItems.Controls.Clear();

            p = new pages(torrents);
            int lastYCordItem = 0;

            if ((page > p._pages.Count) || (p._pages.Count == 0))
            {
                MessageBox.Show("No torrents found on this page.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return;
            }
            List <Control> listItems = new List <Control>();

            foreach (pageItem pi in p._pages[page].items)
            {
                Control c = pi;
                c.Size     = pi.Size;
                c.Location = new Point((pnlItems.Width / 2) - (c.Width / 2), lastYCordItem + pi.Height + 20);
                if (lastYCordItem <= 0)
                {
                    c.Location = new Point(c.Location.X, 1);
                }
                lastYCordItem = c.Location.Y;
                c.Name        = pi.name;
                c.Visible     = false;
                pnlItems.Controls.Add(c);
                pnlItems.Height = lastYCordItem + pi.Height;
                if (string.IsNullOrWhiteSpace(pi.name))
                {
                    listItems.Add(c);
                }
            }

            if (p._pages.Count < 1)
            {
                btnPage1.Enabled = false; btnPage2.Enabled = false;
            }
            else if (p._pages.Count == 1)
            {
                btnPage2.Enabled = false; btnPage1.Enabled = true;
            }
            else
            {
                btnPage1.Enabled = true; btnPage2.Enabled = true;
            }
            pnlPages.Visible = false;
            await Task.Run(() => displayTorrents(listItems));
        }
Exemple #2
0
        public pages(List <Torrent> t)
        {
            List <pageItem> items      = makeItems(t);
            int             intCount   = 0;
            int             pageNumber = 1;
            pages           _p         = new pages();

            foreach (pageItem pi in items)
            {
                if (intCount >= 10)
                {
                    _p.pageNumber = pageNumber;
                    _pages.Add(_p);
                    _p = new pages();
                    pageNumber++;
                    intCount = 0;
                }
                _p.items.Add(pi);
                intCount++;
            }
        }