本文整理汇总了C#中System.Windows.Forms.Control.DoDragDrop方法的典型用法代码示例。如果您正苦于以下问题:C# Control.DoDragDrop方法的具体用法?C# Control.DoDragDrop怎么用?C# Control.DoDragDrop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Control
的用法示例。
在下文中一共展示了Control.DoDragDrop方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DragImage
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);
}
}
示例2: DoDragDrop
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;
}
示例3: CallControlDoDragDrop
public static object CallControlDoDragDrop(Control c, object[] obj)
{
return c.DoDragDrop(obj[0], (DragDropEffects)obj[1]);
}
示例4: StartDragDrop
/// <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);
}
示例5: DoDragDropInternal
/// <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);
}
}
示例6: transferImage
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);
}
}
示例7: DoDragDrop
public void DoDragDrop(Control control, object data, DragDropEffects allowedEffects)
{
control.DoDragDrop(data, allowedEffects);
}