public DoDragDrop ( object data, DragDropEffects allowedEffects ) : DragDropEffects | ||
data | object | |
allowedEffects | DragDropEffects | |
return | DragDropEffects |
/// <summary> /// Performs a default drag and drop operation for the specified drag source. /// </summary> /// <param name="control">The drag source Control.</param> /// <param name="dataObject">The data object associated to the drag and drop operation.</param> /// <param name="allowedEffects">The allowed drop effects.</param> /// <param name="data">The associated data.</param> /// <returns>The accepted drop effects from the completed operation.</returns> private static DragDropEffects DoDragDropInternal(Control control, IDataObject dataObject, DragDropEffects allowedEffects, KeyValuePair <string, object>[] data) { // Set the data onto the data object. if (data != null) { foreach (KeyValuePair <string, object> dataPair in data) { dataObject.SetDataEx(dataPair.Key, dataPair.Value); } } try { return(control.DoDragDrop(dataObject, allowedEffects)); } finally { UnregisterDefaultDragSource(control); } }
private void DragImage(Control ctrl) { if (ctrl.BackgroundImage != null) { string tmpImageName = GetBmpFileTempName(); ctrl.BackgroundImage.Save(tmpImageName); StringCollection filePaths = new StringCollection(); filePaths.Add(tmpImageName); DataObject data = new DataObject(); data.SetFileDropList(filePaths); ctrl.DoDragDrop(data, DragDropEffects.Copy); } }
public static object CallControlDoDragDrop(Control c, object[] obj) { return c.DoDragDrop(obj[0], (DragDropEffects)obj[1]); }
public static DragDropEffects DoDragDrop(List<string> lstPaths, Control control, bool fSameDirecotry) { DragDropEffects none; if((lstPaths == null) || (lstPaths.Count == 0)) { return DragDropEffects.None; } IShellFolder ppv = null; object obj2 = null; List<IntPtr> list = new List<IntPtr>(); try { IntPtr[] ptrArray; if(fSameDirecotry) { IntPtr ptr2; IntPtr item = PInvoke.ILCreateFromPath(lstPaths[0]); list.Add(item); if((PInvoke.SHBindToParent(item, ExplorerGUIDs.IID_IShellFolder, out ppv, out ptr2) != 0) || (ppv == null)) { return DragDropEffects.None; } List<IntPtr> list2 = new List<IntPtr>(); if(ptr2 != IntPtr.Zero) { list2.Add(ptr2); } for(int i = 1; i < lstPaths.Count; i++) { IntPtr ptr3 = PInvoke.ILCreateFromPath(lstPaths[i]); if(ptr3 != IntPtr.Zero) { list.Add(ptr3); IntPtr ptr4 = PInvoke.ILFindLastID(ptr3); if(ptr4 != IntPtr.Zero) { list2.Add(ptr4); } } } if(list2.Count == 0) { return DragDropEffects.None; } ptrArray = list2.ToArray(); } else { foreach(string str in lstPaths) { IntPtr ptr5 = PInvoke.ILCreateFromPath(str); if(ptr5 != IntPtr.Zero) { list.Add(ptr5); } } PInvoke.SHGetDesktopFolder(out ppv); if((list.Count == 0) || (ppv == null)) { return DragDropEffects.None; } ptrArray = list.ToArray(); } uint rgfReserved = 0; Guid riid = ExplorerGUIDs.IID_IDataObject; ppv.GetUIObjectOf(IntPtr.Zero, (uint)ptrArray.Length, ptrArray, ref riid, ref rgfReserved, out obj2); if(obj2 != null) { return control.DoDragDrop(obj2, DragDropEffects.Link | DragDropEffects.Move | DragDropEffects.Copy); } none = DragDropEffects.None; } finally { if(obj2 != null) { Marshal.ReleaseComObject(obj2); obj2 = null; } if(ppv != null) { Marshal.ReleaseComObject(ppv); ppv = null; } foreach(IntPtr ptr6 in list) { if(ptr6 != IntPtr.Zero) { PInvoke.CoTaskMemFree(ptr6); } } } return none; }
public static DragDropEffects DoDragDrop(string path, Control control) { DragDropEffects none; if((path == null) || (path.Length == 0)) { return DragDropEffects.None; } IShellFolder ppv = null; object obj2 = null; IntPtr zero = IntPtr.Zero; try { IntPtr ptr2; zero = PInvoke.ILCreateFromPath(path); if(((zero == IntPtr.Zero) || (PInvoke.SHBindToParent(zero, ExplorerGUIDs.IID_IShellFolder, out ppv, out ptr2) != 0)) || (ppv == null)) { return DragDropEffects.None; } IntPtr[] apidl = new IntPtr[] { ptr2 }; uint rgfReserved = 0; Guid riid = ExplorerGUIDs.IID_IDataObject; ppv.GetUIObjectOf(IntPtr.Zero, (uint)apidl.Length, apidl, ref riid, ref rgfReserved, out obj2); if(obj2 != null) { return control.DoDragDrop(obj2, DragDropEffects.Link | DragDropEffects.Move | DragDropEffects.Copy); } none = DragDropEffects.None; } finally { if(obj2 != null) { Marshal.ReleaseComObject(obj2); obj2 = null; } if(ppv != null) { Marshal.ReleaseComObject(ppv); ppv = null; } if(zero != IntPtr.Zero) { PInvoke.CoTaskMemFree(zero); } } return none; }
public static object CallControlDoDragDrop(Control c, object[] obj) { return(c.DoDragDrop(obj[0], (DragDropEffects)obj[1])); }
/// <summary> /// Start drag & drop operation on the currently selected html segment. /// </summary> /// <param name="control">the control to start the drag & drop on</param> private void StartDragDrop(Control control) { if (_dragDropData == null) { var html = DomUtils.GenerateHtml(_root, HtmlGenerationStyle.Inline, true); var plainText = DomUtils.GetSelectedPlainText(_root); _dragDropData = HtmlClipboardUtils.GetDataObject(html, plainText); } control.DoDragDrop(_dragDropData, DragDropEffects.Copy); }
/// <summary> /// Performs a default drag and drop operation for the specified drag source. /// </summary> /// <param name="control">The drag source Control.</param> /// <param name="dataObject">The data object associated to the drag and drop operation.</param> /// <param name="allowedEffects">The allowed drop effects.</param> /// <param name="data">The associated data.</param> /// <returns>The accepted drop effects from the completed operation.</returns> private static DragDropEffects DoDragDropInternal(Control control, IDataObject dataObject, DragDropEffects allowedEffects, KeyValuePair<string, object>[] data) { // Set the data onto the data object. if (data != null) { foreach (KeyValuePair<string, object> dataPair in data) dataObject.SetDataEx(dataPair.Key, dataPair.Value); } try { return control.DoDragDrop(dataObject, allowedEffects); } finally { UnregisterDefaultDragSource(control); } }
private void transferImage(Control owner, Control image) { using (var bitmap = new Bitmap(image.Width, image.Height)) { image.DrawToBitmap(bitmap, new Rectangle(0, 0, image.Width, image.Height)); owner.DoDragDrop(bitmap, DragDropEffects.Copy); } }
public void DoDragDrop(Control control, object data, DragDropEffects allowedEffects) { control.DoDragDrop(data, allowedEffects); }