From 7692bb93987c48d076077fd6cdf157da36641793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=89=BE=E7=AB=B9?= Date: Sat, 19 Aug 2023 21:46:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E6=AD=A5=E6=89=A7=E8=A1=8C=E5=92=8C?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BlockDesignerItemViewModel.cs | 86 +++++++++++++------ 1 file changed, 62 insertions(+), 24 deletions(-) diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BlockViewModel/BlockDesignerItemViewModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BlockViewModel/BlockDesignerItemViewModel.cs index 28feb98..efb7a0a 100644 --- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BlockViewModel/BlockDesignerItemViewModel.cs +++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BlockViewModel/BlockDesignerItemViewModel.cs @@ -257,8 +257,7 @@ namespace AIStudio.Wpf.DiagramDesigner if (oldchildren != null) { this.RemoveChild(oldchildren, container); - } - Root.Items.Remove(child); + } if (child.LinkNode?.Previous != null) { child.LinkNode.Previous.Value.RemoveNext(); @@ -268,6 +267,7 @@ namespace AIStudio.Wpf.DiagramDesigner child.LinkNode.Next.Value.RemovePrevious(); } container.InsertChild(child, index); + Root.Items.Remove(child); } else { @@ -283,9 +283,9 @@ namespace AIStudio.Wpf.DiagramDesigner items = child.LinkNode.Value.RemoveSelf(true); } - items.ForEach(p => { - Root.Items.Remove(p); + items.ForEach(p => { container.InsertChild(p, index++); + Root.Items.Remove(p); }); } @@ -317,16 +317,16 @@ namespace AIStudio.Wpf.DiagramDesigner })); } - private int _isExecuting; - public int ExecutStatus + private ExecutStatus _executStatus; + public ExecutStatus ExecutStatus { get { - return _isExecuting; + return _executStatus; } set { - SetProperty(ref _isExecuting, value); + SetProperty(ref _executStatus, value); } } @@ -369,6 +369,52 @@ namespace AIStudio.Wpf.DiagramDesigner } } + public BlockDesignerItemViewModel Next + { + get + { + if (ParentContainer != null) + { + var index = ParentContainer.Children.IndexOf(this); + if (index + 1 < ParentContainer.Children.Count) + { + return ParentContainer.Children[index + 1]; + } + else + { + return null; + } + } + else + { + return LinkNode.Next?.Value; + } + } + } + + public BlockDesignerItemViewModel Previous + { + get + { + if (ParentContainer != null) + { + var index = ParentContainer.Children.IndexOf(this); + if (index - 1 >= 0) + { + return ParentContainer.Children[index - 1]; + } + else + { + return null; + } + } + else + { + return LinkNode.Previous?.Value; + } + } + } + public BlockItemsContainerInfo ParentContainer { get; set; @@ -447,30 +493,25 @@ namespace AIStudio.Wpf.DiagramDesigner } } - #region 执行 - protected override async void ExecuteEditCommand(object param) - { - await this.LinkNode.List.First.Value.Execute(); - } - + #region 执行 public override void PreviewExecuteEdit() { var items = this.LinkNode.List.ToList(); - items.ForEach(p => p.ExecutStatus = 1); + items.ForEach(p => p.ExecutStatus = ExecutStatus.Preview); } public override void ExitPreviewExecuteEdit() { var items = this.LinkNode.List.ToList(); - items.ForEach(p => p.ExecutStatus = 0); + items.ForEach(p => p.ExecutStatus = ExecutStatus.Stop); } - public virtual Task Execute() + public virtual Task Execute() { - return Task.CompletedTask; - } + return Task.FromResult(true); + } public virtual object GetResult() { @@ -603,14 +644,11 @@ namespace AIStudio.Wpf.DiagramDesigner } #endregion - [FlagsAttribute] public enum ExecutStatus { Stop, Run, - PauseCommand, - ContinueCommand, - StopCommand, - + Pause, + Preview, } }