private Brush ToBrush(IBrush brush) { if (brush == null) { return(this.NoneBrush); } switch (brush.Type) { case BrushType.None: return(this.NoneBrush); case BrushType.Color: this.ColorBrush.Color = brush.Color; return(this.ColorBrush); case BrushType.LinearGradient: this.LinearGradientBrush.GradientStops = brush.Stops.ToStops(); return(this.LinearGradientBrush); case BrushType.RadialGradient: this.RadialGradientBrush.GradientStops = brush.Stops.ToStops(); return(this.RadialGradientBrush); case BrushType.EllipticalGradient: this.EllipticalGradientBrush.GradientStops = brush.Stops.ToStops(); return(this.EllipticalGradientBrush); case BrushType.Image: Photo photo = Photo.FindFirstPhoto(brush.Photocopier); this.BitmapImage.UriSource = new Uri(photo.ImageFilePath); return(this.ImageBrush); default: return(this.NoneBrush); } }
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 }