完成退出线布局算法

This commit is contained in:
zengwenjie
2025-09-17 10:00:46 +08:00
parent d7149a570d
commit 0f616421ec
4 changed files with 49 additions and 32 deletions

View File

@@ -554,33 +554,28 @@ namespace Deedy.Activity
this.IsSelectable = true; this.IsSelectable = true;
} }
if (newValue is ICombinedElement newCombinedElement) if (newValue is ICombinedElement newCombined)
{ {
this.IsExpandable = true; this.IsExpandable = true;
this.ElementCount = newCombinedElement.Elements.Count; this.ElementCount = newCombined.Elements.Count;
newCombinedElement.Elements.CollectionChanged += Elements_CollectionChanged; newCombined.Elements.CollectionChanged += Elements_CollectionChanged;
} }
else this.IsExpandable = false; else this.IsExpandable = false;
if (newValue is ICriticalZoneManageable criticalZoneManageable) if (newValue is ICriticalZoneManageable criticalZone)
{ {
if (criticalZoneManageable.IsLeaveZoneHidden) this.ShowLeaveZone = Visibility.Collapsed; if (criticalZone.IsLeaveZoneHidden) this.ShowLeaveZone = Visibility.Collapsed;
if (criticalZoneManageable.IsEntryZoneHidden) this.ShowEntryZone = Visibility.Collapsed; if (criticalZone.IsEntryZoneHidden) this.ShowEntryZone = Visibility.Collapsed;
} }
if (newValue is IExitlineManageable exitlinemanageable) if (newValue is IContainerWithExitline withExitline)
{ {
if ((exitlinemanageable.ExitlinePosition & ExitlinePosition.LeftLower) == ExitlinePosition.LeftLower) if (withExitline.ExitlinePosition.HasFlag(ExitlinePosition.LeftLower))
this.ShowLeftExitline = Visibility.Visible; this.ShowLeftExitline = Visibility.Visible;
else if ((exitlinemanageable.ExitlinePosition & ExitlinePosition.Rightlower) == ExitlinePosition.Rightlower) if (withExitline.ExitlinePosition.HasFlag(ExitlinePosition.Rightlower))
this.ShowRightExitline = Visibility.Visible; this.ShowRightExitline = Visibility.Visible;
else if ((exitlinemanageable.ExitlinePosition & ExitlinePosition.Underline) == ExitlinePosition.Underline) // 新元素被托管渲染后调整子元素退出线位置
{ withExitline.AdjustExitlinePosition();
this.ShowLeftExitline = Visibility.Visible;
this.ShowRightExitline = Visibility.Visible;
}
this.ActionElement.AdjustExitlinePosition();
} }
if (newValue is ILogicController logicController) if (newValue is ILogicController logicController)
{ {
@@ -591,8 +586,7 @@ namespace Deedy.Activity
case LogicalBehavior.Break: this.ShowBreakHandle = Visibility.Visible; break; case LogicalBehavior.Break: this.ShowBreakHandle = Visibility.Visible; break;
case LogicalBehavior.Continue: this.ShowContinueHandle = Visibility.Visible; break; case LogicalBehavior.Continue: this.ShowContinueHandle = Visibility.Visible; break;
case LogicalBehavior.Customize: this.ShowCustomizeHandle = Visibility.Visible; break; case LogicalBehavior.Customize: this.ShowCustomizeHandle = Visibility.Visible; break;
default: default: break;
break;
} }
} }
//TODO根据节点的特征与当前工作状态来判定如何处理当前视图的属性 //TODO根据节点的特征与当前工作状态来判定如何处理当前视图的属性
@@ -607,6 +601,8 @@ namespace Deedy.Activity
this.IsExpanded = true; this.IsExpanded = true;
this.ElementCount = combined.Elements.Count; this.ElementCount = combined.Elements.Count;
} }
// 节点集合变更时调整退出线位置
if (this.ActionElement is IContainerWithExitline container) container.AdjustExitlinePosition();
} }
protected virtual void ActionElement_PropertyChanged(object? sender, PropertyChangedEventArgs e) protected virtual void ActionElement_PropertyChanged(object? sender, PropertyChangedEventArgs e)
@@ -617,8 +613,9 @@ namespace Deedy.Activity
case nameof(IActionElement.InstantInfo): case nameof(IActionElement.InstantInfo):
this.InstantInfo = this.ActionElement.InstantInfo; this.InstantInfo = this.ActionElement.InstantInfo;
break; break;
case nameof(IExitlineManageable): case nameof(IContainerWithExitline.ExitlinePosition):
this.ActionElement.AdjustExitlinePosition(); // 自身退出线变更时调整所有子节点退出线位置
(this.ActionElement as IContainerWithExitline)?.AdjustExitlinePosition();
break; break;
default: break; default: break;
} }

