Example #1
0
        internal static bool HandleEvent(IntPtr callref, IntPtr eventref, IntPtr handle, uint kind, ref MSG msg)
        {
            Control         control;
            DataObject      data;
            DragEventArgs   drag_event;
            DragDropEffects allowed;
            QDPoint         point   = new QDPoint();
            UInt32          actions = 0;
            IntPtr          dragref = IntPtr.Zero;
            Hwnd            hwnd    = Hwnd.ObjectFromHandle(handle);

            if (hwnd == null || hwnd.Handle != handle)
            {
                return(false);
            }

            GetEventParameter(eventref, kEventParamDragRef, typeDragRef, IntPtr.Zero, (uint)Marshal.SizeOf(typeof(IntPtr)), IntPtr.Zero, ref dragref);
            XplatUICarbon.GetGlobalMouse(ref point);
            GetDragAllowableActions(dragref, ref actions);
            control    = Control.FromHandle(hwnd.Handle);
            allowed    = DragActionsToEffects(actions);
            data       = DragToDataObject(dragref);
            drag_event = new DragEventArgs(data, 0, point.x, point.y, allowed, DragDropEffects.None);

            switch (kind)
            {
            case ControlHandler.kEventControlDragEnter:
            {
                bool accept = control.AllowDrop;
                SetEventParameter(eventref, ControlHandler.kEventParamControlLikesDrag, ControlHandler.typeBoolean, (uint)Marshal.SizeOf(typeof(bool)), ref accept);

                control.DndEnter(drag_event);
                effects = drag_event.Effect;
                return(false);
            }

            case ControlHandler.kEventControlDragWithin:
                control.DndOver(drag_event);
                effects = drag_event.Effect;
                break;

            case ControlHandler.kEventControlDragLeave:
                control.DndLeave(drag_event);
                break;

            case ControlHandler.kEventControlDragReceive:
                control.DndDrop(drag_event);
                break;
            }
            return(true);
        }
Example #2
0
        public DragDropEffects StartDrag(IntPtr handle, object data, DragDropEffects allowed_effects)
        {
            IntPtr      dragref     = IntPtr.Zero;
            EventRecord eventrecord = new EventRecord();

            effects = DragDropEffects.None;

            NewDrag(ref dragref);
            XplatUICarbon.GetGlobalMouse(ref eventrecord.mouse);
            StoreObjectInDrag(handle, dragref, data);

            TrackDrag(dragref, ref eventrecord, IntPtr.Zero);

            DisposeDrag(dragref);

            return(effects);
        }