Skip to content

Commit

Permalink
Merge branch 'hotfix/#404' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Oct 8, 2021
2 parents 0ad2621 + 8bcdd2a commit c2fa96e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 17 deletions.
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

0 comments on commit c2fa96e

Please sign in to comment.