本文整理汇总了C#中Microsoft.VisualStudio.OLE.Interop.IDataObject类的典型用法代码示例。如果您正苦于以下问题:C# IDataObject类的具体用法?C# IDataObject怎么用?C# IDataObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDataObject类属于Microsoft.VisualStudio.OLE.Interop命名空间,在下文中一共展示了IDataObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DragEnter
/// <summary>
/// Called as soon as the mouse drags an item over a new hierarchy or hierarchy window
/// </summary>
/// <param name="pDataObject">reference to interface IDataObject of the item being dragged</param>
/// <param name="grfKeyState">Current state of the keyboard and the mouse modifier keys. See docs for a list of possible values</param>
/// <param name="itemid">Item identifier for the item currently being dragged</param>
/// <param name="pdwEffect">On entry, a pointer to the current DropEffect. On return, must contain the new valid DropEffect</param>
/// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns>
public override int DragEnter(IOleDataObject pDataObject, uint grfKeyState, uint itemid, ref uint pdwEffect)
{
pdwEffect = (uint)DropEffect.None;
this.dropDataType = QueryDropDataType(pDataObject);
if (this.dropDataType != DropDataType.None)
{
pdwEffect = (uint)this.QueryDropEffect(this.dropDataType, grfKeyState);
}
return VSConstants.S_OK;
}
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:20,代码来源:projectnode.copypaste.cs
示例2: DragEnter
/// <summary>
/// Called as soon as the mouse drags an item over a new hierarchy or hierarchy window
/// </summary>
/// <param name="pDataObject">reference to interface IDataObject of the item being dragged</param>
/// <param name="grfKeyState">Current state of the keyboard and the mouse modifier keys. See docs for a list of possible values</param>
/// <param name="itemid">Item identifier for the item currently being dragged</param>
/// <param name="pdwEffect">On entry, a pointer to the current DropEffect. On return, must contain the new valid DropEffect</param>
/// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns>
public int DragEnter(IOleDataObject pDataObject, uint grfKeyState, uint itemid, ref uint pdwEffect) {
pdwEffect = (uint)DropEffect.None;
var item = NodeFromItemId(itemid);
if (item.GetDragTargetHandlerNode().CanAddFiles) {
_dropType = QueryDropDataType(pDataObject);
if (_dropType != DropDataType.None) {
pdwEffect = (uint)QueryDropEffect(grfKeyState);
}
}
return VSConstants.S_OK;
}
开发者ID:CforED,项目名称:Node.js-Tools-for-Visual-Studio,代码行数:22,代码来源:ProjectNode.CopyPaste.cs
示例3: DragEnter
/// <summary>
/// Called as soon as the mouse drags an item over a new hierarchy or hierarchy window
/// </summary>
/// <param name="pDataObject">reference to interface IDataObject of the item being dragged</param>
/// <param name="grfKeyState">Current state of the keyboard and the mouse modifier keys. See docs for a list of possible values</param>
/// <param name="itemid">Item identifier for the item currently bbeing dragged</param>
/// <param name="pdwEffect">On entry, a pointer to the current DropEffect. On return, must contain the
/// new valid DropEffect</param>
/// <returns>S_OK if the method succeeds</returns>
public override int DragEnter(IOleDataObject pDataObject, uint grfKeyState, uint itemid, ref uint pdwEffect)
{
pdwEffect = (uint)DropEffect.None;
if (this.SourceDraggedOrCutOrCopied)
{
return VSConstants.S_OK;
}
else
{
this.dataObject = (IOleDataObject)pDataObject;
}
this.dropDataType = QueryDropDataType(pDataObject);
if (this.dropDataType != DropDataType.None)
{
pdwEffect = (uint)QueryDropEffect(this.dropDataType, grfKeyState);
}
return VSConstants.S_OK;
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:28,代码来源:ProjectNode.CopyPaste.cs
示例4: DragEnter
/// <summary>
/// Called as soon as the mouse drags an item over a new hierarchy or hierarchy window
/// </summary>
/// <param name="pDataObject">reference to interface IDataObject of the item being dragged</param>
/// <param name="grfKeyState">Current state of the keyboard and the mouse modifier keys. See docs for a list of possible values</param>
/// <param name="itemid">Item identifier for the item currently being dragged</param>
/// <param name="pdwEffect">On entry, a pointer to the current DropEffect. On return, must contain the new valid DropEffect</param>
/// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns>
public override int DragEnter(IOleDataObject pDataObject, uint grfKeyState, uint itemid, ref uint pdwEffect)
{
pdwEffect = (uint)DropEffect.None;
// changed from MPFProj:
// http://mpfproj10.codeplex.com/WorkItem/View.aspx?WorkItemId=8145
/*
if(this.SourceDraggedOrCutOrCopied)
{
return VSConstants.S_OK;
}*/
this.dropDataType = QueryDropDataType(pDataObject);
if (this.dropDataType != DropDataType.None)
{
pdwEffect = (uint)this.QueryDropEffect(this.dropDataType, grfKeyState);
}
return VSConstants.S_OK;
}
开发者ID:borota,项目名称:JTVS,代码行数:28,代码来源:ProjectNode.CopyPaste.cs
示例5: GetDropInfo
/// <summary>
/// Returns information about one or more of the items being dragged
/// </summary>
/// <param name="pdwOKEffects">Pointer to a DWORD value describing the effects displayed while the item is being dragged,
/// such as cursor icons that change during the drag-and-drop operation.
/// For example, if the item is dragged over an invalid target point
/// (such as the item's original location), the cursor icon changes to a circle with a line through it.
/// Similarly, if the item is dragged over a valid target point, the cursor icon changes to a file or folder.</param>
/// <param name="ppDataObject">Pointer to the IDataObject interface on the item being dragged.
/// This data object contains the data being transferred in the drag-and-drop operation.
/// If the drop occurs, then this data object (item) is incorporated into the target hierarchy or hierarchy window.</param>
/// <param name="ppDropSource">Pointer to the IDropSource interface of the item being dragged.</param>
/// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns>
public override int GetDropInfo(out uint pdwOKEffects, out IOleDataObject ppDataObject, out IDropSource ppDropSource)
{
//init out params
pdwOKEffects = (uint)DropEffect.None;
ppDataObject = null;
ppDropSource = null;
IOleDataObject dataObject = PackageSelectionDataObject(false);
if (dataObject == null)
{
return VSConstants.E_NOTIMPL;
}
this.SourceDraggedOrCutOrCopied = true;
this.SourceDragged = true;
pdwOKEffects = (uint)(DropEffect.Move | DropEffect.Copy);
ppDataObject = dataObject;
return VSConstants.S_OK;
}
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:34,代码来源:projectnode.copypaste.cs
示例6: IsSupported
/// <summary>
/// The is supported.
/// </summary>
/// <param name="pDO">
/// The p do.
/// </param>
/// <returns>
/// The <see cref="int"/>.
/// </returns>
public int IsSupported(IDataObject pDO)
{
// Create a OleDataObject from the input interface.
var oleData = new OleDataObject(pDO);
// && EditorControl.RichTextBoxControl.CanPaste(DataFormats.GetFormat(DataFormats.UnicodeText))
// Check if the data object is of type UnicodeText.
if (oleData.GetDataPresent(DataFormats.UnicodeText))
{
return VSConstants.S_OK;
}
// In all the other cases return S_FALSE
return VSConstants.S_FALSE;
}
开发者ID:ZinkoSoft,项目名称:NuSet,代码行数:24,代码来源:EditorPane.cs
示例7:
/// <summary>
/// The get selection data object.
/// </summary>
/// <param name="ppIDataObject">
/// The pp i data object.
/// </param>
/// <returns>
/// The <see cref="int"/>.
/// </returns>
int IVsTextView.GetSelectionDataObject(out IDataObject ppIDataObject)
{
ppIDataObject = null;
return VSConstants.E_NOTIMPL;
}
开发者ID:ZinkoSoft,项目名称:NuSet,代码行数:14,代码来源:EditorPane.cs
示例8: Ole2BclDataObject
internal Ole2BclDataObject(BclComTypes.IDataObject bclData)
{
if (null == bclData)
throw new ArgumentNullException("System.Runtime.InteropServices.ComTypes.IDataObject");
//this.oleData = bclData as OleInterop.IDataObject;
this.oleData = null;
this.bclData = bclData;
}
开发者ID:Graham-Pedersen,项目名称:IronPlot,代码行数:8,代码来源:OleToBCL.cs
示例9: ItemPicked
/// <summary>
/// The item picked.
/// </summary>
/// <param name="pDO">
/// The p do.
/// </param>
/// <returns>
/// The <see cref="int"/>.
/// </returns>
public int ItemPicked(IDataObject pDO)
{
// Create a OleDataObject from the input interface.
var oleData = new OleDataObject(pDO);
// Check if the picked item is the one we can paste.
if (oleData.GetDataPresent(DataFormats.UnicodeText))
{
object o = null;
this.EditorControl.TextSelection.Paste(ref o, 0);
}
return VSConstants.S_OK;
}
开发者ID:ZinkoSoft,项目名称:NuSet,代码行数:23,代码来源:EditorPane.cs
示例10: Drop
/// <summary>
/// Called when one or more items are dropped into the target hierarchy or hierarchy window when the mouse button is released.
/// </summary>
/// <param name="pDataObject">Reference to the IDataObject interface on the item being dragged. This data object contains the data being transferred in the drag-and-drop operation.
/// If the drop occurs, then this data object (item) is incorporated into the target hierarchy or hierarchy window.</param>
/// <param name="grfKeyState">Current state of the keyboard and the mouse modifier keys. See <seealso cref="IVsHierarchyDropDataTarget"/></param>
/// <param name="itemid">Item identifier of the drop data target over which the item is being dragged</param>
/// <param name="pdwEffect">Visual effects associated with the drag-and drop-operation, such as a cursor, bitmap, and so on.
/// The value of dwEffects passed to the source object via the OnDropNotify method is the value of pdwEffects returned by the Drop method</param>
/// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code. </returns>
public override int Drop(IOleDataObject pDataObject, uint grfKeyState, uint itemid, ref uint pdwEffect)
{
if (pDataObject == null)
{
return VSConstants.E_INVALIDARG;
}
pdwEffect = (uint)DropEffect.None;
// Get the node that is being dragged over and ask it which node should handle this call
HierarchyNode targetNode = NodeFromItemId(itemid);
if (targetNode != null)
{
targetNode = targetNode.GetDragTargetHandlerNode();
}
else
{
// There is no target node. The drop can not be completed.
return VSConstants.S_FALSE;
}
int returnValue;
try
{
this.isInPasteOrDrop = true;
DropDataType dropDataType = DropDataType.None;
dropDataType = ProcessSelectionDataObject(pDataObject, targetNode, grfKeyState);
pdwEffect = (uint)this.QueryDropEffect(dropDataType, grfKeyState);
// If it is a drop from windows and we get any kind of error we return S_FALSE and dropeffect none. This
// prevents bogus messages from the shell from being displayed
returnValue = (dropDataType != DropDataType.Shell) ? VSConstants.E_FAIL : VSConstants.S_OK;
}
catch (System.IO.FileNotFoundException e)
{
Trace.WriteLine("Exception : " + e.Message);
if (!Utilities.IsInAutomationFunction(this.Site))
{
string message = e.Message;
string title = string.Empty;
OLEMSGICON icon = OLEMSGICON.OLEMSGICON_CRITICAL;
OLEMSGBUTTON buttons = OLEMSGBUTTON.OLEMSGBUTTON_OK;
OLEMSGDEFBUTTON defaultButton = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;
VsShellUtilities.ShowMessageBox(this.Site, title, message, icon, buttons, defaultButton);
}
returnValue = VSConstants.E_FAIL;
}
finally
{
this.isInPasteOrDrop = false;
this.dropAsCopy = false;
}
return returnValue;
}
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:67,代码来源:projectnode.copypaste.cs
示例11: DragEnter
/// <summary>
/// Called as soon as the mouse drags an item over a new hierarchy or hierarchy window
/// </summary>
/// <param name="dataObject">reference to interface IDataObject of the item being dragged</param>
/// <param name="keyState">Current state of the keyboard and the mouse modifier keys. See docs for a list of possible values</param>
/// <param name="itemId">Item identifier for the item currently being dragged</param>
/// <param name="effect">On entry, a pointer to the current DropEffect. On return, must contain the new valid DropEffect</param>
/// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns>
public override int DragEnter(IOleDataObject dataObject, uint keyState, uint itemId, ref DropEffects effect)
{
effect = DropEffects.None;
if(this.SourceDraggedOrCutOrCopied)
{
return VSConstants.S_OK;
}
this._dropDataType = QueryDropDataType(dataObject);
if(this._dropDataType != DropDataType.None)
{
effect = this.QueryDropEffect(this._dropDataType, keyState);
}
return VSConstants.S_OK;
}
开发者ID:tunnelvisionlabs,项目名称:MPFProj10,代码行数:25,代码来源:ProjectNode.CopyPaste.cs
示例12: OnBeforeDropNotify
/// <summary>
/// Allows the drag source to prompt to save unsaved items being dropped.
/// Notifies the source hierarchy that information dragged from it is about to be dropped on a target.
/// This method is called immediately after the mouse button is released on a drop.
/// </summary>
/// <param name="o">Reference to the IDataObject interface on the item being dragged.
/// This data object contains the data being transferred in the drag-and-drop operation.
/// If the drop occurs, then this data object (item) is incorporated into the hierarchy window of the new hierarchy.</param>
/// <param name="dwEffect">Current state of the keyboard and the mouse modifier keys.</param>
/// <param name="fCancelDrop">If true, then the drop is cancelled by the source hierarchy. If false, then the drop can continue.</param>
/// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code. </returns>
public override int OnBeforeDropNotify(IOleDataObject o, uint dwEffect, out int fCancelDrop)
{
// If there is nothing to be dropped just return that drop should be cancelled.
if (this.ItemsDraggedOrCutOrCopied == null)
{
fCancelDrop = 1;
return VSConstants.S_OK;
}
fCancelDrop = 0;
bool dirty = false;
foreach (HierarchyNode node in this.ItemsDraggedOrCutOrCopied)
{
bool isDirty, isOpen, isOpenedByUs;
uint docCookie;
IVsPersistDocData ppIVsPersistDocData;
DocumentManager manager = node.GetDocumentManager();
if (manager != null)
{
manager.GetDocInfo(out isOpen, out isDirty, out isOpenedByUs, out docCookie, out ppIVsPersistDocData);
if (isDirty && isOpenedByUs)
{
dirty = true;
break;
}
}
}
// if there are no dirty docs we are ok to proceed
if (!dirty)
{
return VSConstants.S_OK;
}
// Prompt to save if there are dirty docs
string message = SR.GetString(SR.SaveModifiedDocuments, CultureInfo.CurrentUICulture);
string title = string.Empty;
OLEMSGICON icon = OLEMSGICON.OLEMSGICON_WARNING;
OLEMSGBUTTON buttons = OLEMSGBUTTON.OLEMSGBUTTON_YESNOCANCEL;
OLEMSGDEFBUTTON defaultButton = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;
int result = VsShellUtilities.ShowMessageBox(Site, title, message, icon, buttons, defaultButton);
switch (result)
{
case NativeMethods.IDYES:
break;
case NativeMethods.IDNO:
return VSConstants.S_OK;
case NativeMethods.IDCANCEL: goto default;
default:
fCancelDrop = 1;
return VSConstants.S_OK;
}
// Save all dirty documents
foreach (HierarchyNode node in this.ItemsDraggedOrCutOrCopied)
{
DocumentManager manager = node.GetDocumentManager();
if (manager != null)
{
manager.Save(true);
}
}
return VSConstants.S_OK;
}
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:79,代码来源:projectnode.copypaste.cs
示例13: GetDropInfo
/// <summary>
/// Returns information about one or more of the items being dragged
/// </summary>
/// <param name="effects">Pointer to a DWORD value describing the effects displayed while the item is being dragged,
/// such as cursor icons that change during the drag-and-drop operation.
/// For example, if the item is dragged over an invalid target point
/// (such as the item's original location), the cursor icon changes to a circle with a line through it.
/// Similarly, if the item is dragged over a valid target point, the cursor icon changes to a file or folder.</param>
/// <param name="dataObject">Pointer to the IDataObject interface on the item being dragged.
/// This data object contains the data being transferred in the drag-and-drop operation.
/// If the drop occurs, then this data object (item) is incorporated into the target hierarchy or hierarchy window.</param>
/// <param name="dropSource">Pointer to the IDropSource interface of the item being dragged.</param>
/// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns>
public override int GetDropInfo(out DropEffects effects, out IOleDataObject dataObject, out IDropSource dropSource)
{
//init out params
effects = (uint)DropEffects.None;
dataObject = null;
dropSource = null;
IOleDataObject selectionDataObject = PackageSelectionDataObject(false);
if(selectionDataObject == null)
{
return VSConstants.E_NOTIMPL;
}
this.SourceDraggedOrCutOrCopied = true;
effects = DropEffects.Move | DropEffects.Copy;
dataObject = selectionDataObject;
return VSConstants.S_OK;
}
开发者ID:tunnelvisionlabs,项目名称:MPFProj10,代码行数:33,代码来源:ProjectNode.CopyPaste.cs
示例14: ProcessSelectionDataObject
/// <summary>
/// Process dataobject from Drag/Drop/Cut/Copy/Paste operation
/// </summary>
/// <remarks>The targetNode is set if the method is called from a drop operation, otherwise it is null</remarks>
internal DropDataType ProcessSelectionDataObject(IOleDataObject dataObject, HierarchyNode targetNode)
{
DropDataType dropDataType = DropDataType.None;
bool isWindowsFormat = false;
// Try to get it as a directory based project.
List<string> filesDropped = DragDropHelper.GetDroppedFiles(DragDropHelper.CF_VSSTGPROJECTITEMS, dataObject, out dropDataType);
if (filesDropped.Count == 0)
{
filesDropped = DragDropHelper.GetDroppedFiles(DragDropHelper.CF_VSREFPROJECTITEMS, dataObject, out dropDataType);
}
if (filesDropped.Count == 0)
{
filesDropped = DragDropHelper.GetDroppedFiles(NativeMethods.CF_HDROP, dataObject, out dropDataType);
isWindowsFormat = (filesDropped.Count > 0);
}
if (dropDataType != DropDataType.None && filesDropped.Count > 0)
{
string[] filesDroppedAsArray = filesDropped.ToArray();
HierarchyNode node = (targetNode == null) ? this : targetNode;
// For directory based projects the content of the clipboard is a double-NULL terminated list of Projref strings.
if (isWindowsFormat)
{
// This is the code path when source is windows explorer
VSADDRESULT[] vsaddresults = new VSADDRESULT[1];
vsaddresults[0] = VSADDRESULT.ADDRESULT_Failure;
int addResult = AddItem(node.ID, VSADDITEMOPERATION.VSADDITEMOP_OPENFILE, null, (uint)filesDropped.Count, filesDroppedAsArray, IntPtr.Zero, vsaddresults);
if (addResult != VSConstants.S_OK && addResult != VSConstants.S_FALSE && addResult != (int)OleConstants.OLECMDERR_E_CANCELED
&& vsaddresults[0] != VSADDRESULT.ADDRESULT_Success)
{
ErrorHandler.ThrowOnFailure(addResult);
}
return dropDataType;
}
else
{
if (AddFilesFromProjectReferences(node, filesDroppedAsArray))
{
return dropDataType;
}
}
}
// If we reached this point then the drop data must be set to None.
// Otherwise the OnPaste will be called with a valid DropData and that would actually delete the item.
return DropDataType.None;
}
开发者ID:CaptainHayashi,项目名称:visualfsharp,代码行数:55,代码来源:ProjectNode.CopyPaste.cs
示例15: ProcessSelectionDataObject
/// <summary>
/// Process dataobject from Drag/Drop/Cut/Copy/Paste operation
///
/// drop indicates if it is a drag/drop or a cut/copy/paste.
/// </summary>
/// <remarks>The targetNode is set if the method is called from a drop operation, otherwise it is null</remarks>
internal DropDataType ProcessSelectionDataObject(IOleDataObject dataObject, HierarchyNode targetNode, bool drop, DropEffect dropEffect) {
Utilities.ArgumentNotNull("targetNode", targetNode);
DropDataType dropDataType = DropDataType.None;
bool isWindowsFormat = false;
// Try to get it as a directory based project.
List<string> filesDropped = DragDropHelper.GetDroppedFiles(DragDropHelper.CF_VSSTGPROJECTITEMS, dataObject, out dropDataType);
if (filesDropped.Count == 0) {
filesDropped = DragDropHelper.GetDroppedFiles(DragDropHelper.CF_VSREFPROJECTITEMS, dataObject, out dropDataType);
}
if (filesDropped.Count == 0) {
filesDropped = DragDropHelper.GetDroppedFiles(NativeMethods.CF_HDROP, dataObject, out dropDataType);
isWindowsFormat = (filesDropped.Count > 0);
}
if (dropDataType != DropDataType.None && filesDropped.Count > 0) {
string[] filesDroppedAsArray = filesDropped.ToArray();
HierarchyNode node = targetNode;
// For directory based projects the content of the clipboard is a double-NULL terminated list of Projref strings.
if (isWindowsFormat) {
DropFilesOrFolders(filesDroppedAsArray, node);
return dropDataType;
} else {
if (AddFilesFromProjectReferences(node, filesDroppedAsArray, drop, dropEffect)) {
return dropDataType;
}
}
}
// If we reached this point then the drop data must be set to None.
// Otherwise the OnPaste will be called with a valid DropData and that would actually delete the item.
return DropDataType.None;
}
开发者ID:CforED,项目名称:Node.js-Tools-for-Visual-Studio,代码行数:43,代码来源:ProjectNode.CopyPaste.cs
示例16: CutToClipboard
/// <summary>
/// Handle the Cut operation to the clipboard
/// </summary>
protected internal override int CutToClipboard()
{
int returnValue = (int)OleConstants.OLECMDERR_E_NOTSUPPORTED;
try
{
this.RegisterClipboardNotifications(true);
// Create our data object and change the selection to show item(s) being cut
this.dataObject = this.PackageSelectionDataObject(true);
if (this.dataObject != null)
{
this.SourceDraggedOrCutOrCopied = true;
// Add our cut item(s) to the clipboard
ErrorHandler.ThrowOnFailure(UnsafeNativeMethods.OleSetClipboard(dataObject));
// Inform VS (UiHierarchyWindow) of the cut
IVsUIHierWinClipboardHelper clipboardHelper = (IVsUIHierWinClipboardHelper)GetService(typeof(SVsUIHierWinClipboardHelper));
if (clipboardHelper == null)
{
return VSConstants.E_FAIL;
}
returnValue = ErrorHandler.ThrowOnFailure(clipboardHelper.Cut(dataObject));
}
}
catch (COMException e)
{
Trace.WriteLine("Exception : " + e.Message);
returnValue = e.ErrorCode;
}
return returnValue;
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:36,代码来源:ProjectNode.CopyPaste.cs
示例17: QueryDropDataType
/// <summary>
/// Get the dropdatatype from the dataobject
/// </summary>
/// <param name="pDataObject">The dataobject to be analysed for its format</param>
/// <returns>dropdatatype or none if dataobject does not contain known format</returns>
internal static DropDataType QueryDropDataType(IOleDataObject pDataObject)
{
if (pDataObject == null)
{
return DropDataType.None;
}
// known formats include File Drops (as from WindowsExplorer),
// VSProject Reference Items and VSProject Storage Items.
FORMATETC fmt = DragDropHelper.CreateFormatEtc(NativeMethods.CF_HDROP);
if (DragDropHelper.QueryGetData(pDataObject, ref fmt) == VSConstants.S_OK)
{
return DropDataType.Shell;
}
fmt.cfFormat = DragDropHelper.CF_VSREFPROJECTITEMS;
if (DragDropHelper.QueryGetData(pDataObject, ref fmt) == VSConstants.S_OK)
{
// Data is from a Ref-based project.
return DropDataType.VsRef;
}
fmt.cfFormat = DragDropHelper.CF_VSSTGPROJECTITEMS;
if (DragDropHelper.QueryGetData(pDataObject, ref fmt) == VSConstants.S_OK)
{
return DropDataType.VsStg;
}
return DropDataType.None;
}
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:36,代码来源:projectnode.copypaste.cs
示例18: DragOver
public override int DragOver(uint grfKeyState, uint itemid, ref uint pdwEffect)
{
if (this.dataObject == null)
{
this.dataObject = PackageSelectionDataObject(false);
}
this.dropDataType = QueryDropDataType(this.dataObject);
if (this.dropDataType != DropDataType.None)
{
pdwEffect = (uint)QueryDropEffect(dropDataType, grfKeyState);
}
//We should also analyze if the node being dragged over can accept the drop
if (!CanTargetNodeAcceptDrop(itemid))
pdwEffect = (uint)DropEffect.None;
return VSConstants.S_OK;
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:17,代码来源:ProjectNode.CopyPaste.cs
示例19: if
/// <summary>
/// Returns a dataobject from selected nodes
/// </summary>
/// <param name="cutHighlightItems">boolean that defines if the selected items must be cut</param>
/// <returns>data object for selected items</returns>
internal virtual DataObject PackageSelectionDataObject(bool cutHighlightItems)
{
this.CleanupSelectionDataObject(false, false, false);
StringBuilder sb = new StringBuilder();
DataObject dataObject = null;
try
{
IList<HierarchyNode> selectedNodes = this.GetSelectedNodes();
if (selectedNodes != null)
{
this.InstantiateItemsDraggedOrCutOrCopiedList();
StringBuilder selectionContent = null;
// If there is a selection package the data
if (selectedNodes.Count > 1)
{
foreach (HierarchyNode node in selectedNodes)
{
selectionContent = node.PrepareSelectedNodesForClipBoard();
if (selectionContent != null)
{
sb.Append(selectionContent);
}
}
}
else if (selectedNodes.Count == 1)
{
HierarchyNode selectedNode = selectedNodes[0];
selectionContent = selectedNode.PrepareSelectedNodesForClipBoard();
if (selectionContent != null)
{
sb.Append(selectionContent);
}
}
}
// Add the project items first.
IntPtr ptrToItems = this.PackageSelectionData(sb, false);
if (ptrToItems == IntPtr.Zero)
{
return null;
}
FORMATETC fmt = DragDropHelper.CreateFormatEtc(DragDropHelper.CF_VSSTGPROJECTITEMS);
dataObject = new DataObject();
dataObject.SetData(fmt, ptrToItems);
// Now add the project path that sourced data. We just write the project file path.
IntPtr ptrToProjectPath = this.PackageSelectionData(new StringBuilder(this.GetMkDocument()), true);
if (ptrToProjectPath != IntPtr.Zero)
{
dataObject.SetData(DragDropHelper.CreateFormatEtc(DragDropHelper.CF_VSPROJECTCLIPDESCRIPTOR), ptrToProjectPath);
}
if (cutHighlightItems)
{
bool first = true;
IVsUIHierarchyWindow w = UIHierarchyUtilities.GetUIHierarchyWindow(this.site, HierarchyNode.SolutionExplorer);
foreach (HierarchyNode node in this.ItemsDraggedOrCutOrCopied)
{
ErrorHandler.ThrowOnFailure(w.ExpandItem((IVsUIHierarchy)this, node.ID, first ? EXPANDFLAGS.EXPF_CutHighlightItem : EXPANDFLAGS.EXPF_AddCutHighlightItem));
first = false;
}
}
}
catch (COMException e)
{
Trace.WriteLine("Exception : " + e.Message);
dataObject = null;
}
return dataObject;
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:84,代码来源:ProjectNode.CopyPaste.cs
示例20: OleDataObject
/// <summary>
/// Determines whether the Toolbox user supports the referenced data object.
/// </summary>
/// <param name="pDO">Data object to be supported.</param>
/// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns>
int IVsToolboxUser.IsSupported(IOleDataObject pDO)
{
// Create a OleDataObject from the input interface.
OleDataObject oleData = new OleDataObject(pDO);
// Check if the data object is of type MyToolboxData.
if (oleData.GetDataPresent(typeof(ToolboxItemData)))
return VSConstants.S_OK;
// In all the other cases return S_FALSE
return VSConstants.S_FALSE;
}
开发者ID:Konctantin,项目名称:VS_SDK_samples,代码行数:17,代码来源:EditorPane.cs
注:本文中的Microsoft.VisualStudio.OLE.Interop.IDataObject类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论