private void OnPictureOverwritten(Guid guid) { var picture = Pictures.First(pic => pic.Guid == guid); var reloadedPicture = _pictureRepository.GetPicturesAsync(new string[] { picture.FullFileName }).Result; Pictures.Remove(picture); Pictures.Add(reloadedPicture.First()); }
public Bitmap FindPictureByFileName(string pictureFileName) { var basePath = AppDomain.CurrentDomain.BaseDirectory; var pathToLocalStorage = Path.Combine(basePath, "LocalStorage"); var key = Path.Combine(pathToLocalStorage, pictureFileName).ToLowerInvariant(); var findValue = Pictures.First(el => string.Compare(el.PathToFileName, key, StringComparison.OrdinalIgnoreCase) == 0); var findId = findValue?.Id ?? Guid.Empty; return(GetPicture(findId)); }
public Bitmap GetPicture(Guid id) { if (Guid.Empty == id) { return(new Bitmap(0, 0)); } var findValue = Pictures.First(el => el.Id == id); var findFileName = findValue?.PathToFileName ?? string.Empty; return(string.IsNullOrWhiteSpace(findFileName) ? new Bitmap(0, 0) : new Bitmap(findFileName)); }
private void AddPicture(Picture picture) { // Remove placeholder if (Pictures.Count == 1) { if (Pictures.First().FileName.Equals("pictureDefault")) { Pictures.RemoveAt(0); } } // persist if (picture.ImageSource != null) { // Filename from Event ID and picture number // Pattern for Event 1, 2nd Picture: {1}2.jpg var idPatternForFileWithoutFileExtension = SelectedEvent.IdForFileSystem + Pictures.Count; _pictureSaver.SavePictureToDisk(picture.ImageSource, idPatternForFileWithoutFileExtension); } // add to view Pictures.Insert(0, picture); }