Esempio n. 1
0
        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));
                }
            }
        }
Esempio n. 2
0
        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"));
        }
Esempio n. 3
0
 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)));
     }
 }
Esempio n. 4
0
 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)));
     }
 }
Esempio n. 5
0
 public List <ReadPicture> GetAll()
 {
     using (Context context = new Context())
     {
         EfPictureRepository rep     = new EfPictureRepository(context);
         PictureConvert      convert = new PictureConvert(context);
         return(convert.ToReadList(rep.GetAll()));
     }
 }
Esempio n. 6
0
 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))));
     }
 }
Esempio n. 7
0
        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));
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        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"));
        }