/// <summary> /// Handle the Copy operation to the clipboard /// </summary> protected internal override int CopyToClipboard() { int returnValue = (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; try { this.RegisterClipboardNotifications(true); // Create our data object and change the selection to show item(s) being copy IOleDataObject dataObject = this.PackageSelectionDataObject(false); if (dataObject != null) { this.SourceDraggedOrCutOrCopied = true; // Add our copy item(s) to the clipboard ErrorHandler.ThrowOnFailure(UnsafeNativeMethods.OleSetClipboard(dataObject)); // Inform VS (UiHierarchyWindow) of the copy IVsUIHierWinClipboardHelper 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); }