Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/GongSolutions.WPF.DragDrop.Shared/DragDrop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private static BitmapSource CaptureScreen(Visual target, FlowDirection flowDirec
private static void CreateEffectAdorner(DropInfo dropInfo)
{
var dragInfo = m_DragInfo;
var template = GetEffectAdornerTemplate(dragInfo.VisualSource, dropInfo.Effects, dropInfo.DestinationText);
var template = GetEffectAdornerTemplate(dragInfo.VisualSource, dropInfo.Effects, dropInfo.DestinationText, dropInfo.EffectText);

if (template != null) {
var rootElement = RootElementFinder.FindRoot(dropInfo.VisualTarget ?? dragInfo.VisualSource);
Expand All @@ -146,21 +146,21 @@ private static void CreateEffectAdorner(DropInfo dropInfo)
}
}

private static DataTemplate GetEffectAdornerTemplate(UIElement target, DragDropEffects effect, string destinationText)
private static DataTemplate GetEffectAdornerTemplate(UIElement target, DragDropEffects effect, string destinationText, string effectText = null)
{
switch (effect)
{
case DragDropEffects.All:
// TODO: Add default template for EffectAll
return GetEffectAllAdornerTemplate(target);
case DragDropEffects.Copy:
return GetEffectCopyAdornerTemplate(target) ?? CreateDefaultEffectDataTemplate(target, IconFactory.EffectCopy, "Copy to", destinationText);
return GetEffectCopyAdornerTemplate(target) ?? CreateDefaultEffectDataTemplate(target, IconFactory.EffectCopy, effectText == null ? "Copy to" : effectText, destinationText);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So maybe it's also good to check string.IsNullOrEmpty(effectText)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used to have the code like your suggestion but we needed an empty string instead of "move to".
With string.IsNullOrEmpty(effectText) the empty string would have been replaced with "Move to". A workaround would have been to set the effectText to " " but the additional whitespace doesn't look good.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, so it's ok for me.

case DragDropEffects.Link:
return GetEffectLinkAdornerTemplate(target) ?? CreateDefaultEffectDataTemplate(target, IconFactory.EffectLink, "Link to", destinationText);
return GetEffectLinkAdornerTemplate(target) ?? CreateDefaultEffectDataTemplate(target, IconFactory.EffectLink, effectText == null ? "Link to" : effectText, destinationText);
case DragDropEffects.Move:
return GetEffectMoveAdornerTemplate(target) ?? CreateDefaultEffectDataTemplate(target, IconFactory.EffectMove, "Move to", destinationText);
return GetEffectMoveAdornerTemplate(target) ?? CreateDefaultEffectDataTemplate(target, IconFactory.EffectMove, effectText == null ? "Move to" : effectText, destinationText);
case DragDropEffects.None:
return GetEffectNoneAdornerTemplate(target) ?? CreateDefaultEffectDataTemplate(target, IconFactory.EffectNone, "None", destinationText);
return GetEffectNoneAdornerTemplate(target) ?? CreateDefaultEffectDataTemplate(target, IconFactory.EffectNone, effectText == null ? "None" : effectText, destinationText);
case DragDropEffects.Scroll:
// TODO: Add default template EffectScroll
return GetEffectScrollAdornerTemplate(target);
Expand Down
5 changes: 5 additions & 0 deletions src/GongSolutions.WPF.DragDrop.Shared/DropInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@ public int UnfilteredInsertIndex
/// </summary>
public string DestinationText { get; set; }

/// <summary>
/// Gets and sets the effect text displayed in the DropDropEffects adorner.
/// </summary>
public string EffectText { get; set; }

/// <summary>
/// Gets the relative position the item will be inserted to compared to the TargetItem
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/GongSolutions.WPF.DragDrop.Shared/IDropInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ public interface IDropInfo
/// </summary>
string DestinationText { get; set; }

/// <summary>
/// Gets and sets the effect text displayed in the DropDropEffects adorner.
/// </summary>
string EffectText { get; set; }

/// <summary>
/// Gets the relative position the item will be inserted to compared to the TargetItem
/// </summary>
Expand Down