예제 #1
0
		/// <summary>
		/// Gets a list of  <see cref="IGalleryItem"/>s from the given <see cref="IDragDropObject">data wrapper</see>.
		/// </summary>
		/// <param name="dataObject">The data wrapper object.</param>
		/// <returns>A <see cref="IList{T}"/> of <see cref="IGalleryItem"/>s, or null if the wrapper did not contain a list of 0 or more IGalleryItems.</returns>
		protected IList<IGalleryItem> ExtractGalleryItemList(IDragDropObject dataObject)
		{
			IList<IGalleryItem> itemlist = null;
			if (dataObject.HasData<IList<IGalleryItem>>())
			{
				itemlist = dataObject.GetData<IList<IGalleryItem>>();
			}

			foreach (string format in dataObject.GetFormats())
			{
				object obj = dataObject.GetData(format);
				if (obj is IList<IGalleryItem>)
					itemlist = obj as IList<IGalleryItem>;
			}

			if (itemlist != null && itemlist.Count == 0)
				return null;
			return itemlist;
		}
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="droppedData"></param>
        /// <param name="targetItem"></param>
        /// <param name="action"></param>
        /// <param name="modifiers"></param>
        /// <returns></returns>
        public override sealed DragDropOption PerformDrop(IDragDropObject droppedData, IGalleryItem targetItem, DragDropOption action, ModifierFlags modifiers)
        {
            DragDropOption       performedAction;
            IList <IGalleryItem> droppedItems = ExtractGalleryItemList(droppedData);

            if (droppedItems != null)
            {
                if (_draggedItems == droppedItems)
                {
                    performedAction = PerformDropLocalItems(droppedItems, targetItem, action, modifiers);
                }
                else
                {
                    performedAction = PerformDropForeignItems(droppedItems, targetItem, action, modifiers);
                }
            }
            else
            {
                performedAction = PerformDropForeignObject(droppedData, targetItem, action, modifiers);
            }
            return(performedAction);
        }
예제 #3
0
        /// <summary>
        /// Checks for allowed drag &amp; drop actions involving the specified foreign data and the given target on this component.
        /// </summary>
        /// <param name="droppingData">The <see cref="IDragDropObject"/> object that encapsulates all forms of the foreign data.</param>
        /// <param name="targetItem">The target item that the user is trying to drop on to.</param>
        /// <param name="actions"></param>
        /// <param name="modifiers">The modifier keys that are being held by the user.</param>
        /// <returns>The allowed <see cref="DragDropKind"/> action for this attempted drag &amp; drop operation.</returns>
        public override sealed DragDropOption CheckDrop(IDragDropObject droppingData, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers)
        {
            DragDropOption       allowedActions;
            IList <IGalleryItem> droppingItems = ExtractGalleryItemList(droppingData);

            if (droppingItems != null)
            {
                if (_draggedItems == droppingItems)
                {
                    allowedActions = CheckDropLocalItems(droppingItems, targetItem, actions, modifiers);
                }
                else
                {
                    allowedActions = CheckDropForeignItems(droppingItems, targetItem, actions, modifiers);
                }
            }
            else
            {
                allowedActions = CheckDropForeignObject(droppingData, targetItem, actions, modifiers);
            }
            return(actions & allowedActions);
        }
예제 #4
0
        /// <summary>
        /// Gets a list of  <see cref="IGalleryItem"/>s from the given <see cref="IDragDropObject">data wrapper</see>.
        /// </summary>
        /// <param name="dataObject">The data wrapper object.</param>
        /// <returns>A <see cref="IList{T}"/> of <see cref="IGalleryItem"/>s, or null if the wrapper did not contain a list of 0 or more IGalleryItems.</returns>
        protected IList <IGalleryItem> ExtractGalleryItemList(IDragDropObject dataObject)
        {
            IList <IGalleryItem> itemlist = null;

            if (dataObject.HasData <IList <IGalleryItem> >())
            {
                itemlist = dataObject.GetData <IList <IGalleryItem> >();
            }

            foreach (string format in dataObject.GetFormats())
            {
                object obj = dataObject.GetData(format);
                if (obj is IList <IGalleryItem> )
                {
                    itemlist = obj as IList <IGalleryItem>;
                }
            }

            if (itemlist != null && itemlist.Count == 0)
            {
                return(null);
            }
            return(itemlist);
        }
