完善ReadyTo的逻辑设计,代码尚未编写
This commit is contained in:
@@ -618,7 +618,7 @@ namespace Deedy.Activity
|
||||
if (withExitline.ExitlinePosition.HasFlag(ExitlinePosition.Rightlower))
|
||||
this.ShowRightExitline = Visibility.Visible;
|
||||
// 新元素被托管渲染后调整子元素退出线位置
|
||||
withExitline.Help_AdjustExitlinePosition();
|
||||
withExitline.Help_ExitlinePositionAdjust();
|
||||
}
|
||||
|
||||
if (newValue is ILogicController logicController)
|
||||
@@ -646,7 +646,7 @@ namespace Deedy.Activity
|
||||
this.ElementCount = combined.Elements.Count;
|
||||
}
|
||||
// 节点集合变更时调整退出线位置
|
||||
if (this.ActionElement is IContainerWithExitline container) container.Help_AdjustExitlinePosition();
|
||||
if (this.ActionElement is IContainerWithExitline container) container.Help_ExitlinePositionAdjust();
|
||||
}
|
||||
|
||||
protected virtual void ActionElement_PropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
@@ -662,7 +662,7 @@ namespace Deedy.Activity
|
||||
break;
|
||||
case nameof(IContainerWithExitline.ExitlinePosition):
|
||||
// 自身退出线变更时调整所有子节点退出线位置
|
||||
(this.ActionElement as IContainerWithExitline)?.Help_AdjustExitlinePosition();
|
||||
(this.ActionElement as IContainerWithExitline)?.Help_ExitlinePositionAdjust();
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
@@ -91,5 +91,25 @@ namespace Deedy.Activity
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void LinkTo([AllowNull] IElement element)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Unlink()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IElement? Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool TryEncode(out string document)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
@@ -103,5 +104,25 @@ namespace Deedy.Activity
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void LinkTo([AllowNull] IElement element)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Unlink()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IElement? Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool TryEncode(out string document)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,13 +228,12 @@ namespace Deedy.Activity
|
||||
public static void Help_RemoveFromParent(this IElement element)
|
||||
{
|
||||
if (element != null && element.ParentElement is IContainerElement container) container.Remove(element);
|
||||
//TODO:将当前节点从自身的父级节点中移除
|
||||
}
|
||||
/// <summary>
|
||||
/// 调整子节点的退出线位置
|
||||
/// </summary>
|
||||
/// <param name="container">要调整的带退出线容器</param>
|
||||
public static void Help_AdjustExitlinePosition(this IContainerWithExitline container)
|
||||
public static void Help_ExitlinePositionAdjust(this IContainerWithExitline container)
|
||||
{
|
||||
if (container != null
|
||||
&& (container.ExitlinePosition == ExitlinePosition.LeftLower
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace Deedy.Activity
|
||||
{
|
||||
@@ -134,5 +136,106 @@ namespace Deedy.Activity
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 构建结构树,设置层级:并且完成参数映射的刷新
|
||||
/// </summary>
|
||||
/// <param name="parent">父级元素</param>
|
||||
public static void Help_Element_ReadyToWorking(this IElement @this, IElement? parent = null, Output? output = null)
|
||||
{
|
||||
@this.LinkTo(parent);
|
||||
if (@this is ICombinedElement combined)
|
||||
{
|
||||
combined.Help_CombineElements();
|
||||
foreach (IElement subElement in combined.Elements)
|
||||
subElement.ReadyToWorking(@this);
|
||||
}
|
||||
}
|
||||
public static void Help_Element_ReadyToEditing(this IElement @this, Runtime runtime)
|
||||
{
|
||||
if (@this is null) return;
|
||||
@this.SetNamedPropertyValue<Runtime?>(nameof(IActivity.Runtime), runtime);
|
||||
if (@this is ICombinedElement combined)
|
||||
{
|
||||
combined.Help_BuildParamMapping();
|
||||
foreach (var subElement in combined.Elements)
|
||||
subElement.ReadyToEditing(runtime);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 将当前节点链接到一个节点上
|
||||
/// </summary>
|
||||
/// <param name="element">要链接到的节点</param>
|
||||
public static void LinkTo(this IElement @this, [AllowNull] IElement element)
|
||||
{
|
||||
if (@this == null) return;
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
@this.Unlink();
|
||||
return;
|
||||
}
|
||||
if (@this.ParentElement != null)
|
||||
{
|
||||
if (@this.ParentElement == element) return;
|
||||
else
|
||||
{
|
||||
if (@this.ParentElement is IContainerElement container)
|
||||
{
|
||||
//this.SetNamedPropertyValue(nameof(ParentElement), element);
|
||||
@this.Help_Setter_ParentElement(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//this.SetNamedPropertyValue(nameof(ParentElement), element);
|
||||
@this.Help_Setter_ParentElement(element);
|
||||
}
|
||||
//this.SetNamedPropertyValue(nameof(DepthLevel), (this.ParentElement?.DepthLevel ?? 0) + 1);
|
||||
@this.Help_Setter_DepthLevel((@this.ParentElement?.DepthLevel ?? 0) + 1);
|
||||
}
|
||||
/// <summary>
|
||||
/// 断开自身与父级节点的链接关系
|
||||
/// </summary>
|
||||
public static void Unlink(this IElement @this)
|
||||
{
|
||||
if (@this == null) return;
|
||||
|
||||
//this.SetNamedPropertyValue<IElement?>(nameof(ParentElement), null);
|
||||
@this.Help_Setter_ParentElement(null);
|
||||
//this.SetNamedPropertyValue(nameof(DepthLevel), 0);
|
||||
@this.Help_Setter_DepthLevel(0);
|
||||
}
|
||||
/// <summary>
|
||||
/// 克隆一个「IElement」节点
|
||||
/// </summary>
|
||||
/// <param name="this">要复制的节点</param>
|
||||
/// <returns>如果复制失败则返回「null」</returns>
|
||||
public static IElement? Clone(this IElement @this)
|
||||
{
|
||||
if (@this == null) return null;
|
||||
try
|
||||
{
|
||||
return XamlReader.Parse(XamlWriter.Save(@this)) as IElement;
|
||||
}
|
||||
catch { return null; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 尝试将一个「IElement」元素序列化为一个字符串形式档案
|
||||
/// </summary>
|
||||
/// <param name="this">要序列化的元素</param>
|
||||
/// <param name="document">序列化后的文本文档</param>
|
||||
/// <returns>如果出错则返回「Flase」</returns>
|
||||
public static bool TryEncode(this IElement @this, out string document)
|
||||
{
|
||||
bool result = false;
|
||||
try
|
||||
{
|
||||
document = XamlWriter.Save(@this);
|
||||
result = true;
|
||||
}
|
||||
catch { document = string.Empty; }
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Deedy.Activity
|
||||
public interface IActivity
|
||||
{
|
||||
public Runtime? Runtime { get; }
|
||||
public void ReadyToWorking(IElement? element = null, Output? output = null);
|
||||
public void ReadyToWorking(IElement? parent = null, Output? output = null);
|
||||
public void ReadyToEditing(Runtime runtime);
|
||||
public void ReadyToRunning(Runtime runtime);
|
||||
public WorkMode WorkMode => Runtime?.WorkMode ?? WorkMode.Waiting;
|
||||
|
||||
@@ -10,6 +10,14 @@ using System.Windows.Markup;
|
||||
|
||||
namespace Deedy.Activity
|
||||
{
|
||||
/// <summary>
|
||||
/// 所有可「设计」元素的公共接口
|
||||
/// <para>注意:</para>
|
||||
/// <para>「LinkTo」与「Unlink」方法只处理父子级关系映射,不处理「Elements」集合的添加与删除...</para>
|
||||
/// <para>「ReadyToWorking」方法会先进行「LinkTo」再进行「CombineElements」操作...</para>
|
||||
/// <para>「ReadyToEditing」方法会迭代进行「BuildParamMapping」操作...</para>
|
||||
/// <para>「ReadyToRunning」方法会迭代进行「CheckLogicConfigs」操作...</para>
|
||||
/// </summary>
|
||||
public interface IElement : IActivity, INotifyPropertyChanged
|
||||
{
|
||||
public string Class { get; }
|
||||
@@ -25,80 +33,13 @@ namespace Deedy.Activity
|
||||
/// 将当前节点链接到一个节点上
|
||||
/// </summary>
|
||||
/// <param name="element">要链接到的节点</param>
|
||||
public virtual void LinkTo([AllowNull] IElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
this.Unlink();
|
||||
return;
|
||||
}
|
||||
if (this.ParentElement != null)
|
||||
{
|
||||
if (this.ParentElement == element) return;
|
||||
else
|
||||
{
|
||||
if (this.ParentElement is IContainerElement container)
|
||||
{
|
||||
container.Remove(this);
|
||||
container.Append(this);
|
||||
//this.SetNamedPropertyValue(nameof(ParentElement), element);
|
||||
this.Help_Setter_ParentElement(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//this.SetNamedPropertyValue(nameof(ParentElement), element);
|
||||
this.Help_Setter_ParentElement(element);
|
||||
}
|
||||
//this.SetNamedPropertyValue(nameof(DepthLevel), (this.ParentElement?.DepthLevel ?? 0) + 1);
|
||||
this.Help_Setter_DepthLevel((this.ParentElement?.DepthLevel ?? 0) + 1);
|
||||
}
|
||||
public void LinkTo([AllowNull] IElement element);
|
||||
/// <summary>
|
||||
/// 断开自身与父级节点的链接关系
|
||||
/// </summary>
|
||||
public virtual void Unlink()
|
||||
{
|
||||
(this.ParentElement as IContainerElement)?.Remove(this);
|
||||
//this.SetNamedPropertyValue<IElement?>(nameof(ParentElement), null);
|
||||
this.Help_Setter_ParentElement(null);
|
||||
//this.SetNamedPropertyValue(nameof(DepthLevel), 0);
|
||||
this.Help_Setter_DepthLevel(0);
|
||||
}
|
||||
/// <summary>
|
||||
/// 构建结构树,设置层级:并且完成参数映射的刷新
|
||||
/// </summary>
|
||||
/// <param name="parent"></param>
|
||||
public new void ReadyToWorking(IElement? element = null, Output? output = null)
|
||||
{
|
||||
this.Help_BuildParamMapping(output);
|
||||
if (element is ICombinedElement combinedElement)
|
||||
combinedElement.Help_CombineElements();
|
||||
|
||||
this.LinkTo(element);
|
||||
if (this is ICombinedElement combined)
|
||||
foreach (IElement subElement in combined.Elements)
|
||||
subElement.ReadyToWorking(this);
|
||||
}
|
||||
public virtual IElement? Clone()
|
||||
{
|
||||
try
|
||||
{
|
||||
return XamlReader.Parse(XamlWriter.Save(this)) as IElement;
|
||||
}
|
||||
catch { return null; }
|
||||
}
|
||||
public virtual bool TryEncode(out string document)
|
||||
{
|
||||
bool result = false;
|
||||
try
|
||||
{
|
||||
document = XamlWriter.Save(this);
|
||||
result = true;
|
||||
}
|
||||
catch { document = string.Empty; }
|
||||
return result;
|
||||
}
|
||||
public void Unlink();
|
||||
public IElement? Clone();
|
||||
public bool TryEncode(out string document);
|
||||
public static virtual bool TryDecode(string document, out IElement? element)
|
||||
{
|
||||
IElement? instance = null;
|
||||
|
||||
Reference in New Issue
Block a user