#0023 整理项目结构
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Prism.Ioc;
|
||||
using Telerik.Windows.DragDrop;
|
||||
using XplorePlane.ViewModels;
|
||||
|
||||
namespace XplorePlane.Views
|
||||
{
|
||||
public partial class PipelineEditorView : UserControl
|
||||
{
|
||||
private const string DragFormat = "OperatorDescriptor";
|
||||
|
||||
public PipelineEditorView()
|
||||
{
|
||||
InitializeComponent();
|
||||
Loaded += OnLoaded;
|
||||
}
|
||||
|
||||
private void OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext == null)
|
||||
DataContext = ContainerLocator.Container.Resolve<PipelineEditorViewModel>();
|
||||
|
||||
// 启用拖拽目标 + 注册 Drop 事件
|
||||
PipelineListBox.AllowDrop = true;
|
||||
DragDropManager.AddDropHandler(PipelineListBox, OnOperatorDropped, true);
|
||||
}
|
||||
|
||||
private void OnOperatorDropped(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
|
||||
{
|
||||
if (DataContext is not PipelineEditorViewModel vm) return;
|
||||
|
||||
var descriptor = DragDropPayloadManager.GetDataFromObject(e.Data, DragFormat) as OperatorDescriptor;
|
||||
if (descriptor == null) return;
|
||||
|
||||
vm.AddOperatorCommand.Execute(descriptor.Key);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user