Пример #1
0
        /// <summary>
        /// Save the current Project.
        /// </summary>
        private async Task Save()
        {
            string        name      = this.ViewModel.Name;
            int           width     = this.ViewModel.CanvasTransformer.Width;
            int           height    = this.ViewModel.CanvasTransformer.Height;
            StorageFolder zipFolder = await FileUtil.DeleteAllAndReturn(name);


            //Save project file.
            Project project = new Project
            {
                Name      = name,
                Width     = width,
                Height    = height,
                Layerages = this.ViewModel.LayerageCollection.RootLayerages
            };
            await Retouch_Photo2.XML.SaveProjectFile(zipFolder, project);

            //Save thumbnail file.
            CanvasRenderTarget thumbnail = this.MainCanvasControl.Render(width, height);
            await FileUtil.SaveThumbnailFile(zipFolder, thumbnail);

            //Save layers file.
            IEnumerable <Layerage> savedLayerages = LayerageCollection.GetUnUestingLayerages(this.ViewModel.LayerageCollection.RootLayerages);
            IEnumerable <ILayer>   savedLayers    = from layer in LayerBase.Instances where savedLayerages.Any(p => layer.Equals(p)) select layer;
            await XML.SaveLayersFile(zipFolder, savedLayers);

            //Save photos file.
            IEnumerable <Photocopier> savedPhotocopiers = LayerageCollection.GetPhotocopiers(savedLayerages);
            IEnumerable <Photo>       savedPhotos       = from photo in Photo.Instances where savedPhotocopiers.Any(p => photo.Equals(p)) select photo;
            await XML.SavePhotosFile(zipFolder, savedPhotos);

            //Move photo file.
            foreach (Photo photo in savedPhotos)
            {
                //await photo.MoveFile(zipFolder);
                //@Release
                {
                    //Move photo file.
                    StorageFile item = await StorageFile.GetFileFromPathAsync(photo.ImageFilePath);

                    await item.CopyAsync(zipFolder);
                }
            }
        }