示例#1
0
        private void BuildField(int?[,] field)
        {
            var rows    = field.GetLength(0);
            var columns = field.GetLength(1);

            CreateGrid(columns, rows);

            var card = ResourceProvider.GetPath("card.png").ToImageSource();

            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns; j++)
                {
                    var num   = field[i, j].Value;
                    var url   = ResourceProvider.GetAnimalsFile(num.ToString());
                    var image = new MemoryCard
                    {
                        Source       = card,
                        FrontImage   = url.ToImageSource(),
                        OpositeImage = card,
                        Number       = num
                    };
                    image.MouseLeftButtonDown += image_MouseLeftButtonDown;
                    SetRow(image, i);
                    SetColumn(image, j);
                    Children.Add(image);
                }
            }
        }