本文整理汇总了C#中DropDataType类的典型用法代码示例。如果您正苦于以下问题:C# DropDataType类的具体用法?C# DropDataType怎么用?C# DropDataType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DropDataType类属于命名空间,在下文中一共展示了DropDataType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例5: 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;
}
示例6: CleanupSelectionDataObject
/// <summary>
/// After a drop or paste, will use the dwEffects
/// to determine whether we need to clean up the source nodes or not. If
/// justCleanup is set, it only does the cleanup work.
/// </summary>
internal void CleanupSelectionDataObject(bool dropped, bool cut, bool moved, bool justCleanup)
{
if (this.ItemsDraggedOrCutOrCopied == null || this.ItemsDraggedOrCutOrCopied.Count == 0)
{
return;
}
// If the source and destination are within the same project, the
// number of items dropped and selected should be equal.
Debug.Assert(!this.SourceDraggedOrCutOrCopied ||
(dropItems == null || dropItems.Count == 0 || (dropItems.Count > 0 && dropItems.Count == this.ItemsDraggedOrCutOrCopied.Count)),
"Number of drop items didn't match number of items selected.");
try
{
int index = -1;
IVsUIHierarchyWindow w = UIHierarchyUtilities.GetUIHierarchyWindow(this.site, HierarchyNode.SolutionExplorer);
foreach (HierarchyNode node in this.ItemsDraggedOrCutOrCopied)
{
index++;
bool shouldRemove = ((moved && dropped) || cut) && !justCleanup;
// get matching drop item
// there might not be any drop items if an error occured early on
if (dropItems != null && dropItems.Count > 0)
{
DragDropItem dropItem = dropItems[index];
if (dropItem.userCancelled)
shouldRemove = false;
}
if (shouldRemove)
{
// do not close it if the doc is dirty or we do not own it
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 || (isOpen && !isOpenedByUs))
{
continue;
}
// close it if opened
if (isOpen)
{
manager.Close(__FRAMECLOSE.FRAMECLOSE_NoSave);
}
}
node.Remove(true);
}
else if (w != null)
{
w.ExpandItem((IVsUIHierarchy)this, node.ID, EXPANDFLAGS.EXPF_UnCutHighlightItem);
}
}
}
finally
{
try
{
// Now delete the memory allocated by the packaging of datasources.
// If we just did a cut, or we are told to cleanup, then we need to free the data object. Otherwise, we leave it
// alone so that you can continue to paste the data in new locations.
if (moved || cut || justCleanup)
{
this.ItemsDraggedOrCutOrCopied.Clear();
this.CleanAndFlushClipboard();
}
}
finally
{
this.dropItems.Clear();
this.dropDataType = DropDataType.None;
}
}
}
示例7: QueryDropEffect
/// <summary>
/// Returns the drop effect.
/// </summary>
/// <remarks>
/// // A directory based project should perform as follow:
/// NO MODIFIER
/// - COPY if not from current hierarchy,
/// - MOVE if from current hierarchy
/// SHIFT DRAG - MOVE
/// CTRL DRAG - COPY
/// CTRL-SHIFT DRAG - NO DROP (used for reference based projects only)
/// </remarks>
internal DropEffect QueryDropEffect(DropDataType dropDataType, uint grfKeyState)
{
//Validate the dropdatatype
if ((dropDataType != DropDataType.Shell) && (dropDataType != DropDataType.VsRef) && (dropDataType != DropDataType.VsStg))
{
return DropEffect.None;
}
// CTRL-SHIFT
if ((grfKeyState & NativeMethods.MK_CONTROL) != 0 && (grfKeyState & NativeMethods.MK_SHIFT) != 0)
{
// Because we are not referenced base, we don't support link
return DropEffect.None;
}
// CTRL
if ((grfKeyState & NativeMethods.MK_CONTROL) != 0)
return DropEffect.Copy;
// SHIFT
if ((grfKeyState & NativeMethods.MK_SHIFT) != 0)
return DropEffect.Move;
// If the source project is this project, default to move items,
// otherwise copy items.
if (this.SourceDraggedOrCutOrCopied)
return DropEffect.Move;
else
return DropEffect.Copy;
}
示例8: CleanupSelectionDataObject
/// <summary>
/// After a drop or paste, will use the dwEffects
/// to determine whether we need to clean up the source nodes or not. If
/// justCleanup is set, it only does the cleanup work.
/// </summary>
public void CleanupSelectionDataObject(bool dropped, bool cut, bool moved, bool justCleanup)
{
if (this.ItemsDraggedOrCutOrCopied == null || this.ItemsDraggedOrCutOrCopied.Count == 0)
{
return;
}
try
{
IVsUIHierarchyWindow w = UIHierarchyUtilities.GetUIHierarchyWindow(this.site, HierarchyNode.SolutionExplorer);
foreach (HierarchyNode node in this.ItemsDraggedOrCutOrCopied)
{
if ((moved && (cut || dropped) && !justCleanup))
{
// do not close it if the doc is dirty or we do not own it
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 || (isOpen && !isOpenedByUs))
{
continue;
}
// close it if opened
if (isOpen)
{
manager.Close(__FRAMECLOSE.FRAMECLOSE_NoSave);
}
}
node.Remove(true);
}
else if (w != null)
{
ErrorHandler.ThrowOnFailure(w.ExpandItem((IVsUIHierarchy)this, node.ID, EXPANDFLAGS.EXPF_UnCutHighlightItem));
}
}
}
finally
{
try
{
// Now delete the memory allocated by the packaging of datasources.
// If we just did a cut, or we are told to cleanup, then we need to free the data object. Otherwise, we leave it
// alone so that you can continue to paste the data in new locations.
if (moved || cut || justCleanup)
{
this.ItemsDraggedOrCutOrCopied.Clear();
this.CleanAndFlushClipboard();
}
}
finally
{
this.dropDataType = DropDataType.None;
}
}
}
示例9: QueryDropEffect
/// <summary>
/// Returns the drop effect.
/// </summary>
/// <remarks>
/// // A directory based project should perform as follow:
/// NO MODIFIER
/// - COPY if not from current hierarchy,
/// - MOVE if from current hierarchy
/// SHIFT DRAG - MOVE
/// CTRL DRAG - COPY
/// CTRL-SHIFT DRAG - NO DROP (used for reference based projects only)
/// </remarks>
internal DropEffect QueryDropEffect(DropDataType dropDataType, uint grfKeyState)
{
//Validate the dropdatatype
if ((dropDataType != DropDataType.Shell) && (dropDataType != DropDataType.VsRef) && (dropDataType != DropDataType.VsStg))
{
return DropEffect.None;
}
// CTRL-SHIFT
if ((grfKeyState & NativeMethods.MK_CONTROL) != 0 && (grfKeyState & NativeMethods.MK_SHIFT) != 0)
{
// Because we are not referenced base, we don't support link
return DropEffect.None;
}
// CTRL
if ((grfKeyState & NativeMethods.MK_CONTROL) != 0)
return DropEffect.Copy;
// SHIFT
if ((grfKeyState & NativeMethods.MK_SHIFT) != 0)
return DropEffect.Move;
// no modifier
if (this.SourceDraggedOrCutOrCopied)
{
return DropEffect.Move;
}
else
{
return DropEffect.Copy;
}
}
示例10: DragLeave
/// <include file='doc\Hierarchy.uex' path='docs/doc[@for="HierarchyNode.DragLeave"]/*' />
public virtual int DragLeave() {
_ddt = DropDataType.None;
return NativeMethods.S_OK;
}
示例11: PasteFromClipboardCore
/// <summary>
/// Handle the Paste operation to a targetNode. Do not call directly
/// outside of PasteFromClipboard.
/// </summary>
private int PasteFromClipboardCore(HierarchyNode targetNode)
{
int returnValue = (int)OleConstants.OLECMDERR_E_NOTSUPPORTED;
//Get the clipboardhelper service and use it after processing dataobject
IVsUIHierWinClipboardHelper clipboardHelper = (IVsUIHierWinClipboardHelper)GetService(typeof(SVsUIHierWinClipboardHelper));
if (clipboardHelper == null)
{
return VSConstants.E_FAIL;
}
try
{
//Get dataobject from clipboard
IOleDataObject dataObject = null;
ErrorHandler.ThrowOnFailure(UnsafeNativeMethods.OleGetClipboard(out dataObject));
if (dataObject == null)
{
return VSConstants.E_UNEXPECTED;
}
DropEffect dropEffect = DropEffect.None;
DropDataType dropDataType = DropDataType.None;
try
{
this.SourceDraggedOrCutOrCopied = this.dataWasCut;
dropDataType = this.ProcessSelectionDataObject(dataObject, targetNode.GetDragTargetHandlerNode(), 0);
dropEffect = this.QueryDropEffect(dropDataType, 0);
}
catch (ExternalException e)
{
Trace.WriteLine("Exception : " + e.Message);
// If it is a drop from windows and we get any kind of error ignore it. This
// prevents bogus messages from the shell from being displayed
if (dropDataType != DropDataType.Shell)
{
throw e;
}
}
finally
{
// Inform VS (UiHierarchyWindow) of the paste
returnValue = clipboardHelper.Paste(dataObject, (uint)dropEffect);
}
}
catch (COMException e)
{
Trace.WriteLine("Exception : " + e.Message);
returnValue = e.ErrorCode;
}
return returnValue;
}
示例12: QueryDropEffect
DropEffect QueryDropEffect(DropDataType ddt, uint grfKeyState){
// We are reference-based project so we should perform as follow:
// for shell and physical items:
// NO MODIFIER - LINK
// SHIFT DRAG - NO DROP
// CTRL DRAG - NO DROP
// CTRL-SHIFT DRAG - LINK
// for reference/link items
// NO MODIFIER - MOVE
// SHIFT DRAG - MOVE
// CTRL DRAG - COPY
// CTRL-SHIFT DRAG - LINK
if ((ddt != DropDataType.Shell) && (ddt != DropDataType.VsRef) && (ddt != DropDataType.VsStg))
return DropEffect.None;
switch (ddt){
case DropDataType.Shell: goto case DropDataType.VsStg;
case DropDataType.VsStg:
// CTRL-SHIFT
if ((grfKeyState & MK_CONTROL) != 0 && (grfKeyState & MK_SHIFT) != 0){
return DropEffect.Link;
}
// CTRL
if ((grfKeyState & MK_CONTROL) != 0)
return DropEffect.None;
// SHIFT
if ((grfKeyState & MK_SHIFT) != 0)
return DropEffect.None;
// no modifier
return DropEffect.Link;
case DropDataType.VsRef:
// CTRL-SHIFT
if ((grfKeyState & MK_CONTROL) != 0 && (grfKeyState & MK_SHIFT) != 0){
return DropEffect.Link;
}
// CTRL
if ((grfKeyState & MK_CONTROL) != 0){
return DropEffect.Copy;
}
// SHIFT
if ((grfKeyState & MK_SHIFT) != 0){
return DropEffect.Move;
}
// no modifier
return DropEffect.Move;
}
return DropEffect.None;
}
示例13: DragEnter
/// <include file='doc\Hierarchy.uex' path='docs/doc[@for="HierarchyNode.DragEnter"]/*' />
public virtual int DragEnter(Microsoft.VisualStudio.OLE.Interop.IDataObject pDataObject, uint grfKeyState, uint itemid, ref uint pdwEffect){
pdwEffect = (uint)DropEffect.None;
if (dragSource)
return 0;
_ddt = QueryDropDataType(pDataObject);
if (_ddt != DropDataType.None){
pdwEffect = (uint)QueryDropEffect(_ddt, grfKeyState);
}
return 0;
}
示例14: ProcessSelectionDataObject
// ================= Drag/Drop/Cut/Copy/Paste ========================
// Ported from HeirUtil7\PrjHeir.cpp
void ProcessSelectionDataObject(Microsoft.VisualStudio.OLE.Interop.IDataObject pDataObject, uint grfKeyState, out DropDataType pddt){
pddt = DropDataType.None;
// try HDROP
FORMATETC fmtetc = DragDropHelper.CreateFormatEtc(CF_HDROP);
bool hasData = false;
try{
DragDropHelper.QueryGetData(pDataObject, ref fmtetc);
hasData = true;
} catch (Exception){
}
if (hasData){
try{
STGMEDIUM stgmedium = DragDropHelper.GetData(pDataObject, ref fmtetc);
if (stgmedium.tymed == (uint)TYMED.TYMED_HGLOBAL){
IntPtr hDropInfo = stgmedium.unionmember;
if (hDropInfo != IntPtr.Zero){
pddt = DropDataType.Shell;
try{
uint numFiles = DragQueryFile(hDropInfo, 0xFFFFFFFF, null, 0);
char[] szMoniker = new char[MAX_PATH + 1];
IVsProject vsProj = (IVsProject)this.projectMgr;
for (uint iFile = 0; iFile < numFiles; iFile++){
uint len = DragQueryFile(hDropInfo, iFile, szMoniker, MAX_PATH);
string filename = new String(szMoniker, 0, (int)len);
// Is full path returned
if (File.Exists(filename)){
VSADDRESULT[] vsaddresult = new VSADDRESULT[1];
vsaddresult[0] = VSADDRESULT.ADDRESULT_Failure;
string[] files = new String[1]{ filename };
// TODO: support dropping into subfolders...
vsProj.AddItem(this.projectMgr.hierarchyId, VSADDITEMOPERATION.VSADDITEMOP_OPENFILE, null, 1, files, IntPtr.Zero, vsaddresult);
}
}
Marshal.FreeHGlobal(hDropInfo);
} catch (Exception e){
Marshal.FreeHGlobal(hDropInfo);
throw e;
}
}
}
return;
} catch (Exception){
hasData = false;
}
}
if (DragDropHelper.AttemptVsFormat(this, DragDropHelper.CF_VSREFPROJECTITEMS, pDataObject, grfKeyState, out pddt))
return;
if (DragDropHelper.AttemptVsFormat(this, DragDropHelper.CF_VSSTGPROJECTITEMS, pDataObject, grfKeyState, out pddt))
return;
}
示例15: DragLeave
/// <include file='doc\Hierarchy.uex' path='docs/doc[@for="HierarchyNode.DragLeave"]/*' />
public virtual int DragLeave(){
_ddt = DropDataType.None;
return 0;
}