Ejemplo n.º 1
0
        /// <summary>
        /// Performs a default drag and drop operation for the specified drag source.
        /// </summary>
        /// <param name="control">The drag source Control.</param>
        /// <param name="dataObject">The data object associated to the drag and drop operation.</param>
        /// <param name="allowedEffects">The allowed drop effects.</param>
        /// <param name="data">The associated data.</param>
        /// <returns>The accepted drop effects from the completed operation.</returns>
        private static DragDropEffects DoDragDropInternal(Control control, IDataObject dataObject,
                                                          DragDropEffects allowedEffects, KeyValuePair <string, object>[] data)
        {
            // Set the data onto the data object.
            if (data != null)
            {
                foreach (var dataPair in data)
                {
                    dataObject.SetDataEx(dataPair.Key, dataPair.Value);
                }
            }

            try {
                return(control.DoDragDrop(dataObject, allowedEffects));
            }
            finally {
                UnregisterDefaultDragSource(control);
            }
        }
Ejemplo n.º 2
0
		/// <summary>
		/// Performs a default drag and drop operation for the specified drag source.
		/// </summary>
		/// <param name="control">The drag source Control.</param>
		/// <param name="dataObject">The data object associated to the drag and drop operation.</param>
		/// <param name="allowedEffects">The allowed drop effects.</param>
		/// <param name="data">The associated data.</param>
		/// <returns>The accepted drop effects from the completed operation.</returns>
		private static DragDropEffects DoDragDropInternal(Control control, IDataObject dataObject,
		                                                  DragDropEffects allowedEffects, KeyValuePair<string, object>[] data) {
			// Set the data onto the data object.
			if (data != null) {
				foreach (var dataPair in data)
					dataObject.SetDataEx(dataPair.Key, dataPair.Value);
			}

			try {
				return control.DoDragDrop(dataObject, allowedEffects);
			}
			finally {
				UnregisterDefaultDragSource(control);
			}
		}