public new void Add(ShapeBase shape) { if (shape != null && !Contains(shape)) { shape.Zoom = Zoom; if (shape.Index > -1) { Insert(shape.Index, shape); } else { if (shape.Type == ShapeType.ShapeDraw) { ShapeDraw tmp = null; if (_shapeDraw == null) { _shapeDraw = shape as ShapeDraw; tmp = _shapeDraw; foreach (ShapeBase item in _shapeDraw.Childs) { Add(item); } } else { tmp = shape as ShapeDraw; foreach (ShapeBase item in tmp.Childs) { _shapeDraw.AddChildShape(item); Add(item); } } } else { AddEvent(shape); base.Add(shape); if (shape.LayerType == LayerType.Paint) { ShapeDraw.AddChildShape(shape); } _changedService.MarkChanged(); } Document_AddRemoveShape(this, new AddRemoveShapeEventArgs(shape, AddRemoveShapeEventArgs.EventType.Add, this.IndexOf(shape))); } } }
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); }