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


            // Save project file.
            Project project = new Project
            {
                Width     = width,
                Height    = height,
                Layerages = LayerManager.RootLayerage.Children
            };
            await Retouch_Photo2.XML.SaveProjectFile(zipFolder, project);

            // Save thumbnail file.
            IProjectViewItem item = this.Items.FirstOrDefault(p => p.Name == name);

            if ((item is null) == false)
            {
                CanvasRenderTarget thumbnail = this.ViewModel.Render(width, height);
                item.ImageSource = await FileUtil.SaveThumbnailFile(zipFolder, thumbnail);
            }

            // Save layers file.
            IEnumerable <Layerage> savedLayerages = LayerManager.GetFlatNestingLayerages(LayerManager.RootLayerage);
            IEnumerable <ILayer>   savedLayers    = from layer in LayerBase.Instances.Values where savedLayerages.Any(p => layer.Equals(p)) select layer;
            await XML.SaveLayersFile(zipFolder, savedLayers);

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

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

                    await file.CopyAsync(zipFolder);
                }
            }
        }
Пример #2
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);
                }
            }
        }