예제 #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;
            }
        }
예제 #2
0
 private void ImageUrl_TextChanged(object sender, TextChangedEventArgs e)
 {
     try
     {
         MyAvatar.Source   = new BitmapImage(new Uri(ImageUrl.Text));
         isImageValid      = true;
         avatar.Visibility = Visibility.Collapsed;
     } catch (System.Exception)
     {
         ExceptionHandle.ThrowDebug("wrong image");
         MyAvatar.Source   = null;
         isImageValid      = false;
         avatar.Visibility = Visibility.Visible;
     }
 }