From 5e6f4ffa0cc6068284961915bd1829a2cb582c43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Karger=20=E3=83=84=20=E2=98=80?= Date: Fri, 9 Sep 2022 22:58:35 +0200 Subject: [PATCH 1/7] Create dependabot.yml --- .github/dependabot.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..f5b21b9a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "nuget" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "monthly" + open-pull-requests-limit: 10 From ae98a811ba906766dfd775ce309ec0343e8bdc5c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 9 Sep 2022 20:58:57 +0000 Subject: [PATCH 2/7] build(deps): update Fody requirement from 6.5.* to 6.6.* Updates the requirements on [Fody](https://github.com/Fody/Fody) to permit the latest version. - [Release notes](https://github.com/Fody/Fody/releases) - [Commits](https://github.com/Fody/Fody/compare/6.5.0...6.6.3) --- updated-dependencies: - dependency-name: Fody dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- src/Showcase/Showcase.WPF.DragDrop.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Showcase/Showcase.WPF.DragDrop.csproj b/src/Showcase/Showcase.WPF.DragDrop.csproj index f71ca229..c83bf058 100644 --- a/src/Showcase/Showcase.WPF.DragDrop.csproj +++ b/src/Showcase/Showcase.WPF.DragDrop.csproj @@ -28,7 +28,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive From 0a79cec913694e65dc7bcabb573c8ce56f7a8be0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 9 Sep 2022 20:59:00 +0000 Subject: [PATCH 3/7] build(deps): update Costura.Fody requirement from 5.6.* to 5.7.* Updates the requirements on [Costura.Fody](https://github.com/Fody/Costura) to permit the latest version. - [Release notes](https://github.com/Fody/Costura/releases) - [Changelog](https://github.com/Fody/Costura/blob/develop/GitReleaseManager.yaml) - [Commits](https://github.com/Fody/Costura/compare/5.6.0...5.7.0) --- updated-dependencies: - dependency-name: Costura.Fody dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- src/Showcase/Showcase.WPF.DragDrop.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Showcase/Showcase.WPF.DragDrop.csproj b/src/Showcase/Showcase.WPF.DragDrop.csproj index f71ca229..fecf36be 100644 --- a/src/Showcase/Showcase.WPF.DragDrop.csproj +++ b/src/Showcase/Showcase.WPF.DragDrop.csproj @@ -32,7 +32,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + From 2faf12f6213cf6f4ec369bf32e59a0e204a36e44 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 9 Sep 2022 20:59:05 +0000 Subject: [PATCH 4/7] build(deps): update JetBrains.Annotations requirement Updates the requirements on [JetBrains.Annotations](https://github.com/JetBrains/JetBrains.Annotations) to permit the latest version. - [Release notes](https://github.com/JetBrains/JetBrains.Annotations/releases) - [Commits](https://github.com/JetBrains/JetBrains.Annotations/commits) --- updated-dependencies: - dependency-name: JetBrains.Annotations dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- src/Directory.build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Directory.build.props b/src/Directory.build.props index e389b90e..7c176235 100644 --- a/src/Directory.build.props +++ b/src/Directory.build.props @@ -21,7 +21,7 @@ - + From 349b0f35af4c0c1389e867c3fb6fa4c961eef8a5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 10 Sep 2022 10:21:34 +0000 Subject: [PATCH 5/7] build(deps): update WpfAnalyzers requirement from 3.5.* to 4.1.* Updates the requirements on [WpfAnalyzers](https://github.com/DotNetAnalyzers/WpfAnalyzers) to permit the latest version. - [Release notes](https://github.com/DotNetAnalyzers/WpfAnalyzers/releases) - [Changelog](https://github.com/DotNetAnalyzers/WpfAnalyzers/blob/master/RELEASE_NOTES.md) - [Commits](https://github.com/DotNetAnalyzers/WpfAnalyzers/commits) --- updated-dependencies: - dependency-name: WpfAnalyzers dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- src/Directory.build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Directory.build.props b/src/Directory.build.props index 7c176235..3eabfb4c 100644 --- a/src/Directory.build.props +++ b/src/Directory.build.props @@ -22,7 +22,7 @@ - + From 918ae55825f1700b661380ae0989d4dfb1fb1bbb Mon Sep 17 00:00:00 2001 From: punker76 Date: Sun, 25 Dec 2022 12:50:27 +0100 Subject: [PATCH 6/7] fix: #460 calculate correct size of DropTargetAdorner If the ItemsControl has a scrollable content then try to get the viewport width/height to paint the insertion adorner only on this size. --- .../DropTargetInsertionAdorner.cs | 205 +++++++++--------- 1 file changed, 100 insertions(+), 105 deletions(-) diff --git a/src/GongSolutions.WPF.DragDrop/DropTargetInsertionAdorner.cs b/src/GongSolutions.WPF.DragDrop/DropTargetInsertionAdorner.cs index 7778f7fd..b2a248f2 100644 --- a/src/GongSolutions.WPF.DragDrop/DropTargetInsertionAdorner.cs +++ b/src/GongSolutions.WPF.DragDrop/DropTargetInsertionAdorner.cs @@ -23,141 +23,136 @@ public DropTargetInsertionAdorner(UIElement adornedElement, DropInfo dropInfo) protected override void OnRender(DrawingContext drawingContext) { var dropInfo = this.DropInfo; - var itemsControl = dropInfo.VisualTarget as ItemsControl; - if (itemsControl != null) + if (dropInfo.VisualTarget is not ItemsControl itemsControl) { - // Get the position of the item at the insertion index. If the insertion point is - // to be after the last item, then get the position of the last item and add an - // offset later to draw it at the end of the list. - ItemsControl itemParent; + return; + } - var visualTargetItem = dropInfo.VisualTargetItem; - if (visualTargetItem != null) - { - itemParent = ItemsControl.ItemsControlFromItemContainer(visualTargetItem); - } - else - { - itemParent = itemsControl; - } + // Get the position of the item at the insertion index. If the insertion point is + // to be after the last item, then get the position of the last item and add an + // offset later to draw it at the end of the list. + + var visualTargetItem = dropInfo.VisualTargetItem; + var itemParent = visualTargetItem != null ? ItemsControl.ItemsControlFromItemContainer(visualTargetItem) : itemsControl; - // this could be happen with a thread scenario where items are removed very quickly - if (itemParent == null) + // this could be happen with a thread scenario where items are removed very quickly + if (itemParent == null) + { + return; + } + + var itemsCount = itemParent.Items.Count; + var index = Math.Min(dropInfo.InsertIndex, itemsCount - 1); + + var lastItemInGroup = false; + var targetGroup = dropInfo.TargetGroup; + if (targetGroup != null && targetGroup.IsBottomLevel && dropInfo.InsertPosition.HasFlag(RelativeInsertPosition.AfterTargetItem)) + { + var indexOf = targetGroup.Items.IndexOf(dropInfo.TargetItem); + lastItemInGroup = indexOf == targetGroup.ItemCount - 1; + if (lastItemInGroup && dropInfo.InsertIndex != itemsCount) { - return; + index--; } + } - var itemsCount = itemParent.Items.Count; - var index = Math.Min(dropInfo.InsertIndex, itemsCount - 1); + var itemContainer = (UIElement)itemParent.ItemContainerGenerator.ContainerFromIndex(index); - var lastItemInGroup = false; - var targetGroup = dropInfo.TargetGroup; - if (targetGroup != null && targetGroup.IsBottomLevel && dropInfo.InsertPosition.HasFlag(RelativeInsertPosition.AfterTargetItem)) + var showAlwaysDropTargetAdorner = itemContainer == null && DragDrop.GetShowAlwaysDropTargetAdorner(itemParent); + if (showAlwaysDropTargetAdorner) + { + itemContainer = itemParent; + } + + if (itemContainer == null) + { + return; + } + + var itemRect = new Rect(itemContainer.TranslatePoint(new Point(), this.AdornedElement), itemContainer.RenderSize); + Point point1, + point2; + double rotation = 0; + + // If the ItemsControl has a scrollable content then try to get the viewport width/height + // to paint the insertion adorner only on this size. + var viewportWidth = double.MaxValue; + var viewportHeight = double.MaxValue; + if (dropInfo.TargetScrollViewer != null) + { + if (dropInfo.TargetScrollViewer.ScrollableWidth != 0) { - var indexOf = targetGroup.Items.IndexOf(dropInfo.TargetItem); - lastItemInGroup = indexOf == targetGroup.ItemCount - 1; - if (lastItemInGroup && dropInfo.InsertIndex != itemsCount) - { - index--; - } + viewportWidth = dropInfo.TargetScrollViewer.ViewportWidth; } - var itemContainer = (UIElement)itemParent.ItemContainerGenerator.ContainerFromIndex(index); - - var showAlwaysDropTargetAdorner = itemContainer == null && DragDrop.GetShowAlwaysDropTargetAdorner(itemParent); - if (showAlwaysDropTargetAdorner) + if (dropInfo.TargetScrollViewer.ScrollableHeight != 0) { - itemContainer = itemParent; + viewportHeight = dropInfo.TargetScrollViewer.ViewportHeight; } + } - if (itemContainer != null) + if (dropInfo.VisualTargetOrientation == Orientation.Vertical) + { + if ((dropInfo.InsertIndex == itemsCount) || lastItemInGroup) { - var itemRect = new Rect(itemContainer.TranslatePoint(new Point(), this.AdornedElement), itemContainer.RenderSize); - Point point1, - point2; - double rotation = 0; - - // I really don't know why I did this - // - // var viewportWidth = double.MaxValue; - // var viewportHeight = double.MaxValue; - // if (DropInfo.TargetScrollViewer != null) - // { - // if (DropInfo.TargetScrollViewer.ScrollableWidth != 0) - // { - // viewportWidth = DropInfo.TargetScrollViewer.ViewportWidth; - // } - // - // if (DropInfo.TargetScrollViewer.ScrollableHeight != 0) - // { - // viewportHeight = DropInfo.TargetScrollViewer.ViewportHeight; - // } - // } - - if (dropInfo.VisualTargetOrientation == Orientation.Vertical) + if (itemsCount > 0) { - if ((dropInfo.InsertIndex == itemsCount) || lastItemInGroup) - { - if (itemsCount > 0) - { - itemRect.Y += itemContainer.RenderSize.Height; - } - else - { - if ((itemsControl as ListView)?.View is GridView) - { - var header = itemsControl.GetVisualDescendent(); - if (header != null) - { - itemRect.Y += header.RenderSize.Height; - } - } - else if (itemsControl is DataGrid) - { - var header = itemsControl.GetVisualDescendent(); - if (header != null) - { - itemRect.Y += header.RenderSize.Height; - } - } - - itemRect.Y += this.Pen.Thickness; - } - } - - var itemRectRight = itemRect.Right; //Math.Min(itemRect.Right, viewportWidth); - var itemRectLeft = itemRect.X < 0 ? 0 : itemRect.X; - point1 = new Point(itemRectLeft, itemRect.Y); - point2 = new Point(itemRectRight, itemRect.Y); + itemRect.Y += itemContainer.RenderSize.Height; } else { - if (dropInfo.InsertIndex == itemsCount) + if ((itemsControl as ListView)?.View is GridView) { - if (itemsCount > 0) + var header = itemsControl.GetVisualDescendent(); + if (header != null) { - itemRect.X += itemContainer.RenderSize.Width; + itemRect.Y += header.RenderSize.Height; } - else + } + else if (itemsControl is DataGrid) + { + var header = itemsControl.GetVisualDescendent(); + if (header != null) { - itemRect.X += this.Pen.Thickness; + itemRect.Y += header.RenderSize.Height; } } - var itemRectTop = itemRect.Y < 0 ? 0 : itemRect.Y; - var itemRectBottom = itemRect.Bottom; //Math.Min(itemRect.Bottom, viewportHeight); - - point1 = new Point(itemRect.X, itemRectTop); - point2 = new Point(itemRect.X, itemRectBottom); - rotation = 90; + itemRect.Y += this.Pen.Thickness; } + } - drawingContext.DrawLine(this.Pen, point1, point2); - this.DrawTriangle(drawingContext, point1, rotation); - this.DrawTriangle(drawingContext, point2, 180 + rotation); + var itemRectRight = Math.Min(itemRect.Right, viewportWidth); + var itemRectLeft = itemRect.X < 0 ? 0 : itemRect.X; + point1 = new Point(itemRectLeft, itemRect.Y); + point2 = new Point(itemRectRight, itemRect.Y); + } + else + { + if (dropInfo.InsertIndex == itemsCount) + { + if (itemsCount > 0) + { + itemRect.X += itemContainer.RenderSize.Width; + } + else + { + itemRect.X += this.Pen.Thickness; + } } + + var itemRectTop = itemRect.Y < 0 ? 0 : itemRect.Y; + var itemRectBottom = Math.Min(itemRect.Bottom, viewportHeight); + + point1 = new Point(itemRect.X, itemRectTop); + point2 = new Point(itemRect.X, itemRectBottom); + rotation = 90; } + + drawingContext.DrawLine(this.Pen, point1, point2); + this.DrawTriangle(drawingContext, point1, rotation); + this.DrawTriangle(drawingContext, point2, 180 + rotation); } private void DrawTriangle(DrawingContext drawingContext, Point origin, double rotation) From 054245045205b77a61cd3f136e2ce9a4e88524f1 Mon Sep 17 00:00:00 2001 From: punker76 Date: Sun, 25 Dec 2022 20:37:02 +0100 Subject: [PATCH 7/7] chore(build): set exact version for package references --- global.json | 6 ------ src/Showcase/Showcase.WPF.DragDrop.csproj | 12 ++++++------ src/global.json | 7 +++++++ 3 files changed, 13 insertions(+), 12 deletions(-) delete mode 100644 global.json create mode 100644 src/global.json diff --git a/global.json b/global.json deleted file mode 100644 index 9f49ccc2..00000000 --- a/global.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "sdk": { - "version": "6.0.300", - "rollForward": "feature" - } -} \ No newline at end of file diff --git a/src/Showcase/Showcase.WPF.DragDrop.csproj b/src/Showcase/Showcase.WPF.DragDrop.csproj index 162ddd65..71ea96d1 100644 --- a/src/Showcase/Showcase.WPF.DragDrop.csproj +++ b/src/Showcase/Showcase.WPF.DragDrop.csproj @@ -21,18 +21,18 @@ - - - - + + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/global.json b/src/global.json new file mode 100644 index 00000000..f8d33ac9 --- /dev/null +++ b/src/global.json @@ -0,0 +1,7 @@ +{ + "sdk": { + "version": "6.0.300", + "rollForward": "latestFeature", + "allowPrerelease": false + } +} \ No newline at end of file