Example #1
0
 // cell neighbourhood iterator
 public void ForEachCellNeighbour(int i, int j, CellDelegate method)
 {
     for (int d = 0; d < di.Length; d++)
     {
         // get neighbour coordinates
         int ii = i + di[d], jj = j + dj[d];
         if (OnBoard(ii, jj))
         {
             method(ii, jj);
         }
     }
 }
Example #2
0
        public static T Fold <T>(T acc, CellDelegate <T> fn, Grid board)
        {
            T a = acc;

            foreach (UIElement element in board.Children)
            {
                if (element is Cell)
                {
                    a = fn(a, (Cell)element, board);
                }
            }
            return(a);
        }
Example #3
0
 public void ForEachBoardCell(CellDelegate method)
 {
     for (int i = 0; i < board.GetLength(0); i++)
     {
         for (int j = 0; j < board.GetLength(1); j++)
         {
             if (OnBoard(i, j))
             {
                 method(i, j);
             }
         }
     }
 }
Example #4
0
            public ViewDataSource(UITableView tableView)
            {
                Random rnd = new Random();

                sections  = UILocalizedIndexedCollation.CurrentCollation().SectionIndexTitles;
                testArray = (
                    from section in sections
                    group section by section
                    into g
                    select(
                        from i in Enumerable.Range(1, rnd.Next(5) + 1)
                        select i.ToString()
                        ).ToList()
                    ).ToArray();

                cellDelegate = new CellDelegate(testArray, tableView);
            }
Example #5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // set up the data
            Random rnd = new Random();

            sections  = UILocalizedIndexedCollation.CurrentCollation().SectionIndexTitles;
            testArray = (
                from section in sections
                group section by section into g
                select Enumerable.Range(1, rnd.Next(5) + 1).Select(i => i.ToString()).ToList()
                ).ToArray();

            cellDelegate = new CellDelegate(testArray, TableView);

            NavigationItem.LeftBarButtonItem = EditButtonItem;
            TableView.RowHeight  = 90;
            NavigationItem.Title = "Pull to Toggle Cell Type";

            // Setup refresh control for example app
            UIRefreshControl refreshControl = new UIRefreshControl();

            refreshControl.ValueChanged += (sender, args) => {
                refreshControl.BeginRefreshing();
                useCustomCells = !useCustomCells;
                if (useCustomCells)
                {
                    RefreshControl.TintColor = UIColor.Yellow;
                }
                else
                {
                    RefreshControl.TintColor = UIColor.Blue;
                }

                TableView.ReloadData();
                refreshControl.EndRefreshing();
            };
            refreshControl.TintColor = UIColor.Blue;
            TableView.AddSubview(refreshControl);
            RefreshControl = refreshControl;

            useCustomCells = false;
        }
Example #6
0
			public ViewDataSource(UITableView tableView)
			{
				Random rnd = new Random();
				sections = UILocalizedIndexedCollation.CurrentCollation().SectionIndexTitles;
				testArray = (
					from section in sections
					group section by section
					into g
					select (
						from i in Enumerable.Range(1, rnd.Next(5) + 1)
						select i.ToString()
						).ToList()
					).ToArray();

				cellDelegate = new CellDelegate(testArray, tableView);
			}