View File

@@ -17,6 +17,14 @@ namespace Deedy.Activity
if (index < this.Elements.Count) this.Elements.Insert((int)index, element); if (index < this.Elements.Count) this.Elements.Insert((int)index, element);
if (index >= this.Elements.Count) this.Elements.Add(element); if (index >= this.Elements.Count) this.Elements.Add(element);
} }
public void MoveTo(IElement element, uint index)
{
if (element == null) return;
int newIndex = (index >= this.Elements.Count) ? this.Elements.Count - 1 : (int)index;
int oldIndex = this.Elements.IndexOf(element);
if (oldIndex < 0) this.Elements.Insert(newIndex, element);
else this.Elements.Move(oldIndex, newIndex);
}
/// <summary> /// <summary>
/// 如果类型上没有组装规则,则认为不允许组装,否则按照组装规则处理 /// 如果类型上没有组装规则,则认为不允许组装,否则按照组装规则处理
/// </summary> /// </summary>

View File

@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Deedy.Activity namespace Deedy.Activity
{ {
public interface IExitlineManageable public interface IContainerWithExitline : IContainerElement, IActionElement
{ {
ExitlinePosition ExitlinePosition { get; set; } ExitlinePosition ExitlinePosition { get; set; }
bool? IsExitlineAtSamePosition { get; set; } bool? IsExitlineAtSamePosition { get; set; }

View File

@@ -212,20 +212,32 @@ namespace Deedy.Activity
return default; return default;
} }
public static void AdjustExitlinePosition(this IActionElement element) public static void AdjustExitlinePosition(this IContainerWithExitline container)
{ {
if (element is IExitlineManageable exitlineManageable if (container != null
&& (exitlineManageable.ExitlinePosition == ExitlinePosition.LeftLower && (container.ExitlinePosition == ExitlinePosition.LeftLower
|| exitlineManageable.ExitlinePosition == ExitlinePosition.Rightlower)) || container.ExitlinePosition == ExitlinePosition.Rightlower))
{ {
//TODO根据退出线方向是否相同的设置项调整子节点的退出线位置 var lastChild = container.Elements[container.Elements.Count - 1] as IContainerWithExitline;
if (exitlineManageable.IsExitlineAtSamePosition == true) if (lastChild != null
&& (lastChild.ExitlinePosition == ExitlinePosition.LeftLower
|| lastChild.ExitlinePosition == ExitlinePosition.Rightlower))
{ {
//TODO同向退出线控制 if (container.IsExitlineAtSamePosition == true)
}
if (exitlineManageable.IsExitlineAtSamePosition == false)
{ {
//TODO对向退出线控制 if (container.ExitlinePosition == ExitlinePosition.LeftLower)
lastChild.ExitlinePosition = ExitlinePosition.LeftLower;
if (container.ExitlinePosition == ExitlinePosition.Rightlower)
lastChild.ExitlinePosition = ExitlinePosition.Rightlower;
}
if (container.IsExitlineAtSamePosition == false)
{
if (container.ExitlinePosition == ExitlinePosition.LeftLower)
lastChild.ExitlinePosition = ExitlinePosition.LeftLower;
if (container.ExitlinePosition == ExitlinePosition.Rightlower)
lastChild.ExitlinePosition = ExitlinePosition.Rightlower;
}
//lastChild.AdjustExitlinePosition();
} }
} }
} }