public LayerAddedAction(LayerControl frameLayer) : base(frameLayer) { Name = string.Format("add <{0}> shape ", frameLayer.Shape.Type); if (frameLayer.Layer != null) { //_layer = frameLayer.Layer.Copy(); _layer = frameLayer.Layer; } }
public CopyItem(ShapeBase shape, IShapeLayer layer) { Shape = shape; Layer = layer; }
protected override bool DoPaste() { if (ClipboardService.ContainsImage()) { var img = ClipboardService.GetImage(); var imgFile = Constance.LibraryImageDir + Constance.DirectorySeparator + DateTime.Now.Ticks.ToString() + ".jpg"; IOHelper.SaveImage(img, imgFile); innerControl.AddImageLayer(imgFile); return(true); } foreach (var item in items) { if (item.Layer.Shape.LayerType == LayerType.Paint) { LayerControl lc = innerControl.GetLayerControl(item.Shape); if (lc != null || innerControl.IsExistShapeDraw) { ShapeBase pastedShape = item.Shape; pastedShape.ID = KeyGenerator.Shape; pastedShape.Move(Point.Empty); innerControl.AddLayer(pastedShape, ShapeAddMode.Clone); } else { IShapeLayer sl = item.Layer.Copy(); if (sl.Shape.Type == ShapeType.ShapeDraw) { ShapeDraw sd = sl.Shape as ShapeDraw; sd.Clear(); sd.AddChildShape(item.Shape); //sl.Shape = sd; } sl.Shape.Move(Point.Empty); LayerControl tmlayer = innerControl.NewLayerControl(sl as ShapeLayer, true); innerControl.AddLayer(tmlayer, ShapeAddMode.Clone); tmlayer.Shape.Zoom = item.Shape.Zoom; } } else { //LayerControl layerControl = innerControl.GetLayerControl(item.Shape); //if (layerControl != null) //{ // bool isBackGround = layerControl.Shape.IsBackground; // ShapeLayer item = layerControl.Layer.Copy(); // item.Shape = item.Shape.Copy(); // item.Shape.Move(Point.Empty); // if (isBackGround) // { // item.Shape.BeginEdit(); // item.Shape.IsBackground = false; // item.Shape.EndEdit(); // } // innerControl.AddLayer(innerControl.NewLayerControl(item, true), ShapeAddMode.Clone); // if(isBackGround) // item.Shape.IsBackground = isBackGround; //} //else //{ bool isBackGround = item.Layer.Shape.IsBackground; if (isBackGround) { item.Layer.Shape.BeginEdit(); item.Layer.Shape.IsBackground = false; item.Layer.Shape.EndEdit(); } var sl = item.Layer.Copy(); sl.Shape.Move(Point.Empty); innerControl.AddLayer(innerControl.NewLayerControl(sl as ShapeLayer, true), ShapeAddMode.Clone); if (isBackGround) { item.Layer.Shape.IsBackground = isBackGround; } //} } } innerControl.ShapeControl.Invalidate(); return(true); }