protected internal override int CopyToClipboard()
{
var returnValue = (int) OleConstants.OLECMDERR_E_NOTSUPPORTED;
try
{
RegisterClipboardNotifications(true);
// Create our data object and change the selection to show item(s) being copy
IOleDataObject dataObject = PackageSelectionDataObject(false);
if (dataObject != null)
{
SourceDraggedOrCutOrCopied = true;
// Add our copy item(s) to the clipboard
ErrorHandler.ThrowOnFailure(UnsafeNativeMethods.OleSetClipboard(dataObject));
// Inform VS (UiHierarchyWindow) of the copy
var clipboardHelper = (IVsUIHierWinClipboardHelper) GetService(typeof (SVsUIHierWinClipboardHelper));
if (clipboardHelper == null)
{
return VSConstants.E_FAIL;
}
returnValue = ErrorHandler.ThrowOnFailure(clipboardHelper.Copy(dataObject));
}
}
catch (COMException e)
{
Trace.WriteLine("Exception : " + e.Message);
returnValue = e.ErrorCode;
}
catch (ArgumentException e)
{
Trace.WriteLine("Exception : " + e.Message);
returnValue = Marshal.GetHRForException(e);
}
return returnValue;
}