private async Task _newFromPicture(StorageFile copyFile) { this.LoadingControl.State = LoadingState.Loading; this.LoadingControl.IsActive = true; //Photo if (copyFile == null) { this.LoadingControl.State = LoadingState.None; this.LoadingControl.IsActive = false; return; } Photo photo = await Photo.CreatePhotoFromCopyFileAsync(this.ViewModel.CanvasDevice, copyFile); Photo.DuplicateChecking(photo); //Transformer string name = this.MainLayout.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(); ImageLayer imageLayer = new ImageLayer(this.ViewModel.CanvasDevice) { Transform = new Transform(transformerSource), Photocopier = photocopier, }; Layerage imageLayerage = imageLayer.ToLayerage(); LayerBase.Instances.Add(imageLayer); //Project { Project project = new Project { Name = name, Width = width, Height = height, Layerages = new List <Layerage> { imageLayerage } }; this.ViewModel.LoadFromProject(project); } //Transition TransitionData data = new TransitionData { Type = TransitionType.Size }; this.LoadingControl.State = LoadingState.None; this.LoadingControl.IsActive = false; this.Frame.Navigate(typeof(DrawPage), data);//Navigate }
//@Construct /// <summary> /// Initializes a LayersControl. /// </summary> public LayersControl() { this.InitializeComponent(); //LayerageCollection this.ConstructLayerageCollection(); this.ItemsControl.ItemsSource = this.ViewModel.LayerageCollection.RootControls; this.Tapped += (s, e) => this.MethodViewModel.MethodSelectedNone();//Method this.RightTapped += (s, e) => this.ShowLayerMenu(); this.Holding += (s, e) => this.ShowLayerMenu(); Retouch_Photo2.PhotosPage.AddImageCallBack += (photo) => { if (photo == null) { return; } //History LayeragesArrangeHistory history = new LayeragesArrangeHistory("Add layer", this.ViewModel.LayerageCollection); this.ViewModel.HistoryPush(history); //Transformer Transformer transformerSource = new Transformer(photo.Width, photo.Height, Vector2.Zero); //Layer Photocopier photocopier = photo.ToPhotocopier(); ImageLayer imageLayer = new ImageLayer(this.ViewModel.CanvasDevice) { Photocopier = photocopier, IsSelected = true, Transform = new Transform(transformerSource) }; Layerage imageLayerage = imageLayer.ToLayerage(); LayerBase.Instances.Add(imageLayer); //Selection this.SelectionViewModel.SetValue((layerage) => { ILayer layer = layerage.Self; layer.IsSelected = false; }); //Mezzanine LayerageCollection.Mezzanine(this.ViewModel.LayerageCollection, imageLayerage); this.SelectionViewModel.SetMode(this.ViewModel.LayerageCollection);//Selection LayerageCollection.ArrangeLayers(this.ViewModel.LayerageCollection); LayerageCollection.ArrangeLayersBackground(this.ViewModel.LayerageCollection); this.ViewModel.Invalidate();//Invalidate }; }
public void Started(Vector2 startingPoint, Vector2 point) { Photocopier photocopier = this.SelectionViewModel.Photocopier; if (photocopier.FolderRelativeId == null) { this.ImagePage.TipSelect(); return; } Photo photo = Photo.FindFirstPhoto(photocopier); if (photo == null) { this.ImagePage.TipSelect(); return; } //History LayeragesArrangeHistory history = new LayeragesArrangeHistory("Add layer", this.ViewModel.LayerageCollection); this.ViewModel.HistoryPush(history); //Transformer this._sizeWidth = photo.Width; this._sizeHeight = photo.Height; Transformer transformerSource = new Transformer(photo.Width, photo.Height, Vector2.Zero); Transformer transformerDestination = this.CreateTransformer(startingPoint, point, photo.Width, photo.Height); //Mezzanine ImageLayer imageLayer = new ImageLayer(this.ViewModel.CanvasDevice) { Photocopier = photocopier, IsSelected = true, Transform = new Transform(transformerSource, transformerDestination), Style = this.SelectionViewModel.StandGeometryStyle }; Layerage imageLayerage = imageLayer.ToLayerage(); LayerBase.Instances.Add(imageLayer); this.MezzanineLayerage = imageLayerage; LayerageCollection.Mezzanine(this.ViewModel.LayerageCollection, this.MezzanineLayerage); this.SelectionViewModel.Transformer = transformerDestination; //Selection this.ViewModel.Invalidate(InvalidateMode.Thumbnail); //Invalidate }