/// <summary> /// Duplicate zip folder. /// </summary> /// <param name="oldName"> The old name.</param> /// <param name="newName"> The new name.</param> /// <returns> The product ProjectViewItem. </returns> public static async Task <IProjectViewItem> DuplicateZipFolder(string oldName, string newName) { ProjectViewItem item = new ProjectViewItem { Name = newName }; // Duplicate zip folder. StorageFolder zipFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync($"{oldName}.photo2pk"); StorageFolder zipFolderNew = await ApplicationData.Current.LocalFolder.CreateFolderAsync($"{newName}.photo2pk", CreationCollisionOption.ReplaceExisting); IReadOnlyList <StorageFile> files = await zipFolder.GetFilesAsync(); foreach (StorageFile file in files) { await file.CopyAsync(zipFolderNew); if (file.Name == "Thumbnail.png") { using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read)) { item.ImageSource = await FileUtil.GetImageSource(stream); } } } return(item); }
private async Task NewFromPictureCore(StorageFile copyFile) { this.LoadingControl.State = LoadingState.Loading; // Photo if (copyFile is null) { this.LoadingControl.State = LoadingState.None; return; } Photo photo = await Photo.CreatePhotoFromCopyFileAsync(LayerManager.CanvasDevice, copyFile); Photo.DuplicateChecking(photo); // Transformer string name = this.UntitledRenameByRecursive($"{photo.Name}"); int width = (int)photo.Width; int height = (int)photo.Height; Transformer transformerSource = new Transformer(width, height, Vector2.Zero); // ImageLayer Photocopier photocopier = photo.ToPhotocopier(); Layerage imageLayerage = Layerage.CreateByGuid(); ImageLayer imageLayer = new ImageLayer { Id = imageLayerage.Id, Transform = new Transform(transformerSource), Photocopier = photocopier, }; LayerBase.Instances.Add(imageLayerage.Id, imageLayer); // Project Project project = new Project { Width = width, Height = height, Layerages = new List <Layerage> { imageLayerage } }; // Item IProjectViewItem item = new ProjectViewItem { Name = name, ImageSource = null, Project = project, }; this.Items.Insert(0, item); this.LoadingControl.State = LoadingState.None; this.Frame.Navigate(typeof(DrawPage), item); // Navigate }
/// <summary> /// New from project. /// </summary> /// <param name="project"> The project. </param> public void NewFromProject(Project project) { this.LoadingControl.State = LoadingState.Loading; string untitled = this.Untitled; string name = this.UntitledRenameByRecursive(untitled); // Item IProjectViewItem item = new ProjectViewItem { Name = name, ImageSource = null, Project = project, }; this.Items.Insert(0, item); this.LoadingControl.State = LoadingState.None; this.Frame.Navigate(typeof(DrawPage), item); // Navigate }