private void CleanAndFlushClipboard()
{
IOleDataObject oleDataObject = null;
ErrorHandler.ThrowOnFailure(UnsafeNativeMethods.OleGetClipboard(out oleDataObject));
if (oleDataObject == null)
{
return;
}
var sourceProjectPath = DragDropHelper.GetSourceProjectPath(oleDataObject);
if (!string.IsNullOrEmpty(sourceProjectPath) && NativeMethods.IsSamePath(sourceProjectPath, GetMkDocument()))
{
ErrorHandler.ThrowOnFailure(UnsafeNativeMethods.OleFlushClipboard());
var clipboardOpened = 0;
try
{
ErrorHandler.ThrowOnFailure(clipboardOpened = UnsafeNativeMethods.OpenClipboard(IntPtr.Zero));
ErrorHandler.ThrowOnFailure(UnsafeNativeMethods.EmptyClipboard());
}
finally
{
if (clipboardOpened == 1)
{
ErrorHandler.ThrowOnFailure(UnsafeNativeMethods.CloseClipboard());
}
}
}
}