예제 #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="droppedData"></param>
 /// <param name="targetItem"></param>
 /// <param name="action"></param>
 /// <param name="modifiers"></param>
 /// <returns></returns>
 public virtual DragDropOption PerformDrop(IDragDropObject droppedData, IGalleryItem targetItem, DragDropOption action, ModifierFlags modifiers)
 {
     return(DragDropOption.None);
 }
예제 #6
0
 /// <summary>
 ///
 /// </summary>
 /// <remarks>
 /// This method or <see cref="PerformDrop(IDragDropObject,IGalleryItem,DragDropOption,ModifierFlags)"/> may be called
 /// additional times if the returned action is <see cref="DragDropOption.None"/> in order to attempt other ways to drop the item in
 /// an acceptable manner. It is thus very important that the result be set properly if the drop was accepted and no further attempts
 /// should be made.
 /// </remarks>
 /// <param name="droppedData"></param>
 /// <param name="targetIndex"></param>
 /// <param name="action"></param>
 /// <param name="modifiers"></param>
 /// <returns></returns>
 public virtual DragDropOption PerformDrop(IDragDropObject droppedData, int targetIndex, DragDropOption action, ModifierFlags modifiers)
 {
     return(DragDropOption.None);
 }
예제 #7
0
 /// <summary>
 /// Checks for allowed drag &amp; drop actions involving the specified foreign data and the given target on this component.
 /// </summary>
 /// <param name="droppingData">The <see cref="IDragDropObject"/> object that encapsulates all forms of the foreign data.</param>
 /// <param name="targetItem">The target item that the user is trying to drop on to.</param>
 /// <param name="actions"></param>
 /// <param name="modifiers">The modifier keys that are being held by the user.</param>
 /// <returns>The allowed <see cref="DragDropKind"/> action for this attempted drag &amp; drop operation.</returns>
 public virtual DragDropOption CheckDrop(IDragDropObject droppingData, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers)
 {
     return(DragDropOption.None);
 }
예제 #8
0
 /// <summary>
 /// Checks for allowed drag &amp; drop actions involving the specified foreign data and the given target on this component.
 /// </summary>
 /// <param name="droppingData">The <see cref="IDragDropObject"/> object that encapsulates all forms of the foreign data.</param>
 /// <param name="targetIndex">The target index that the user is trying to drop at.</param>
 /// <param name="actions"></param>
 /// <param name="modifiers">The modifier keys that are being held by the user.</param>
 /// <returns>The allowed <see cref="DragDropKind"/> actions for this attempted drag &amp; drop operation.</returns>
 public virtual DragDropOption CheckDrop(IDragDropObject droppingData, int targetIndex, DragDropOption actions, ModifierFlags modifiers)
 {
     return(DragDropOption.None);
 }
예제 #9
0
 /// <summary>
 /// Performs a drag-drop of a non-<see cref="IGalleryItem"/> object from outside this gallery on top of the specified item.
 /// </summary>
 /// <param name="droppedData">The data object to drop.</param>
 /// <param name="targetItem">The target <see cref="IGalleryItem"/> at which the <paramref name="droppedData"/> is being dropped.</param>
 /// <param name="actions">The interaction to take.</param>
 /// <param name="modifiers">The modifier keys that were pressed at the time of the drop.</param>
 /// <returns>The actual interaction on the <paramref name="droppedData"/> that was taken.</returns>
 protected virtual DragDropOption PerformDropForeignObject(IDragDropObject droppedData, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers)
 {
     return(DragDropOption.None);
 }
예제 #10
0
 /// <summary>
 /// Checks if drag-dropping non-<see cref="IGalleryItem"/> objects from outside this gallery to the specified index is allowed.
 /// </summary>
 /// <param name="droppingData">The data object to drop.</param>
 /// <param name="targetIndex">The target index at which the <paramref name="droppingData"/> is being dropped.</param>
 /// <param name="actions">The interactions that are being allowed by the data source.</param>
 /// <param name="modifiers">The modifier keys that currently being pressed.</param>
 /// <returns>The allowed interactions for dropping the <paramref name="droppingData"/> here.</returns>
 protected virtual DragDropOption CheckDropForeignObject(IDragDropObject droppingData, int targetIndex, DragDropOption actions, ModifierFlags modifiers)
 {
     return(DragDropOption.None);
 }
