private void CommandPaste() { if (CommandCanPaste()) { ObjectSelectionClipboard clip = ObjectSelectionClipboard.CopyFromClipboard(Layer.Level.Project); if (clip == null) { return; } ObjectSelectTool tool = _currentTool as ObjectSelectTool; if (tool == null) { SetCurrentTool(NewSelectTool()); } _selectionManager.ClearSelection(); CenterObjectsInViewport(clip.Objects); Command command = new ObjectAddCommand(Layer, clip.Objects, _selectionManager); LayerContext.History.Execute(command); foreach (ObjectInstance inst in clip.Objects) { //Layer.AddObject(inst); _selectionManager.AddObjectToSelection(inst); } } }
private void CommandCopy() { if (CommandCanCopy()) { ObjectSelectionClipboard clip = new ObjectSelectionClipboard(_selectionManager.SelectedObjects); clip.CopyToClipboard(); CommandManager.Invalidate(CommandKey.Paste); } }
public static ObjectSelectionClipboard CopyFromClipboard(Project project) { ObjectSelectionClipboard clip = Clipboard.GetData(typeof(ObjectSelectionClipboard).FullName) as ObjectSelectionClipboard; if (clip == null) { return(null); } foreach (ObjectInstance inst in clip.Objects) { inst.PostDeserialize(project); } return(clip); }