Ejemplo n.º 1
0
        public async Task GetAllImages()
        {
            List <BitmapImage> images = new List <BitmapImage>();

            try
            {
                StorageFolder pictureFolder2 = await Folder.GetFolderAsync(PuzzleSize.ToString());

                for (int i = 1; i < (PuzzleSize * PuzzleSize); i++)
                {
                    Debug.WriteLine("Image from folder: " + i.ToString());
                    StorageFile img = await pictureFolder2.GetFileAsync(i.ToString() + ".png");

                    BitmapImage image = new BitmapImage();
                    using (IRandomAccessStream fileStream = await img.OpenAsync(FileAccessMode.Read))
                    {
                        image.SetSource(fileStream);
                    }
                    images.Add(image);
                }
            }
            catch (Exception ex)
            {
                Debug.Write(ex.ToString());
                throw;
            }

            PuzzlePieceImages = images;
        }
Ejemplo n.º 2
0
        public async Task GetAllImages()
        {
            try
            {
                StorageFolder pictureFolder2 = await Folder.GetFolderAsync(PuzzleSize.ToString());

                for (int i = 1; i <= TotalPuzzleSize; i++)
                {
                    StorageFile img = await pictureFolder2.GetFileAsync($"{i.ToString()}{ImageTypes.Png}");

                    BitmapImage image = new BitmapImage();
                    using (IRandomAccessStream fileStream = await img.OpenAsync(FileAccessMode.Read))
                    {
                        image.SetSource(fileStream);
                    }
                    PuzzleImages.Add(image);
                }
                if (PuzzleImages.Count != TotalPuzzleSize)
                {
                    throw new Exception("PUzzle can not be generated.");
                }
            }
            catch
            {
                throw;
            }
        }