예제 #11
0
		/// <summary>
		/// Performs a drag-drop of a non-<see cref="IGalleryItem"/> object from outside this gallery on top of the specified item.
		/// </summary>
		/// <param name="droppedData">The data object to drop.</param>
		/// <param name="targetItem">The target <see cref="IGalleryItem"/> at which the <paramref name="droppedData"/> is being dropped.</param>
		/// <param name="actions">The interaction to take.</param>
		/// <param name="modifiers">The modifier keys that were pressed at the time of the drop.</param>
		/// <returns>The actual interaction on the <paramref name="droppedData"/> that was taken.</returns>
		protected virtual DragDropOption PerformDropForeignObject(IDragDropObject droppedData, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers)
		{
			return DragDropOption.None;
		}
예제 #12
0
		/// <summary>
		/// Performs a drag-drop of a non-<see cref="IGalleryItem"/> object from outside this gallery to the specified index.
		/// </summary>
		/// <param name="droppedData">The data object to drop.</param>
		/// <param name="targetIndex">The target index at which the <paramref name="droppedData"/> is being dropped.</param>
		/// <param name="actions">The interaction to take.</param>
		/// <param name="modifiers">The modifier keys that were pressed at the time of the drop.</param>
		/// <returns>The actual interaction on the <paramref name="droppedData"/> that was taken.</returns>
		protected virtual DragDropOption PerformDropForeignObject(IDragDropObject droppedData, int targetIndex, DragDropOption actions, ModifierFlags modifiers)
		{
			return DragDropOption.None;
		}
예제 #13
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="droppedData"></param>
		/// <param name="targetItem"></param>
		/// <param name="action"></param>
		/// <param name="modifiers"></param>
		/// <returns></returns>
		public override sealed DragDropOption PerformDrop(IDragDropObject droppedData, IGalleryItem targetItem, DragDropOption action, ModifierFlags modifiers)
		{
			DragDropOption performedAction;
			IList<IGalleryItem> droppedItems = ExtractGalleryItemList(droppedData);
			if (droppedItems != null)
			{
				if (_draggedItems == droppedItems)
				{
					performedAction = PerformDropLocalItems(droppedItems, targetItem, action, modifiers);
				}
				else
				{
					performedAction = PerformDropForeignItems(droppedItems, targetItem, action, modifiers);
				}
			}
			else
			{
				performedAction = PerformDropForeignObject(droppedData, targetItem, action, modifiers);
			}
			return performedAction;
		}
예제 #14
0
		/// <summary>
		/// Checks for allowed drag &amp; drop actions involving the specified foreign data and the given target on this component.
		/// </summary>
		/// <param name="droppingData">The <see cref="IDragDropObject"/> object that encapsulates all forms of the foreign data.</param>
		/// <param name="targetItem">The target item that the user is trying to drop on to.</param>
		/// <param name="actions"></param>
		/// <param name="modifiers">The modifier keys that are being held by the user.</param>
		/// <returns>The allowed <see cref="DragDropKind"/> action for this attempted drag &amp; drop operation.</returns>
		public override sealed DragDropOption CheckDrop(IDragDropObject droppingData, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers)
		{
			DragDropOption allowedActions;
			IList<IGalleryItem> droppingItems = ExtractGalleryItemList(droppingData);
			if (droppingItems != null)
			{
				if (_draggedItems == droppingItems)
				{
					allowedActions = CheckDropLocalItems(droppingItems, targetItem, actions, modifiers);
				}
				else
				{
					allowedActions = CheckDropForeignItems(droppingItems, targetItem, actions, modifiers);
				}
			}
			else
			{
				allowedActions = CheckDropForeignObject(droppingData, targetItem, actions, modifiers);
			}
			return actions & allowedActions;
		}