private void OnAdd() { user = Serializer.DeserializeUser(); int count = 0; int number = -1; CurrentPicture = new Picture(uri, Title, Description); CurrentPicture.Validate(); if (CurrentPicture.IsValid) { user.Pictures.Add(new Picture(uri, Title, Description)); PictureViewModel.picturesChange(user); allUsers = Serializer.Deserialize(); foreach (Users tempuser in allUsers.Users) { if (tempuser.Username == user.Username) { number = count; } count++; } allUsers.Users[number].Pictures.Add(CurrentPicture); Serializer.SerializeUser(allUsers.Users[number]); Serializer.Serialize(allUsers); Title = ""; Description = ""; Bitmap bitmap = (Bitmap)Bitmap.FromFile(@"C:\Users\pc\Desktop\Blok5-Projekat1\MVVM1\bin\Debug\addLogo.png", true); ButtonSource = BitmapConversion.BitmapToBitmapSource(bitmap); } }
public StudentViewModel() { user = Serializer.DeserializeUser(); BrowseCommand = new MyICommand(OnBrowse); AddCommand = new MyICommand(OnAdd); Bitmap bitmap = (Bitmap)Bitmap.FromFile(@"C:\Users\pc\Desktop\Blok5-Projekat1\MVVM1\bin\Debug\addLogo.png", true); bitmapSource = BitmapConversion.BitmapToBitmapSource(bitmap); }
private void OnBrowse() { OpenFileDialog op = new OpenFileDialog(); op.Title = "Select a picture"; op.Filter = "All supported graphics|*.jpg;*.jpeg;*.png|" + "JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|" + "Portable Network Graphic (*.png)|*.png"; if (op.ShowDialog() == true) { Bitmap bitmap = (Bitmap)Bitmap.FromFile(op.FileName, true); ButtonSource = BitmapConversion.BitmapToBitmapSource(bitmap); uri = op.FileName; } }