本文整理汇总了C#中IDataObject.SetDropDescription方法的典型用法代码示例。如果您正苦于以下问题:C# IDataObject.SetDropDescription方法的具体用法?C# IDataObject.SetDropDescription怎么用?C# IDataObject.SetDropDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataObject
的用法示例。
在下文中一共展示了IDataObject.SetDropDescription方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DragEnter
/// <summary>
/// Sets the drop description of the IDataObject and then notifies the
/// DragDropHelper that the specified Control received a DragEnter event.
/// </summary>
/// <param name="control">The Control the received the DragEnter event.</param>
/// <param name="data">The DataObject containing a drag image.</param>
/// <param name="cursorOffset">The current cursor's offset relative to the window.</param>
/// <param name="effect">The accepted drag drop effect.</param>
/// <param name="descriptionMessage">The drop description message.</param>
/// <param name="descriptionInsert">The drop description insert.</param>
/// <remarks>
/// Because the DragLeave event in SWF does not provide the IDataObject in the
/// event args, this DragEnter override of the DropTargetHelper will cache a
/// copy of the IDataObject based on the provided Control so that it may be
/// cleared using the DragLeave override that takes a Control parameter. Note that
/// if you use this override of DragEnter, you must call the DragLeave override
/// that takes a Control parameter to avoid a possible memory leak. However, calling
/// this method multiple times with the same Control parameter while not calling the
/// DragLeave method will not leak memory.
/// </remarks>
public static void DragEnter(Control control, IDataObject data, Point cursorOffset, DragDropEffects effect,
string descriptionMessage, string descriptionInsert) {
data.SetDropDescription((DropImageType) effect, descriptionMessage, descriptionInsert);
DragEnter(control, data, cursorOffset, effect);
if (!s_dataContext.ContainsKey(control))
s_dataContext.Add(control, data);
else
s_dataContext[control] = data;
}
示例2: DefaultGiveFeedback
/// <summary>
/// Provides a default GiveFeedback event handler for drag sources.
/// </summary>
/// <param name="data">The associated data object for the event.</param>
/// <param name="e">The event arguments.</param>
public static void DefaultGiveFeedback(IDataObject 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.
bool setDefaultDropDesc = false;
bool isDefaultDropDesc = IsDropDescriptionDefault(data);
DropImageType 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.Arrow;
}
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)
{
InvalidateDragImage(data);
// 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)
{
// Only change if the effect changed
if ((DropImageType) e.Effect != currentType)
{
if (e.Effect == DragDropEffects.Copy)
data.SetDropDescription(DropImageType.Copy, "Copy", "");
else if (e.Effect == DragDropEffects.Link)
data.SetDropDescription(DropImageType.Link, "Link", "");
else if (e.Effect == DragDropEffects.Move)
data.SetDropDescription(DropImageType.Move, "Move", "");
else if (e.Effect == DragDropEffects.None)
data.SetDropDescription(DropImageType.None, null, 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);
}
}
}
示例3: DragLeave
/// <summary>
/// Notifies the DragDropHelper that the current Window received
/// a DragLeave event.
/// </summary>
/// <param name="data">The data object associated to the event.</param>
public static void DragLeave(IDataObject data)
{
data.SetDropDescription(DropImageType.Invalid, null, null);
DragLeave();
}
示例4: DragEnter
/// <summary>
/// Notifies the DragDropHelper that the specified Window received
/// a DragEnter event.
/// </summary>
/// <param name="window">The Window the received the DragEnter event.</param>
/// <param name="data">The DataObject containing a drag image.</param>
/// <param name="cursorOffset">The current cursor's offset relative to the window.</param>
/// <param name="effect">The accepted drag drop effect.</param>
/// <param name="descriptionMessage">The drop description message.</param>
/// <param name="descriptionInsert">The drop description insert.</param>
/// <remarks>Callers of this DragEnter override should make sure to call
/// the DragLeave override taking an IDataObject parameter in order to clear
/// the drop description.</remarks>
public static void DragEnter(Window window, IDataObject data, Point cursorOffset, DragDropEffects effect, string descriptionMessage, string descriptionInsert)
{
data.SetDropDescription((DropImageType)effect, descriptionMessage, descriptionInsert);
DragEnter(window, data, cursorOffset, effect);
}