/// <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 }