Example #1
0
        private DragEventArgs CreateDragEventArgs(object pDataObj, int grfKeyState, NativeMethods.POINTL pt, int pdwEffect)
        {
            IDataObject data = null;

            if (pDataObj == null)
            {
                data = lastDataObject;
            }
            else
            {
                if (pDataObj is IDataObject)
                {
                    data = (IDataObject)pDataObj;
                }
                else if (pDataObj is IComDataObject)
                {
                    data = new DataObject(pDataObj);
                }
                else
                {
                    return(null); // Unknown data object interface; we can't work with this so return null
                }
            }

            DragEventArgs drgevent = new DragEventArgs(data, grfKeyState, pt.x, pt.y, (DragDropEffects)pdwEffect, lastEffect);

            lastDataObject = data;
            return(drgevent);
        }
Example #2
0
        int UnsafeNativeMethods.IOleDropTarget.OleDragEnter(object pDataObj, int grfKeyState,
                                                            UnsafeNativeMethods.POINTSTRUCT pt,
                                                            ref int pdwEffect)
        {
            Debug.WriteLineIf(CompModSwitches.DragDrop.TraceInfo, "OleDragEnter recieved");
            NativeMethods.POINTL ptl = new NativeMethods.POINTL
            {
                x = pt.x,
                y = pt.y
            };
            Debug.WriteLineIf(CompModSwitches.DragDrop.TraceInfo, "\t" + (ptl.x) + "," + (ptl.y));
            Debug.Assert(pDataObj != null, "OleDragEnter didn't give us a valid data object.");
            DragEventArgs drgevent = CreateDragEventArgs(pDataObj, grfKeyState, ptl, pdwEffect);

            if (drgevent != null)
            {
                owner.OnDragEnter(drgevent);
                pdwEffect  = (int)drgevent.Effect;
                lastEffect = drgevent.Effect;
            }
            else
            {
                pdwEffect = (int)DragDropEffects.None;
            }
            return(NativeMethods.S_OK);
        }
        int UnsafeNativeMethods.IOleDropTarget.OleDragOver(int grfKeyState, long pt, ref int pdwEffect)
        {
            NativeMethods.POINTL pointl = new NativeMethods.POINTL {
                x = this.GetX(pt),
                y = this.GetY(pt)
            };
            DragEventArgs e = this.CreateDragEventArgs(null, grfKeyState, pointl, pdwEffect);

            this.owner.OnDragOver(e);
            pdwEffect       = (int)e.Effect;
            this.lastEffect = e.Effect;
            return(0);
        }
Example #4
0
        int UnsafeNativeMethods.IOleDropTarget.OleDragOver(int grfKeyState, UnsafeNativeMethods.POINTSTRUCT pt, ref int pdwEffect)
        {
            Debug.WriteLineIf(CompModSwitches.DragDrop.TraceInfo, "OleDragOver recieved");
            NativeMethods.POINTL ptl = new NativeMethods.POINTL();
            ptl.x = pt.x;
            ptl.y = pt.y;
            Debug.WriteLineIf(CompModSwitches.DragDrop.TraceInfo, "\t" + (ptl.x) + "," + (ptl.y));
            DragEventArgs drgevent = CreateDragEventArgs(null, grfKeyState, ptl, pdwEffect);

            owner.OnDragOver(drgevent);
            pdwEffect  = (int)drgevent.Effect;
            lastEffect = drgevent.Effect;
            return(NativeMethods.S_OK);
        }
        int UnsafeNativeMethods.IOleDropTarget.OleDragEnter(object pDataObj, int grfKeyState, long pt, ref int pdwEffect)
        {
            NativeMethods.POINTL pointl = new NativeMethods.POINTL {
                x = this.GetX(pt),
                y = this.GetY(pt)
            };
            DragEventArgs e = this.CreateDragEventArgs(pDataObj, grfKeyState, pointl, pdwEffect);

            if (e != null)
            {
                this.owner.OnDragEnter(e);
                pdwEffect       = (int)e.Effect;
                this.lastEffect = e.Effect;
            }
            else
            {
                pdwEffect = 0;
            }
            return(0);
        }
Example #6
0
        int UnsafeNativeMethods.IOleDropTarget.OleDrop(object pDataObj, int grfKeyState, UnsafeNativeMethods.POINTSTRUCT pt, ref int pdwEffect)
        {
            Debug.WriteLineIf(CompModSwitches.DragDrop.TraceInfo, "OleDrop recieved");
            NativeMethods.POINTL ptl = new NativeMethods.POINTL();
            ptl.x = pt.x;
            ptl.y = pt.y;
            Debug.WriteLineIf(CompModSwitches.DragDrop.TraceInfo, "\t" + (ptl.x) + "," + (ptl.y));
            DragEventArgs drgevent = CreateDragEventArgs(pDataObj, grfKeyState, ptl, pdwEffect);

            if (drgevent != null)
            {
                owner.OnDragDrop(drgevent);
                pdwEffect = (int)drgevent.Effect;
            }
            else
            {
                pdwEffect = (int)DragDropEffects.None;
            }

            lastEffect     = DragDropEffects.None;
            lastDataObject = null;
            return(NativeMethods.S_OK);
        }
        private DragEventArgs CreateDragEventArgs(object pDataObj, int grfKeyState, NativeMethods.POINTL pt, int pdwEffect)
        {
            System.Windows.Forms.IDataObject data = null;
            if (pDataObj == null)
            {
                data = this.lastDataObject;
            }
            else if (pDataObj is System.Windows.Forms.IDataObject)
            {
                data = (System.Windows.Forms.IDataObject)pDataObj;
            }
            else if (pDataObj is System.Runtime.InteropServices.ComTypes.IDataObject)
            {
                data = new DataObject(pDataObj);
            }
            else
            {
                return(null);
            }
            DragEventArgs args = new DragEventArgs(data, grfKeyState, pt.x, pt.y, (DragDropEffects)pdwEffect, this.lastEffect);

            this.lastDataObject = data;
            return(args);
        }