From 99f9dd79a3cbfed1bafe8d249a88dd18646ce3fa Mon Sep 17 00:00:00 2001 From: "NotYoojun.!" Date: Thu, 2 Nov 2023 17:27:27 +0800 Subject: [PATCH] dragdrop 2 --- .../DragDrop/DropTargetInsertionAdorner.cs | 15 ++++++++++++++- source/iNKORE.UI.WPF/DragDrop/IDragInfoBuilder.cs | 4 ++-- source/iNKORE.UI.WPF/DragDrop/IDropInfoBuilder.cs | 4 ++-- .../iNKORE.UI.WPF/DragDrop/Icons/IconFactory.cs | 2 +- .../DragDrop/Utilities/VisualTreeExtensions.cs | 1 + source/iNKORE.UI.WPF/iNKORE.UI.WPF.csproj | 11 +++++++++++ 6 files changed, 31 insertions(+), 6 deletions(-) diff --git a/source/iNKORE.UI.WPF/DragDrop/DropTargetInsertionAdorner.cs b/source/iNKORE.UI.WPF/DragDrop/DropTargetInsertionAdorner.cs index 7e4fe01..25783fd 100644 --- a/source/iNKORE.UI.WPF/DragDrop/DropTargetInsertionAdorner.cs +++ b/source/iNKORE.UI.WPF/DragDrop/DropTargetInsertionAdorner.cs @@ -70,7 +70,18 @@ protected override void OnRender(DrawingContext drawingContext) return; } - var itemRect = new Rect(itemContainer.TranslatePoint(new Point(), this.AdornedElement), itemContainer.RenderSize); + Size itemSize = itemContainer.RenderSize; + + var itemRect = new Rect(itemContainer.TranslatePoint(new Point(), this.AdornedElement), itemSize); + + if (itemContainer is FrameworkElement ele) + { + itemRect.X -= ele.Margin.Left; + itemRect.Y -= ele.Margin.Top; + itemRect.Width += ele.Margin.Left + ele.Margin.Right; + itemRect.Height += ele.Margin.Top + ele.Margin.Bottom; + } + Point point1, point2; double rotation = 0; @@ -179,9 +190,11 @@ static DropTargetInsertionAdorner() var figure = new PathFigure { StartPoint = new Point(triangleSize, 0) }; figure.Segments.Add(firstLine); figure.Segments.Add(secondLine); + figure.Freeze(); m_Triangle = new PathGeometry(); + m_Triangle.Figures.Add(figure); m_Triangle.Freeze(); } diff --git a/source/iNKORE.UI.WPF/DragDrop/IDragInfoBuilder.cs b/source/iNKORE.UI.WPF/DragDrop/IDragInfoBuilder.cs index 013e983..2154d0b 100644 --- a/source/iNKORE.UI.WPF/DragDrop/IDragInfoBuilder.cs +++ b/source/iNKORE.UI.WPF/DragDrop/IDragInfoBuilder.cs @@ -1,7 +1,7 @@ using System; using System.Windows; using System.Windows.Input; -////using JetBrains.Annotations; +//using JetBrains.Annotations; namespace iNKORE.UI.WPF.DragDrop { @@ -18,7 +18,7 @@ public interface IDragInfoBuilder /// The original source of the input event. /// The mouse button which was used for the drag operation. /// A function of the input event which is used to get drag position points. - //[CanBeNull] + DragInfo CreateDragInfo(object sender, object originalSource, MouseButton mouseButton, Func getPosition); } } \ No newline at end of file diff --git a/source/iNKORE.UI.WPF/DragDrop/IDropInfoBuilder.cs b/source/iNKORE.UI.WPF/DragDrop/IDropInfoBuilder.cs index 32ffd20..46a4efa 100644 --- a/source/iNKORE.UI.WPF/DragDrop/IDropInfoBuilder.cs +++ b/source/iNKORE.UI.WPF/DragDrop/IDropInfoBuilder.cs @@ -16,7 +16,7 @@ public interface IDropInfoBuilder /// The drag event arguments. /// Information about the drag source, if the drag came from within the framework. /// The type of the underlying event (tunneled or bubbled). - //[CanBeNull] - IDropInfo CreateDropInfo(object sender, DragEventArgs e, DragInfo dragInfo, EventType eventType); + + IDropInfo CreateDropInfo(object sender, DragEventArgs e, DragInfo dragInfo, EventType eventType); } } \ No newline at end of file diff --git a/source/iNKORE.UI.WPF/DragDrop/Icons/IconFactory.cs b/source/iNKORE.UI.WPF/DragDrop/Icons/IconFactory.cs index 87c7904..21a4639 100644 --- a/source/iNKORE.UI.WPF/DragDrop/Icons/IconFactory.cs +++ b/source/iNKORE.UI.WPF/DragDrop/Icons/IconFactory.cs @@ -41,7 +41,7 @@ public static class IconFactory /// The image to be displayed private static BitmapImage GetImage(string iconName, int size) { - var uri = new Uri($@"pack://application:,,,/iNKORE.UI.WPF.DragDrop;component/Icons/{iconName}", UriKind.RelativeOrAbsolute); + var uri = new Uri($@"/iNKORE.UI.WPF;component/DragDrop/Icons/{iconName}", UriKind.RelativeOrAbsolute); var icon = new BitmapImage(uri); icon.DecodePixelHeight = size; icon.DecodePixelWidth = size; diff --git a/source/iNKORE.UI.WPF/DragDrop/Utilities/VisualTreeExtensions.cs b/source/iNKORE.UI.WPF/DragDrop/Utilities/VisualTreeExtensions.cs index ed370ac..0220925 100644 --- a/source/iNKORE.UI.WPF/DragDrop/Utilities/VisualTreeExtensions.cs +++ b/source/iNKORE.UI.WPF/DragDrop/Utilities/VisualTreeExtensions.cs @@ -5,6 +5,7 @@ using System.Windows.Media; using System.Collections.Generic; using System.Windows.Media.Media3D; +//using JetBrains.Annotations; namespace iNKORE.UI.WPF.DragDrop.Utilities { diff --git a/source/iNKORE.UI.WPF/iNKORE.UI.WPF.csproj b/source/iNKORE.UI.WPF/iNKORE.UI.WPF.csproj index 9151b48..c649c73 100644 --- a/source/iNKORE.UI.WPF/iNKORE.UI.WPF.csproj +++ b/source/iNKORE.UI.WPF/iNKORE.UI.WPF.csproj @@ -26,6 +26,13 @@ + + + + + + + @@ -35,6 +42,10 @@ + + + +