コード例 #1
0
ファイル: CapturedPicture.cs プロジェクト: kamilk/PlantSaver
        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;
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: PlantRepository.cs プロジェクト: kamilk/PlantSaver
        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);
        }