mirror of
https://github.com/egmont11/NetworkDiagram.git
synced 2026-07-24 07:09:43 +02:00
Fixed an issue where if you dragged a device to the screen, it used the last selected instead,
This commit is contained in:
@@ -75,9 +75,20 @@ namespace NetworkDiagram
|
|||||||
#region Drag and Drop (Toolbox to Canvas)
|
#region Drag and Drop (Toolbox to Canvas)
|
||||||
private void Toolbox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
|
private void Toolbox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is ListBox { SelectedItem: DeviceTemplate template } listBox)
|
if (sender is ListBox listBox)
|
||||||
|
{
|
||||||
|
// Find the item under the mouse instead of relying on SelectedItem
|
||||||
|
var element = e.OriginalSource as DependencyObject;
|
||||||
|
while (element != null && !(element is ListBoxItem))
|
||||||
|
element = VisualTreeHelper.GetParent(element);
|
||||||
|
|
||||||
|
if (element is ListBoxItem item && item.Content is DeviceTemplate template)
|
||||||
|
{
|
||||||
DragDrop.DoDragDrop(listBox, template, DragDropEffects.Copy);
|
DragDrop.DoDragDrop(listBox, template, DragDropEffects.Copy);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void DiagramCanvas_DragOver(object sender, DragEventArgs e)
|
private void DiagramCanvas_DragOver(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user