当前位置: 首页>>代码示例>>C#>>正文


C# Control.DoDragDrop方法代码示例

本文整理汇总了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);
              }
        }
开发者ID:itadapter,项目名称:nfx,代码行数:16,代码来源:QRTestForm.cs

示例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;
 }
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:74,代码来源:ShellMethods.cs

示例3: CallControlDoDragDrop

		public static object CallControlDoDragDrop(Control c, object[] obj)
		{
			return c.DoDragDrop(obj[0], (DragDropEffects)obj[1]);
		}
开发者ID:HosokawaKenchi,项目名称:powersdr-if-stage,代码行数:4,代码来源:invoke.cs

示例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);
 }
开发者ID:havlenapetr,项目名称:HTMLRenderer,代码行数:14,代码来源:SelectionHandler.cs

示例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);
            }
        }
开发者ID:orryverducci,项目名称:SmoothTranscode,代码行数:26,代码来源:DragDropLib.cs

示例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);
     }
 }
开发者ID:h2suzuki,项目名称:HTMCLA_Exp1,代码行数:8,代码来源:Form1.cs

示例7: DoDragDrop

 public void DoDragDrop(Control control, object data, DragDropEffects allowedEffects)
 {
     control.DoDragDrop(data, allowedEffects);
 }
开发者ID:aggie0642,项目名称:SWEN-670,代码行数:4,代码来源:FormInteractionHelper.cs


注:本文中的System.Windows.Forms.Control.DoDragDrop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。