示例#1
0
        private async void EditUserIcon_Tabbed(object sender, EventArgs e)
        {
            await CrossMedia.Current.Initialize();

            if (!CrossMedia.Current.IsPickPhotoSupported)
            {
                await DisplayAlert("Alert", "not supprored", "ok");

                return;
            }
            var mediaoptions = new Plugin.Media.Abstractions.PickMediaOptions()
            {
                PhotoSize = PhotoSize.Medium
            };

            selectedimgfile = await CrossMedia.Current.PickPhotoAsync(mediaoptions);

            if (selectedimgfile == null)
            {
                await DisplayAlert("error", "tryagain", "ok");
            }
            RelativeImage.Source = ImageSource.FromStream(() => selectedimgfile.GetStream());
            Stream stream    = selectedimgfile.GetStream();
            var    imagePath = await UserProfileViewModel.UploadImage(stream, selectedimgfile.Path);

            var userID = int.Parse(Application.Current.Properties["UserID"].ToString());

            Relative.Image = App.ServiceURL + imagePath;

            Relative = await UserProfileViewModel.EditUser(Relative, Relative.ID);

            RelativeImage.Source = Relative.Image;
        }