Example #1
0
 public async void StartGame()
 {
     if (progressRing.IsActive == false)
     {
         progressRing.IsActive = true;
         if (GameGlobal.PictrueSource == null && string.IsNullOrEmpty(IsGallery) || !IsPictureSelected && string.IsNullOrEmpty(IsGallery))
         {
             var bmp = (TempBorder.Child as Image).Source as BitmapImage;
             StorageFile file = GetFileFromUriAsync(bmp.UriSource.OriginalString);
             if (file != null)
             {
                 using (FileRandomAccessStream stream = (FileRandomAccessStream)await file.OpenAsync(FileAccessMode.Read))
                 {
                     var property = await file.Properties.GetImagePropertiesAsync();
                     WriteableBitmap wbm = new WriteableBitmap((int)property.Width, (int)property.Height);
                     wbm.SetSource(stream);
                     GameGlobal.PictrueSource = wbm;
                     GameGlobal.CurrentUriSource = bmp.UriSource;
                     stream.Dispose();
                 }
             }
         }
         GameGlobal.SetLevel(new Size(CountParts * K, CountParts));
         progressRing.IsActive = false;
         Frame.Navigate(typeof(GameInterface));
     }
 }
        public static async Task <BitmapImage> LoadImage(StorageFile file)
        {
            BitmapImage            bitmapImage = new BitmapImage();
            FileRandomAccessStream stream      = (FileRandomAccessStream)await file.OpenAsync(FileAccessMode.Read);

            bitmapImage.SetSource(stream);
            stream.Dispose();
            return(bitmapImage);
        }
Example #3
0
 public void Close()
 {
     if (!isClosed)
     {
         isClosed = true;
         stream.Dispose();
         stream = null;
         fileStream.Dispose();
         fileStream = null;
     }
 }
Example #4
0
 public void Close()
 {
     if (!isClosed)
     {
         isClosed = true;
         stream.Dispose();
         stream = null;
         fileStream.Dispose();
         fileStream      = null;
         this.isModified = false;
     }
 }
        private async void ListImages_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count > 0 && progressRing.IsActive == false)
            {
                progressRing.IsActive = true;
                IsPictureSelected     = true;
                var file = GetFileFromUriAsync((((ImageEntity)e.AddedItems[0]).ImageSource as BitmapImage).UriSource.OriginalString);
                if (file != null)
                {
                    var property = await file.Properties.GetImagePropertiesAsync();

                    using (FileRandomAccessStream stream = (FileRandomAccessStream)await file.OpenAsync(FileAccessMode.Read))
                    {
                        if (property.Height > property.Width)
                        {
                            WriteableBitmap wbm = new WriteableBitmap((int)property.Width, (int)property.Height);
                            wbm.SetSource(stream);
                            wbm = wbm.Resize((int)property.Width, (int)property.Height, WriteableBitmapExtensions.Interpolation.Bilinear).Rotate(270);
                            GameGlobal.PictrueSource = wbm;
                        }
                        else
                        {
                            WriteableBitmap wbm = new WriteableBitmap((int)property.Width, (int)property.Height);
                            wbm.SetSource(stream);
                            GameGlobal.PictrueSource = wbm;
                        }
                        stream.Dispose();
                    }
                    GameGlobal.CurrentUriSource = (((ImageEntity)e.AddedItems[0]).ImageSource as BitmapImage).UriSource;

                    K = 1.5;
                    if (property.Height < property.Width)
                    {
                        double div = (double)property.Width / property.Height;
                        if (div < 1.5)
                        {
                            K = 1;
                        }
                    }
                    SliderAmount.Text = (K * Math.Pow(4, 2)).ToString();
                    countParts.Value  = 4;
                }
                progressRing.IsActive = false;
            }
        }