From 9d1660270272180cd71147d6ddd53d1382643d2e Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 02 十一月 2026 18:00:14 +0800
Subject: [PATCH] merge: 并入远程 Initial commit 作为历史根节点
---
Plugin.SeqEditor/ViewModel/StepDropHandler.cs | 139 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 139 insertions(+), 0 deletions(-)
diff --git a/Plugin.SeqEditor/ViewModel/StepDropHandler.cs b/Plugin.SeqEditor/ViewModel/StepDropHandler.cs
new file mode 100644
index 0000000..6c39449
--- /dev/null
+++ b/Plugin.SeqEditor/ViewModel/StepDropHandler.cs
@@ -0,0 +1,139 @@
+锘縰sing GongSolutions.Wpf.DragDrop;
+using HMI.UI;
+using NationalInstruments.TestStand.Interop.API;
+using Plugin.SeqEditor.Entity;
+using System.Windows;
+
+namespace Plugin.SeqEditor.ViewModel
+{
+ public class StepDropHandler : DefaultDropHandler
+ {
+ private SeqEditorViewModel model;
+ public StepDropHandler(SeqEditorViewModel model)
+ {
+ this.model = model;
+ }
+
+ public bool CanConvert(IDropInfo dropInfo)
+ {
+ if (!(dropInfo.TargetItem is TreeItemData targetItem))
+ {
+ return false;
+ }
+
+ if (!(targetItem.Data is StepUI target))
+ {
+ return false;
+ }
+
+ if (!(dropInfo.Data is TreeItemData sourceItem))
+ {
+ return false;
+ }
+
+ if (!(sourceItem.Data is StepUI source))
+ {
+ return false;
+ }
+
+ if (targetItem.ParentItem != sourceItem.ParentItem)
+ {
+ return false;
+ }
+
+ if (source == target)
+ {
+ return false;
+ }
+
+ if (source.sequence != target.sequence)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public override void DragOver(IDropInfo dropInfo)
+ {
+ if (CanConvert(dropInfo))
+ {
+ dropInfo.Effects = DragDropEffects.Move;
+ dropInfo.DropTargetHintState = DropHintState.Active;
+ }
+ else
+ {
+ dropInfo.DropTargetHintState = DropHintState.None;
+ }
+ }
+
+ public override void Drop(IDropInfo dropInfo)
+ {
+ if (!CanConvert(dropInfo))
+ {
+ return;
+ }
+ var sourceItem = (TreeItemData)dropInfo.Data;
+ var targetItem = (TreeItemData)dropInfo.TargetItem;
+
+ var source = sourceItem.Data as StepUI;
+ var target = targetItem.Data as StepUI;
+ int sourceIndex = source.IndexInSequence;
+ int targetIndex = target.IndexInSequence;
+
+ TreeItemDataCollection collection = model.TreeCollection;
+
+ List<TreeItemData> datasource;
+
+ if (sourceItem.ParentItem == null)
+ {
+ datasource = collection.RootItems;
+ }
+ else
+ {
+ datasource = sourceItem.ParentItem.Items;
+ }
+
+ //ObservableCollection<TreeItemData> datasource =
+ // (ObservableCollection<TreeItemData>)dropInfo.TargetCollection.TryGetList();
+
+ int uiSourceIndex = collection.IndexOf(sourceItem);
+ int uiTargetIndex = collection.IndexOf(targetItem);
+
+ if (uiSourceIndex == uiTargetIndex + 1)
+ {
+ return;
+ }
+
+ StepGroups group = target.StepGroup;
+ if (sourceIndex == targetIndex) {
+ return;
+ }
+
+ if (sourceIndex < targetIndex)
+ {
+ source.sequence.DeleteStep(sourceIndex, source.StepGroup);
+ target.sequence.InsertStep(source.step, targetIndex, group);
+
+ collection.Move(uiSourceIndex, uiTargetIndex);
+
+ //datasource.RemoveAt(uiSourceIndex);
+ //datasource.Insert(uiTargetIndex, sourceItem);
+ }
+ else if (sourceIndex > targetIndex)
+ {
+ source.sequence.DeleteStep(sourceIndex, source.StepGroup);
+ target.sequence.InsertStep(source.step, targetIndex + 1, group);
+
+ collection.Move(uiSourceIndex, uiTargetIndex);
+ }
+ model.CurrentSeqUI.IsChanged = true;
+ //var task = Task.Run(() =>
+ //{
+ // collection.ResetItems();
+ // model.TreeItemData = sourceItem;
+ //});
+ //task.Wait();
+ }
+ }
+}
--
Gitblit v1.9.1