/// <summary> /// Open from ProjectViewItem. /// </summary> /// <param name="item"> The ProjectViewItem. </param> public async void OpenFromProjectViewItem(IProjectViewItem item) { this.LoadingControl.State = LoadingState.Loading; // FileUtil string name = item.Name; if (name is null || name == string.Empty) { this.LoadingControl.State = LoadingState.FileNull; await Task.Delay(800); this.LoadingControl.State = LoadingState.None; return; } // FileUtil await FileUtil.DeleteAllInTemporaryFolder(); bool isExists = await FileUtil.MoveAllInZipFolderToTemporaryFolder(name); if (isExists == false) { this.LoadingControl.State = LoadingState.FileCorrupt; await Task.Delay(800); this.LoadingControl.State = LoadingState.None; return; } // Load all photos file. Photo.Instances.Clear(); Photo.InstancesCollection.Clear(); IEnumerable <Photo> photos = XML.LoadPhotosFile(); if ((photos is null) == false) { foreach (Photo photo in photos) { string id = photo.FolderRelativeId; await photo.ConstructPhotoSource(LayerManager.CanvasDevice); Photo.Instances.Add(id, photo); Photo.UpdateInstancesCollection(); } } // Load all layers file. LayerBase.Instances.Clear(); IEnumerable <ILayer> layers = XML.LoadLayersFile(); if ((layers is null) == false) { foreach (ILayer layer in layers) { string id = layer.Id; LayerBase.Instances.Add(id, layer); } } // Load project file. Project project = XML.LoadProjectFile(); if (project is null) { this.LoadingControl.State = LoadingState.LoadFailed; await Task.Delay(800); this.LoadingControl.State = LoadingState.None; return; } // Item item.Project = project; item.RenderImageVisualRect(Window.Current.Content); this.LoadingControl.State = LoadingState.None; this.Frame.Navigate(typeof(DrawPage), item); // Navigate }
/// <summary> /// Open from ProjectViewItem. /// </summary> /// <param name="projectViewItem"> The ProjectViewItem. </param> public async void OpenFromProjectViewItem(IProjectViewItem projectViewItem) { this.LoadingControl.State = LoadingState.Loading; this.LoadingControl.IsActive = true; //FileUtil string name = projectViewItem.Name; if (name == null || name == string.Empty) { this.LoadingControl.IsActive = false; this.LoadingControl.State = LoadingState.FileNull; await Task.Delay(800); this.LoadingControl.State = LoadingState.None; return; } await FileUtil.DeleteInTemporaryFolder(); bool isExists = await FileUtil.MoveAllAndReturn(name); if (isExists == false) { this.LoadingControl.IsActive = false; this.LoadingControl.State = LoadingState.FileCorrupt; await Task.Delay(800); this.LoadingControl.State = LoadingState.None; return; } //Load all photos file. Photo.Instances.Clear(); IEnumerable <Photo> photos = XML.LoadPhotosFile(); if (photos != null) { foreach (Photo photo in photos) { await photo.ConstructPhotoSource(this.ViewModel.CanvasDevice); Photo.Instances.Add(photo); } } //Load all layers file. LayerBase.Instances.Clear(); IEnumerable <ILayer> layers = XML.LoadLayersFile(this.ViewModel.CanvasDevice); if (layers != null) { foreach (ILayer layer in layers) { LayerBase.Instances.Add(layer); } } //Load project file. Project project = XML.LoadProjectFile(name); if (project == null) { this.LoadingControl.IsActive = false; this.LoadingControl.State = LoadingState.LoadFailed; await Task.Delay(800); this.LoadingControl.State = LoadingState.None; return; } this.ViewModel.LoadFromProject(project); this.SelectionViewModel.SetMode(this.ViewModel.LayerageCollection);//Selection //Transition TransitionData data = new TransitionData { Type = TransitionType.Transition, SourceRect = projectViewItem.GetVisualRect(Window.Current.Content), PageSize = new Size(this.ActualWidth, this.ActualHeight - 50) }; this.LoadingControl.State = LoadingState.None; this.LoadingControl.IsActive = false; this.Frame.Navigate(typeof(DrawPage), data);//Navigate }