private async Task <StorageFile> CreateCroppedFile(StorageFile orignalFile, Point corpPoint, Size cropSize)
        {
            var myPictures = await Windows.Storage.StorageLibrary.GetLibraryAsync(Windows.Storage.KnownLibraryId.Pictures);

            StorageFile croppedFile = await myPictures.SaveFolder.CreateFileAsync("photocrop.jpg", CreationCollisionOption.GenerateUniqueName);

            // var returnedcropImage = await CropBitmap.GetCroppedBitmapAsync(file, screenCoords, rect.RenderSize, 1);
            await CropBitmap.SaveCroppedBitmapAsync(orignalFile, croppedFile, corpPoint, cropSize);

            return(croppedFile);
        }
        private async Task <String> CapturePhoto()
        {
            var myPictures = await Windows.Storage.StorageLibrary.GetLibraryAsync(Windows.Storage.KnownLibraryId.Pictures);

            StorageFile file = await myPictures.SaveFolder.CreateFileAsync("photo.jpg", CreationCollisionOption.GenerateUniqueName);


            using (var captureStream = new InMemoryRandomAccessStream())
            {
                await _mediaCapture.CapturePhotoToStreamAsync(ImageEncodingProperties.CreateJpeg(), captureStream);

                using (var fileStream = await file.OpenAsync(FileAccessMode.ReadWrite))
                {
                    var decoder = await BitmapDecoder.CreateAsync(captureStream);

                    var encoder = await BitmapEncoder.CreateForTranscodingAsync(fileStream, decoder);

                    var properties = new BitmapPropertySet {
                        { "System.Photo.Orientation", new BitmapTypedValue(PhotoOrientation.Normal, PropertyType.UInt16) }
                    };
                    await encoder.BitmapProperties.SetPropertiesAsync(properties);

                    await encoder.FlushAsync();

                    // decoder = null;
                    // encoder = null;
                    //await  fileStream.FlushAsync();
                    // fileStream.Dispose();
                }
                //await  captureStream.FlushAsync();
                // captureStream.Dispose();

                // GC.Collect();
            }

            var   ttv          = rect.TransformToVisual(previewElement);
            Point screenCoords = ttv.TransformPoint(new Point(0, 0));
            // screenCoords.X -= 120;
            // screenCoords.Y -= 120;

            StorageFile croppedFile = await myPictures.SaveFolder.CreateFileAsync("photocrop.jpg", CreationCollisionOption.GenerateUniqueName);

            // var returnedcropImage = await CropBitmap.GetCroppedBitmapAsync(file, screenCoords, rect.RenderSize, 1);
            await CropBitmap.SaveCroppedBitmapAsync(file, croppedFile, screenCoords, rect.RenderSize);

            ///Image bmp = new Image();
            // bmp.Source = returnedcropImage;

            // bmp.sa


            // String ret = await Upload("http://192.168.0.102:8090/api/Switch/UploadFiles", croppedFile);
            //String ret = "";
            await  ObserveObjects(file);

            await file.DeleteAsync();

            //await  croppedFile.DeleteAsync();
            //if(ret.Contains("closed"))
            //{
            //    ret = "Full";
            //}
            //else if(ret.Contains("open"))
            //{
            //    ret = "reserve";
            //}
            //else if (ret.Contains("bird"))
            //{
            //    ret = "empty";
            //}
            return("");
        }