public static CapturedPicture Deserialise(Stream inputStream) { CapturedPicture picture = new CapturedPicture(); using (BinaryReader binaryReader = new BinaryReader(inputStream)) { int length = binaryReader.ReadInt32(); picture.ImageBytes = binaryReader.ReadBytes(length); picture.FileName = binaryReader.ReadString(); } return picture; }
public void SavePicture(CapturedPicture picture) { var path = Path.Combine(directory, picture.FileName); var isoFile = IsolatedStorageFile.GetUserStoreForApplication(); if (!isoFile.DirectoryExists(directory)) isoFile.CreateDirectory(directory); using (var isoStream = isoFile.OpenFile(path, FileMode.OpenOrCreate)) { picture.Serialise(isoStream); } LoadPicture(picture.FileName); }
public void SaveNewPlant(Plant plant, CapturedPicture picture) { CreatePlantDataContextIfNotExists(); StorablePlant storablePlant = new StorablePlant(plant, picture != null ? picture.FileName : null); PlantDataContext.Plants.InsertOnSubmit(storablePlant); PlantDataContext.SubmitChanges(); Plants.Add(plant); if (picture != null) PictureRepository.Instance.SavePicture(picture); }