Hi Douglas,
The following code performs paste at location for a view of your choice.
public NTransactionResult Paste(NDrawingView view, NPointF location)
{
NTransactionResult result = new NTransactionResult(NDR.TransactionPaste);
if (view.CanPaste() == false)
{
result.Status = TransactionResultStatus.FailedNotExecuted;
return result;
}
view.Document.StartTransaction(NDR.TransactionPaste);
try
{
// get data object from the clipboard and adapt it to drawing data object
// using the document data object adaptors
IDataObject dataObject = Clipboard.GetDataObject();
NDataObjectAdaptor adapter = view.Document.DataObjectAdaptors.GetAdaptorForDataObject(dataObject);
NDrawingDataObject ddo = (adapter.Adapt(dataObject) as NDrawingDataObject);
// calculate the translation needed to position the elements so that their bounds center
// is mapped to the location argument.
NNodeList elements = new NNodeList(ddo.Elements);
NBatchTranslate batch = new NBatchTranslate(null, elements);
NRectangleF batchBounds = batch.Bounds;
float dx = batchBounds.Center.X - location.X;
float dy = batchBounds.Center.Y - location.Y;
// translate data object elements and add them in the document active layer.
result.Combine(batch.Translate(dx, dy, true, false), false);
result.Combine(ddo.AddInComposite(view.Document, view.Document.ActiveLayer), false);
// select the pasted elements
view.Selection.SingleSelect(elements);
}
catch (Exception ex)
{
view.Document.Rollback();
result.LogError(ex);
result.Status = TransactionResultStatus.FailedRolledback;
return result;
}
view.Document.Commit();
return result;
}
Best Regards,
Nevron Support Team