private async void GetImage() { FileOpenPicker picker = new FileOpenPicker(); picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; picker.FileTypeFilter.Add(".png"); picker.FileTypeFilter.Add(".jpg"); picker.FileTypeFilter.Add(".jpeg"); StorageFile file = await picker.PickSingleFileAsync(); if (file != null) { IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read); BitmapImage image = new BitmapImage(); await image.SetSourceAsync(stream.CloneStream()); image.UriSource = new Uri(file.Path); MyBuffer buffer = new MyBuffer(new byte[stream.Size]); await stream.ReadAsync(buffer.Buffer, (uint)stream.Size, InputStreamOptions.None); var newAvatar = buffer.AsByteArray(); Database_Service.SchedServiceClient client = new Database_Service.SchedServiceClient(); account.avatarImage = newAvatar; Application.Current.Resources["User"] = account; await client.UpdateUserAsync(account.clientID, account.phoneNumber, account.address, account.username, newAvatar); EventViewModel e = this.DataContext as EventViewModel; e.newAvatar(newAvatar); DataContext = e; } }
private void ConfirmButton_Click(object sender, RoutedEventArgs e) { Database_Service.SchedServiceClient client = new Database_Service.SchedServiceClient(); client.UpdateUserAsync(account.clientID, this.PhoneNumberTextBox.Text.Trim(), "", this.UsernameTextBox.Text.Trim(), account.avatarImage); Application.Current.Resources.Remove("User"); this.DisplaySuccessDialog(); }