private async void AddImageBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var file = await FilePicker.OpenPicker(new List <string>() { ".jpg", ".png" });

                FBFormControl.SetSupportImageSource(await FilePicker.ConvertToBitmapFromFile(file));
                if (file != null)
                {
                    //var encoded = await FilePicker.EncodeFile(file);
                    FBFormControl.Imagefile = file;
                }
            }
            catch
            {
                await HelpersClass.ShowDialogAsync("Lỗi khi thêm hình ảnh");
            }
        }
示例#2
0
        private async Task GetBackgroundImagesAsync()
        {
            try
            {
                var folderPath    = @"Assets\Graphics\Backgrounds";
                var backgroundFol = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync(folderPath);

                if (backgroundFol != null)
                {
                    var files = await backgroundFol.GetFilesAsync();

                    Random rand  = new Random();
                    int    index = rand.Next(files.Count);
                    BackgroundImage.Source = await FilePicker.ConvertToBitmapFromFile(files[index]);
                }
            }catch (UnauthorizedAccessException unauthorizedEx)
            {
                await HelpersClass.ShowDialogAsync("Cannot access to background folder " + unauthorizedEx.Message);
            }catch (Exception ex)
            {
                await HelpersClass.ShowDialogAsync("something went really wrong " + ex.Message);
            }
        }
示例#3
0
        private async Task <BitmapImage> LoadImage(Feedback fb)
        {
            //Load the image
            ImageLoadingStackPanel.Visibility = Visibility.Visible;
            BitmapImage image = null;

            if (fb.AttachedImage != null)
            {
                var file = await App.CloudStorage.GetFileAsync(fb.Id, fb.AttachedImage);

                if (file != null)
                {
                    image = await FilePicker.ConvertToBitmapFromFile(file);

                    Debug.WriteLine(fb.Id + " download completed");
                }
                else
                {
                    Debug.WriteLine(fb.Id + " download cancelled");
                }
            }
            ImageLoadingStackPanel.Visibility = Visibility.Collapsed;
            return(image);
        }