コード例 #1
0
ファイル: DropDescriptionHelper.cs プロジェクト: zparr/ATF
        /// <summary>
        /// Gets a drop description flag.
        /// </summary>
        private static DropDescriptionFlags GetDropDescriptionFlag(IComDataObject dataObject)
        {
            int flag;

            if (dataObject.TryGetData("DropDescriptionFlags", out flag))
            {
                return((DropDescriptionFlags)flag);
            }
            return(DropDescriptionFlags.None);
        }
コード例 #2
0
        /// <summary>
        /// Gets a drop description.
        /// </summary>
        public static object GetDropDescription(IComDataObject dataObject)
        {
            DropDescription desc;

            if (dataObject.TryGetData("DropDescription", out desc))
            {
                return(desc);
            }
            return(null);
        }
コード例 #3
0
ファイル: DropDescriptionHelper.cs プロジェクト: zparr/ATF
        // The drag image manager sets this flag to indicate if the current
        // drop target supports drag images.
        private static bool IsShowingLayered(IComDataObject dataObject)
        {
            int value;

            if (dataObject.TryGetData("IsShowingLayered", out value))
            {
                return(value != 0);
            }
            return(false);
        }
コード例 #4
0
ファイル: DropDescriptionHelper.cs プロジェクト: zparr/ATF
        /// <summary>
        /// Gets a drop description.
        /// </summary>
        public static object GetDropDescription(IComDataObject dataObject)
        {
            // CFSTR_DROPDESCRIPTION
            DropDescription desc;

            if (dataObject.TryGetData("DropDescription", out desc))
            {
                return(desc);
            }
            return(null);
        }
コード例 #5
0
ファイル: DropDescriptionHelper.cs プロジェクト: zparr/ATF
        /// <summary>
        /// Default feedback handler.
        /// </summary>
        public static void DefaultGiveFeedback(IComDataObject data, GiveFeedbackEventArgs e)
        {
            // For drop targets that don't set the drop description, we'll
            // set a default one. Drop targets that do set drop descriptions
            // should set an invalid drop description during DragLeave.
            var setDefaultDropDesc = false;
            var isDefaultDropDesc  = IsDropDescriptionDefault(data);
            var currentType        = DropImageType.Invalid;

            if (!IsDropDescriptionValid(data) || isDefaultDropDesc)
            {
                currentType        = GetDropImageType(data);
                setDefaultDropDesc = true;
            }

            if (IsShowingLayered(data))
            {
                // The default drag source implementation uses drop descriptions,
                // so we won't use default cursors.
                e.UseDefaultCursors = false;
                Cursor.Current      = Cursors.Default;
            }
            else
            {
                e.UseDefaultCursors = true;
            }

            // We need to invalidate the drag image to refresh the drop description.
            // This is tricky to implement correctly, but we try to mimic the Windows
            // Explorer behavior. We internally use a flag to tell us to invalidate
            // the drag image, so if that is set, we'll invalidate. Otherwise, we
            // always invalidate if the drop description was set by the drop target,
            // *or* if the current drop image is not None. So if we set a default
            // drop description to anything but None, we'll always invalidate.
            if (InvalidateRequired(data) || !isDefaultDropDesc || currentType != DropImageType.None)
            {
                IntPtr hwnd;
                if (data.TryGetData("DragWindow", out hwnd))
                {
                    const uint WM_INVALIDATEDRAGIMAGE = 0x403;
                    PostMessage(hwnd, WM_INVALIDATEDRAGIMAGE, IntPtr.Zero, IntPtr.Zero);
                }

                // The invalidate required flag only lasts for one invalidation
                SetInvalidateRequired(data, false);
            }

            // If the drop description is currently invalid, or if it is a default
            // drop description already, we should check about re-setting it.
            if (setDefaultDropDesc && (DropImageType)e.Effect != currentType)
            {
                if (e.Effect != DragDropEffects.None)
                {
                    SetDropDescription(data, (DropImageType)e.Effect, e.Effect.ToString(), null);
                }
                else
                {
                    SetDropDescription(data, (DropImageType)e.Effect, e.Effect.ToString(), null);
                }

                SetDropDescriptionIsDefault(data, true);

                // We can't invalidate now, because the drag image manager won't
                // pick it up... so we set this flag to invalidate on the next
                // GiveFeedback event.
                SetInvalidateRequired(data, true);
            }
        }
