public static void Paste(Drawing drawing, string xmlContent) { var action = new PasteAction( drawing, xmlContent); drawing.ActionManager.RecordAction(action); }
public void Duplicate() { var transaction = Transaction.Create(ActionManager, false); List <IFigure> list = GetSelectedFiguresWithDependencies(); var s = new System.Text.StringBuilder(); using (var w = System.Xml.XmlWriter.Create(s, new System.Xml.XmlWriterSettings() { Indent = true })) { new DrawingSerializer().WriteFigureList(list, w); } var paste = new PasteAction(this, s.ToString()); ActionManager.RecordAction(paste); // Offset the new figures. List <IMovable> moving = new List <IMovable>(); foreach (IFigure f in paste.Figures.Where(f => f as IMovable != null)) { moving.Add(f as IMovable); } Actions.Move(this, moving, new Point(1, -1), Figures); // Select new figures. Figures.ClearSelection(); foreach (IFigure f in paste.Figures) { f.Selected = true; } RaiseUserIsAddingFigures(new UIAFEventArgs() { Figures = paste.Figures }); transaction.Commit(); }
public void Duplicate() { var transaction = Transaction.Create(ActionManager, false); List<IFigure> list = GetSelectedFiguresWithDependencies(); var s = new System.Text.StringBuilder(); using (var w = System.Xml.XmlWriter.Create(s, new System.Xml.XmlWriterSettings() { Indent = true })) { new DrawingSerializer().WriteFigureList(list, w); } var paste = new PasteAction(this, s.ToString()); ActionManager.RecordAction(paste); // Offset the new figures. List<IMovable> moving = new List<IMovable>(); foreach (IFigure f in paste.Figures.Where(f => f as IMovable != null)) { moving.Add(f as IMovable); } Actions.Move(this, moving, new Point(1, -1), Figures); // Select new figures. Figures.ClearSelection(); foreach (IFigure f in paste.Figures) { f.Selected = true; } RaiseUserIsAddingFigures(new UIAFEventArgs() {Figures = paste.Figures}); transaction.Commit(); }