mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-09 02:36:35 +08:00
block
This commit is contained in:
39
AIStudio.Wpf.DiagramDesigner/Models/Values/ConstParameter.cs
Normal file
39
AIStudio.Wpf.DiagramDesigner/Models/Values/ConstParameter.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class ConstParameter : BindableBase, IParameter
|
||||
{
|
||||
private object _value;
|
||||
|
||||
public object Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _value, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(object value)
|
||||
{
|
||||
if (double.TryParse(Value?.ToString() ?? "", out var value1) && double.TryParse(value?.ToString() ?? "", out var value2))
|
||||
{
|
||||
Value = value1 + value2;
|
||||
}
|
||||
else
|
||||
{
|
||||
Value = $"{Value}{value}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
18
AIStudio.Wpf.DiagramDesigner/Models/Values/IParameter.cs
Normal file
18
AIStudio.Wpf.DiagramDesigner/Models/Values/IParameter.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public interface IParameter
|
||||
{
|
||||
object Value
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
void Add(object value);
|
||||
}
|
||||
}
|
||||
10
AIStudio.Wpf.DiagramDesigner/Models/Values/VarParameter.cs
Normal file
10
AIStudio.Wpf.DiagramDesigner/Models/Values/VarParameter.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class VarParameter : ConstParameter
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -176,7 +176,20 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
SetProperty(ref _actualItemHeight, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IParameter _parameter;
|
||||
public IParameter Parameter
|
||||
{
|
||||
get
|
||||
{
|
||||
return _parameter;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _parameter, value);
|
||||
}
|
||||
}
|
||||
|
||||
private ObservableCollection<BlockDesignerItemViewModel> _children = new ObservableCollection<BlockDesignerItemViewModel>();
|
||||
public ObservableCollection<BlockDesignerItemViewModel> Children
|
||||
@@ -322,7 +335,14 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
if (OnlyOneChild)
|
||||
{
|
||||
return Children.FirstOrDefault()?.GetResult();
|
||||
if (Children?.Count == 1)
|
||||
{
|
||||
return Children.FirstOrDefault()?.GetResult();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Parameter?.Value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
||||
using AIStudio.Wpf.DiagramDesigner.Models;
|
||||
@@ -248,6 +249,19 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isExecuting;
|
||||
public bool IsExecuting
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isExecuting;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _isExecuting, value);
|
||||
}
|
||||
}
|
||||
|
||||
public string Flag
|
||||
{
|
||||
get; set;
|
||||
@@ -409,11 +423,29 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
|
||||
#region 执行
|
||||
public virtual void Execute()
|
||||
public void Execute()
|
||||
{
|
||||
BeforeExecute();
|
||||
Executing();
|
||||
AfterExecute();
|
||||
}
|
||||
|
||||
public virtual void BeforeExecute()
|
||||
{
|
||||
IsExecuting = true;
|
||||
}
|
||||
|
||||
public virtual void Executing()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void AfterExecute()
|
||||
{
|
||||
IsExecuting = false;
|
||||
Next?.Execute();
|
||||
}
|
||||
|
||||
public virtual object GetResult()
|
||||
{
|
||||
if (FirstContainer != null)
|
||||
|
||||
Reference in New Issue
Block a user