コード例 #6
0
ファイル: DropDescriptionHelper.cs プロジェクト: sbambach/ATF
 /// <summary>
 /// Gets a drop description flag.
 /// </summary>
 private static DropDescriptionFlags GetDropDescriptionFlag(IComDataObject dataObject)
 {
     int flag;
     if (dataObject.TryGetData("DropDescriptionFlags", out flag))
     {
         return (DropDescriptionFlags)flag;
     }
     return DropDescriptionFlags.None;
 }
コード例 #7
0
ファイル: DropDescriptionHelper.cs プロジェクト: sbambach/ATF
 // The drag image manager sets this flag to indicate if the current
 // drop target supports drag images.
 private static bool IsShowingLayered(IComDataObject dataObject)
 {
     int value;
     if (dataObject.TryGetData("IsShowingLayered", out value))
     {
         return (value != 0);
     }
     return false;
 }
コード例 #8
0
ファイル: DropDescriptionHelper.cs プロジェクト: sbambach/ATF
        /// <summary>
        /// Default feedback handler.
        /// </summary>
        public static void DefaultGiveFeedback(IComDataObject data, GiveFeedbackEventArgs e)
        {
            // For drop targets that don't set the drop description, we'll
            // set a default one. Drop targets that do set drop descriptions
            // should set an invalid drop description during DragLeave.
            var setDefaultDropDesc = false;
            var isDefaultDropDesc = IsDropDescriptionDefault(data);
            var currentType = DropImageType.Invalid;
            if (!IsDropDescriptionValid(data) || isDefaultDropDesc)
            {
                currentType = GetDropImageType(data);
                setDefaultDropDesc = true;
            }

            if (IsShowingLayered(data))
            {
                // The default drag source implementation uses drop descriptions,
                // so we won't use default cursors.
                e.UseDefaultCursors = false;
                Cursor.Current = Cursors.Default;
            }
            else
            {
                e.UseDefaultCursors = true;
            }

            // We need to invalidate the drag image to refresh the drop description.
            // This is tricky to implement correctly, but we try to mimic the Windows
            // Explorer behavior. We internally use a flag to tell us to invalidate
            // the drag image, so if that is set, we'll invalidate. Otherwise, we
            // always invalidate if the drop description was set by the drop target,
            // *or* if the current drop image is not None. So if we set a default
            // drop description to anything but None, we'll always invalidate.
            if (InvalidateRequired(data) || !isDefaultDropDesc || currentType != DropImageType.None)
            {
                IntPtr hwnd;
                if (data.TryGetData("DragWindow", out hwnd))
                {
                    const uint WM_INVALIDATEDRAGIMAGE = 0x403;
                    User32.PostMessage(hwnd, WM_INVALIDATEDRAGIMAGE, IntPtr.Zero, IntPtr.Zero);
                }

                // The invalidate required flag only lasts for one invalidation
                SetInvalidateRequired(data, false);
            }

            // If the drop description is currently invalid, or if it is a default
            // drop description already, we should check about re-setting it.
            if (setDefaultDropDesc && (DropImageType)e.Effect != currentType)
            {
                if (e.Effect != DragDropEffects.None)
                {
                    SetDropDescription(data, (DropImageType)e.Effect, e.Effect.ToString(), null);
                }
                else
                {
                    SetDropDescription(data, (DropImageType)e.Effect, e.Effect.ToString(), null);
                }

                SetDropDescriptionIsDefault(data, true);

                // We can't invalidate now, because the drag image manager won't
                // pick it up... so we set this flag to invalidate on the next
                // GiveFeedback event.
                SetInvalidateRequired(data, true);
            }
        }
コード例 #9
0
ファイル: DropDescriptionHelper.cs プロジェクト: sbambach/ATF
 /// <summary>
 /// Gets a drop description.
 /// </summary>
 public static object GetDropDescription(IComDataObject dataObject)
 {
     DropDescription desc;
     if (dataObject.TryGetData("DropDescription", out desc))
     {
         return desc;
     }
     return null;
 }
コード例 #10
0
 /// <summary>
 /// Gets a drop description.
 /// </summary>
 public static object GetDropDescription(IComDataObject dataObject)
 {
     // CFSTR_DROPDESCRIPTION
     DropDescription desc;
     if (dataObject.TryGetData("DropDescription", out desc))
     {
         return desc;
     }
     return null;
 }