Exemplo n.º 1
0
        //private void RollMethod(int pIndex)
        //{
        //    pageIndex = pIndex;

        //    for (int i = 0; i < pnlPages.Controls.Count; i++)
        //    {
        //        string text = pnlPages.Controls[i].ToString();
        //        pnlPages.Controls[i].Visible = false;
        //    }

        //    //Set pager variable to true because it is possible to have more than
        //    //50 records when you retrieve an unfiltered fixture list
        //    bool pager = true;
        //    view.ShowFixtures(selectedDate, null, pageIndex, pager);
        //}

        public IEnumerable <GamePlay> AddToList(List <GamePlay> fixture, int index, Panel pPnlPages)
        {
            int count;
            //The number of games per page
            int             numberPerPage = 50;
            List <GamePlay> gamesToReturn = new List <GamePlay>();
            //This arraylist will indicate how many pages will be collect
            ArrayList pageCollection = new ArrayList();

            //GamePlay[] game = fixture.ToArray();
            GamePlay[] page;
            //fixture.CopyTo(0, page, 0, 30);

            if (fixture.Count > 50)
            {
                count = fixture.Count() / 50;
                //Count how many pages to add
                count = fixture.Count % 50 > 0 ? count = count + 1 : count = count + 0;
                for (int i = 0; i < count; i++)
                {
                    if (fixture.Count < 50)
                    {
                        page = new GamePlay[numberPerPage];
                        fixture.CopyTo(0, page, 0, fixture.Count);
                        pageCollection.Add(page);
                        fixture.RemoveRange(0, fixture.Count - 1);
                    }
                    else
                    {
                        page = new GamePlay[numberPerPage];
                        fixture.CopyTo(0, page, 0, 50);
                        pageCollection.Add(page);
                        fixture.RemoveRange(0, 50);
                    }
                }
            }
            else
            {
                page = new GamePlay[fixture.Count];
                fixture.CopyTo(0, page, 0, fixture.Count);
                pageCollection.Add(page);
            }

            Control control       = pages.Controls[index];
            int     numberOfPages = pageCollection.Count;

            for (int i = 0; i < numberOfPages; i++)
            {
                pPnlPages.Controls[i].Visible = true;
                string text = pages.Controls[i].ToString();
                pPnlPages.Controls[index].Font = new System.Drawing.Font(control.Font.Name, control.Font.Size,
                                                                         control.Font.Style);
                //pnlPages.Controls.Add(control);
            }

            pPnlPages.Controls[index].Font = new System.Drawing.Font(control.Font.Name, control.Font.Size,
                                                                     control.Font.Style ^ FontStyle.Bold);
            if (pageCollection.Count - 1 == index)
            {
                index = 0;
            }

            string test = "";

            return((IEnumerable <GamePlay>)pageCollection[index]);
        }