示例#1
0
        private async void Capture_Photo(object sender, RoutedEventArgs e)
        {
            StorageFile     file      = null;
            CameraCaptureUI captureUI = new CameraCaptureUI();

            captureUI.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Png;
            captureUI.PhotoSettings.CroppedSizeInPixels = new Size(200, 200);
            file = await captureUI.CaptureFileAsync(CameraCaptureUIMode.Photo);

            if (file == null)
            {
                return;
            }
            Uri URL = await ApiHandle <string> .Upload(file, await ApiHandle <string> .Call(APITypes.GetUpload, null), "quanganh9x", "image/png");

            ImageUrl.Text = URL.AbsoluteUri;
            try
            {
                MyAvatar.Source   = new BitmapImage(URL);
                isImageValid      = true;
                avatar.Visibility = Visibility.Collapsed;
            } catch
            {
                ExceptionHandle.ThrowDebug("cant upload image");
                MyAvatar.Source   = null;
                isImageValid      = false;
                avatar.Visibility = Visibility.Visible;
            }
        }