#0024 修复浮动工具箱
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Prism.Ioc;
|
||||
using Telerik.Windows.DragDrop;
|
||||
using Serilog;
|
||||
using XplorePlane.ViewModels;
|
||||
|
||||
namespace XplorePlane.Views
|
||||
{
|
||||
public partial class PipelineEditorView : UserControl
|
||||
{
|
||||
private const string DragFormat = "OperatorDescriptor";
|
||||
|
||||
public PipelineEditorView()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -21,19 +19,47 @@ namespace XplorePlane.Views
|
||||
if (DataContext == null)
|
||||
DataContext = ContainerLocator.Container.Resolve<PipelineEditorViewModel>();
|
||||
|
||||
// 启用拖拽目标 + 注册 Drop 事件
|
||||
PipelineListBox.AllowDrop = true;
|
||||
DragDropManager.AddDropHandler(PipelineListBox, OnOperatorDropped, true);
|
||||
PipelineListBox.Drop += OnOperatorDropped;
|
||||
PipelineListBox.DragOver += OnDragOver;
|
||||
Log.Debug("PipelineEditorView 原生 Drop 目标已注册");
|
||||
}
|
||||
|
||||
private void OnOperatorDropped(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
|
||||
private void OnDragOver(object sender, DragEventArgs e)
|
||||
{
|
||||
if (DataContext is not PipelineEditorViewModel vm) return;
|
||||
if (e.Data.GetDataPresent(OperatorToolboxView.DragFormat))
|
||||
e.Effects = DragDropEffects.Copy;
|
||||
else
|
||||
e.Effects = DragDropEffects.None;
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
var descriptor = DragDropPayloadManager.GetDataFromObject(e.Data, DragFormat) as OperatorDescriptor;
|
||||
if (descriptor == null) return;
|
||||
private void OnOperatorDropped(object sender, DragEventArgs e)
|
||||
{
|
||||
if (DataContext is not PipelineEditorViewModel vm)
|
||||
{
|
||||
Log.Warning("Drop 事件触发但 DataContext 不是 PipelineEditorViewModel");
|
||||
return;
|
||||
}
|
||||
|
||||
vm.AddOperatorCommand.Execute(descriptor.Key);
|
||||
if (!e.Data.GetDataPresent(OperatorToolboxView.DragFormat))
|
||||
{
|
||||
Log.Warning("Drop 事件触发但数据中无 {Format}", OperatorToolboxView.DragFormat);
|
||||
return;
|
||||
}
|
||||
|
||||
var operatorKey = e.Data.GetData(OperatorToolboxView.DragFormat) as string;
|
||||
if (string.IsNullOrEmpty(operatorKey))
|
||||
{
|
||||
Log.Warning("Drop 事件触发但 OperatorKey 为空");
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Information("算子已放入流水线:{OperatorKey},VM HashCode={Hash},当前节点数(执行前)={Count}",
|
||||
operatorKey, vm.GetHashCode(), vm.PipelineNodes.Count);
|
||||
vm.AddOperatorCommand.Execute(operatorKey);
|
||||
Log.Information("AddOperator 执行后节点数={Count},PipelineListBox.Items.Count={ItemsCount}",
|
||||
vm.PipelineNodes.Count, PipelineListBox.Items.Count);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user