Skip to content

Fix for #404 #405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 8, 2021
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
8 changes: 5 additions & 3 deletions src/GongSolutions.WPF.DragDrop/DropInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ public DropInfo(object sender, DragEventArgs e, [CanBeNull] DragInfo dragInfo, E

this.InsertPosition |= RelativeInsertPosition.TargetItemCenter;
}
//System.Diagnostics.Debug.WriteLine("==> DropInfo: pos={0}, idx={1}, Y={2}, Item={3}", this.InsertPosition, this.InsertIndex, currentYPos, item);

// System.Diagnostics.Debug.WriteLine($"==> DropInfo: pos={this.InsertPosition}, index={this.InsertIndex}, currentXPos={currentXPos}, Item={this.item}");
}
else
{
Expand All @@ -188,7 +189,7 @@ public DropInfo(object sender, DragEventArgs e, [CanBeNull] DragInfo dragInfo, E

if (this.VisualTargetFlowDirection == FlowDirection.RightToLeft)
{
if (currentXPos > targetWidth / 2)
if (currentXPos < targetWidth / 2)
{
this.InsertPosition = RelativeInsertPosition.BeforeTargetItem;
}
Expand Down Expand Up @@ -221,7 +222,8 @@ public DropInfo(object sender, DragEventArgs e, [CanBeNull] DragInfo dragInfo, E

this.InsertPosition |= RelativeInsertPosition.TargetItemCenter;
}
//System.Diagnostics.Debug.WriteLine("==> DropInfo: pos={0}, idx={1}, X={2}, Item={3}", this.InsertPosition, this.InsertIndex, currentXPos, item);

// System.Diagnostics.Debug.WriteLine($"==> DropInfo: pos={this.InsertPosition}, index={this.InsertIndex}, currentXPos={currentXPos}, Item={this.item}");
}
}
else
Expand Down
13 changes: 1 addition & 12 deletions src/GongSolutions.WPF.DragDrop/DropTargetInsertionAdorner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,7 @@ protected override void OnRender(DrawingContext drawingContext)
}
else
{
if (dropInfo.VisualTargetFlowDirection == FlowDirection.LeftToRight && dropInfo.InsertIndex == itemsCount)
{
if (itemsCount > 0)
{
itemRect.X += itemContainer.RenderSize.Width;
}
else
{
itemRect.X += this.Pen.Thickness;
}
}
else if (dropInfo.VisualTargetFlowDirection == FlowDirection.RightToLeft && dropInfo.InsertIndex != itemsCount)
if (dropInfo.InsertIndex == itemsCount)
{
if (itemsCount > 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private static BitmapSource CaptureScreen(Visual target, FlowDirection flowDirec
{
var transformGroup = new TransformGroup();
transformGroup.Children.Add(new ScaleTransform(-1, 1));
transformGroup.Children.Add(new TranslateTransform(bounds.Size.Width - 1, 0));
transformGroup.Children.Add(new TranslateTransform(bounds.Size.Width, 0));
ctx.PushTransform(transformGroup);
}

Expand Down
27 changes: 26 additions & 1 deletion src/Showcase/Views/ListBoxSamples.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,36 @@
<StackPanel>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Demonstrates the default behaviour with horizontal ListBoxes and right to left flow direction." />
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Unbound ListBox" />
<ListBox Height="Auto"
<ListBox MinHeight="30"
Height="Auto"
dd:DragDrop.DefaultDragAdornerOpacity="0.5"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultDragAdorner="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True"
dd:DragDrop.ShowAlwaysDropTargetAdorner="True"
SelectionMode="Extended">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Margin="1" Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBoxItem>ListBoxItem1</ListBoxItem>
<ListBoxItem>ListBoxItem2</ListBoxItem>
<ListBoxItem>ListBoxItem3</ListBoxItem>
<ListBoxItem>ListBoxItem4</ListBoxItem>
<ListBoxItem>ListBoxItem5</ListBoxItem>
</ListBox>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="ListBox with right to left flow direction" />
<ListBox MinHeight="30"
Height="Auto"
FlowDirection="RightToLeft"
dd:DragDrop.DefaultDragAdornerOpacity="0.5"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultDragAdorner="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True"
dd:DragDrop.ShowAlwaysDropTargetAdorner="True"
SelectionMode="Extended">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
Expand Down