コード例 #1
0
        /// <summary>
        /// Unregisters a drag source from the internal cache.
        /// </summary>
        /// <param name="control">The drag source Control.</param>
        public static void UnregisterDefaultDragSource(Control control)
        {
            if (s_dataContext.ContainsKey(control))
            {
                DragSourceEntry entry         = s_dataContext[control];
                var             dataObjectCOM = (System.Runtime.InteropServices.ComTypes.IDataObject)entry.data;

                // Stop listening to drop description changes
                dataObjectCOM.DUnadvise(entry.adviseConnection);

                // Unhook the default drag source event handlers
                control.GiveFeedback      -= DefaultGiveFeedbackHandler;
                control.QueryContinueDrag -= DefaultQueryContinueDragHandler;

                // Remove the entries from our context caches
                s_dataContext.Remove(control);
                s_dropDescriptions.Remove(entry.data);
            }
        }
コード例 #2
0
        /// <summary>
        /// Registers a Control as a drag source and provides default implementations of
        /// GiveFeedback and QueryContinueDrag.
        /// </summary>
        /// <param name="dragSource">The drag source UIElement instance.</param>
        /// <param name="data">The DataObject associated to the drag source.</param>
        /// <remarks>Callers must call UnregisterDefaultDragSource when the drag and drop
        /// operation is complete to avoid memory leaks.</remarks>
        public static void RegisterDefaultDragSource(UIElement dragSource, IDataObject data)
        {
            // Cache the drag source and the associated data object
            var entry = new DragSourceEntry(data);

            if (!s_dataContext.ContainsKey(dragSource))
            {
                s_dataContext.Add(dragSource, entry);
            }
            else
            {
                s_dataContext[dragSource] = entry;
            }

            // We need to listen for drop description changes. If a drop target
            // changes the drop description, we shouldn't provide a default one.
            entry.adviseConnection = ((System.Runtime.InteropServices.ComTypes.IDataObject)data).Advise(new AdviseSink(data), DropDescriptionFormat, 0);

            // Hook up the default drag source event handlers
            dragSource.GiveFeedback      += DefaultGiveFeedbackHandler;
            dragSource.QueryContinueDrag += DefaultQueryContinueDragHandler;
        }
コード例 #3
0
        /// <summary>
        /// Registers a Control as a drag source and provides default implementations of
        /// GiveFeedback and QueryContinueDrag.
        /// </summary>
        /// <param name="control">The drag source Control instance.</param>
        /// <param name="data">The DataObject associated to the drag source.</param>
        /// <remarks>Callers must call UnregisterDefaultDragSource when the drag and drop
        /// operation is complete to avoid memory leaks.</remarks>
        public static void RegisterDefaultDragSource(Control control, IDataObject data)
        {
            // Cache the drag source and the associated data object
            DragSourceEntry entry = new DragSourceEntry(data);

            if (!s_dataContext.ContainsKey(control))
            {
                s_dataContext.Add(control, entry);
            }
            else
            {
                s_dataContext[control] = entry;
            }

            // We need to listen for drop description changes. If a drop target
            // changes the drop description, we shouldn't provide a default one.
            entry.adviseConnection = ComTypes.ComDataObjectExtensions.Advise(((ComTypes.IDataObject)data), new AdviseSink(data), DropDescriptionFormat, 0);

            // Hook up the default drag source event handlers
            control.GiveFeedback      += new GiveFeedbackEventHandler(DefaultGiveFeedbackHandler);
            control.QueryContinueDrag += new QueryContinueDragEventHandler(DefaultQueryContinueDragHandler);
        }
コード例 #4
0
ファイル: DragDropLib.cs プロジェクト: applejian/cyberduck
        /// <summary>
        /// Registers a Control as a drag source and provides default implementations of
        /// GiveFeedback and QueryContinueDrag.
        /// </summary>
        /// <param name="control">The drag source Control instance.</param>
        /// <param name="data">The DataObject associated to the drag source.</param>
        /// <remarks>Callers must call UnregisterDefaultDragSource when the drag and drop
        /// operation is complete to avoid memory leaks.</remarks>
        public static void RegisterDefaultDragSource(Control control, IDataObject data)
        {
            // Cache the drag source and the associated data object
            DragSourceEntry entry = new DragSourceEntry(data);
            if (!s_dataContext.ContainsKey(control))
                s_dataContext.Add(control, entry);
            else
                s_dataContext[control] = entry;

            // We need to listen for drop description changes. If a drop target
            // changes the drop description, we shouldn't provide a default one.
            entry.adviseConnection =
                ComDataObjectExtensions.Advise(((Runtime.InteropServices.ComTypes.IDataObject) data),
                                               new AdviseSink(data), DropDescriptionFormat, 0);

            // Hook up the default drag source event handlers
            control.GiveFeedback += DefaultGiveFeedbackHandler;
            control.QueryContinueDrag += DefaultQueryContinueDragHandler;
        }
コード例 #5
0
        /// <summary>
        /// Registers a Control as a drag source and provides default implementations of
        /// GiveFeedback and QueryContinueDrag.
        /// </summary>
        /// <param name="dragSource">The drag source UIElement instance.</param>
        /// <param name="data">The DataObject associated to the drag source.</param>
        /// <remarks>Callers must call UnregisterDefaultDragSource when the drag and drop
        /// operation is complete to avoid memory leaks.</remarks>
        public static void RegisterDefaultDragSource(UIElement dragSource, IDataObject data)
        {
            // Cache the drag source and the associated data object
            DragSourceEntry entry = new DragSourceEntry(data);
            if (!s_dataContext.ContainsKey(dragSource))
                s_dataContext.Add(dragSource, entry);
            else
                s_dataContext[dragSource] = entry;

            // We need to listen for drop description changes. If a drop target
            // changes the drop description, we shouldn't provide a default one.
            entry.adviseConnection = ComTypes.ComDataObjectExtensions.Advise(((ComTypes.IDataObject)data), new AdviseSink(data), DropDescriptionFormat, 0);

            // Hook up the default drag source event handlers
            dragSource.GiveFeedback += new GiveFeedbackEventHandler(DefaultGiveFeedbackHandler);
            dragSource.QueryContinueDrag += new QueryContinueDragEventHandler(DefaultQueryContinueDragHandler);
        }