private async void loadProfilePicture() { try { using (var picStream = await NetHelper.GetProfilePicture(userIDTB.Text)) { await this.WriteToFile(picStream); imageView.Source = await PictureConvert.FromStream(picStream); } } catch (COMException) { try { using (var picStream = await ReadFromFile()) { imageView.Source = await PictureConvert.FromStream(picStream); } } catch (Exception e) { Debug.WriteLine(e.Message); StorageFolder appInstalledFolder = Windows.ApplicationModel.Package.Current.InstalledLocation; StorageFolder assets = await appInstalledFolder.GetFolderAsync("Assets"); var file = await assets.GetFileAsync("Square150x150Logo.scale-200.png"); imageView.Source = await PictureConvert.FromStream(await file.OpenAsync(FileAccessMode.Read)); } } }
public async Task <IActionResult> OnPostAsync(IFormFile picture) { try { ValidationUniqueEmail vue = new ValidationUniqueEmail(); if (!vue.CheckEmail(ModelState["Customer.Email"].RawValue.ToString())) { ModelState.AddModelError("email", "E-mail already exists."); } if (picture == null) { ModelState.AddModelError("picture", "Picture is empty."); } if (!ModelState.IsValid) { return(Page()); } pictureConvert = new PictureConvert(); Customer.Picture = await pictureConvert.IFormFileToByte(picture); _dbContext.Customer.Add(Customer); await _dbContext.SaveChangesAsync(); alert.ShowMessage("Successfully created."); } catch (Exception) { alert.ShowMessage("Error to creating.", 4); return(Page()); } return(RedirectToPage("/Customers/Index")); }
public bool Update(UpdatePicture item) { using (Context context = new Context()) { EfPictureRepository rep = new EfPictureRepository(context); PictureConvert convert = new PictureConvert(context); return(rep.Update(convert.ToEntity(item))); } }
public ReadPicture Remove(int id) { using (Context context = new Context()) { EfPictureRepository rep = new EfPictureRepository(context); PictureConvert convert = new PictureConvert(context); return(convert.ToRead(rep.Remove(id))); } }
public List <ReadPicture> GetAll() { using (Context context = new Context()) { EfPictureRepository rep = new EfPictureRepository(context); PictureConvert convert = new PictureConvert(context); return(convert.ToReadList(rep.GetAll())); } }
public ReadPicture Add(CreatePicture item) { using (Context context = new Context()) { EfPictureRepository rep = new EfPictureRepository(context); PictureConvert convert = new PictureConvert(context); return(convert.ToRead(rep.Add(convert.ToEntity(item)))); } }
protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); StorageFolder appInstalledFolder = Windows.ApplicationModel.Package.Current.InstalledLocation; StorageFolder assets = await appInstalledFolder.GetFolderAsync("Assets"); var file = await assets.GetFileAsync("SnapMemo_square.png"); imgView.Source = await PictureConvert.FromStream(await file.OpenAsync(FileAccessMode.Read)); }
private void SetCommandBarButtonImage(CommandBarButton button, string id) { var image = Globals.ThisAddIn.GetCommandBitmap(id + "_sm"); if (image == null) { return; } Bitmap picture, mask; BitmapToPictureAndMask(image, out picture, out mask); button.Picture = PictureConvert.ImageToPictureDisp(picture); button.Mask = PictureConvert.ImageToPictureDisp(mask); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); IRandomAccessStream stream = null; try { stream = e.Parameter as IRandomAccessStream; } catch (Exception) { Debug.WriteLine("wrong type convert"); } decoder = await BitmapDecoder.CreateAsync(stream); imgView.Source = await PictureConvert.FromStream(stream); }
public async Task <IActionResult> OnPostAsync(IFormFile picture) { try { if (_email != ModelState["Customer.Email"].RawValue.ToString()) { ValidationUniqueEmail vue = new ValidationUniqueEmail(); if (!vue.CheckEmail(ModelState["Customer.Email"].RawValue.ToString())) { ModelState.AddModelError("email", "E-mail already exists."); } } if (!ModelState.IsValid) { ViewData["picture"] = _picture; return(Page()); } if (picture != null) { pictureConvert = new PictureConvert(); Customer.Picture = await pictureConvert.IFormFileToByte(picture); } else { Customer.Picture = _picture; } _dbContext.Customer.Add(Customer).State = Microsoft.EntityFrameworkCore.EntityState.Modified; await _dbContext.SaveChangesAsync(); alert.ShowMessage("Successfully edited."); } catch (Exception) { alert.ShowMessage("Error to editing.", 4); return(Page()); } return(RedirectToPage("/Customers/Index")); }