完成退出线布局算法
This commit is contained in:
@@ -554,33 +554,28 @@ namespace Deedy.Activity
|
||||
this.IsSelectable = true;
|
||||
}
|
||||
|
||||
if (newValue is ICombinedElement newCombinedElement)
|
||||
if (newValue is ICombinedElement newCombined)
|
||||
{
|
||||
this.IsExpandable = true;
|
||||
this.ElementCount = newCombinedElement.Elements.Count;
|
||||
newCombinedElement.Elements.CollectionChanged += Elements_CollectionChanged;
|
||||
this.ElementCount = newCombined.Elements.Count;
|
||||
newCombined.Elements.CollectionChanged += Elements_CollectionChanged;
|
||||
}
|
||||
else this.IsExpandable = false;
|
||||
|
||||
if (newValue is ICriticalZoneManageable criticalZoneManageable)
|
||||
if (newValue is ICriticalZoneManageable criticalZone)
|
||||
{
|
||||
if (criticalZoneManageable.IsLeaveZoneHidden) this.ShowLeaveZone = Visibility.Collapsed;
|
||||
if (criticalZoneManageable.IsEntryZoneHidden) this.ShowEntryZone = Visibility.Collapsed;
|
||||
if (criticalZone.IsLeaveZoneHidden) this.ShowLeaveZone = 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;
|
||||
else if ((exitlinemanageable.ExitlinePosition & ExitlinePosition.Rightlower) == ExitlinePosition.Rightlower)
|
||||
if (withExitline.ExitlinePosition.HasFlag(ExitlinePosition.Rightlower))
|
||||
this.ShowRightExitline = Visibility.Visible;
|
||||
else if ((exitlinemanageable.ExitlinePosition & ExitlinePosition.Underline) == ExitlinePosition.Underline)
|
||||
{
|
||||
this.ShowLeftExitline = Visibility.Visible;
|
||||
this.ShowRightExitline = Visibility.Visible;
|
||||
}
|
||||
|
||||
this.ActionElement.AdjustExitlinePosition();
|
||||
// 新元素被托管渲染后调整子元素退出线位置
|
||||
withExitline.AdjustExitlinePosition();
|
||||
}
|
||||
if (newValue is ILogicController logicController)
|
||||
{
|
||||
@@ -591,8 +586,7 @@ namespace Deedy.Activity
|
||||
case LogicalBehavior.Break: this.ShowBreakHandle = Visibility.Visible; break;
|
||||
case LogicalBehavior.Continue: this.ShowContinueHandle = Visibility.Visible; break;
|
||||
case LogicalBehavior.Customize: this.ShowCustomizeHandle = Visibility.Visible; break;
|
||||
default:
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
//TODO:根据节点的特征与当前工作状态来判定如何处理当前视图的属性
|
||||
@@ -607,6 +601,8 @@ namespace Deedy.Activity
|
||||
this.IsExpanded = true;
|
||||
this.ElementCount = combined.Elements.Count;
|
||||
}
|
||||
// 节点集合变更时调整退出线位置
|
||||
if (this.ActionElement is IContainerWithExitline container) container.AdjustExitlinePosition();
|
||||
}
|
||||
|
||||
protected virtual void ActionElement_PropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
@@ -617,8 +613,9 @@ namespace Deedy.Activity
|
||||
case nameof(IActionElement.InstantInfo):
|
||||
this.InstantInfo = this.ActionElement.InstantInfo;
|
||||
break;
|
||||
case nameof(IExitlineManageable):
|
||||
this.ActionElement.AdjustExitlinePosition();
|
||||
case nameof(IContainerWithExitline.ExitlinePosition):
|
||||
// 自身退出线变更时调整所有子节点退出线位置
|
||||
(this.ActionElement as IContainerWithExitline)?.AdjustExitlinePosition();
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
@@ -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.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>
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Deedy.Activity
|
||||
{
|
||||
public interface IExitlineManageable
|
||||
public interface IContainerWithExitline : IContainerElement, IActionElement
|
||||
{
|
||||
ExitlinePosition ExitlinePosition { get; set; }
|
||||
bool? IsExitlineAtSamePosition { get; set; }
|
||||
@@ -212,20 +212,32 @@ namespace Deedy.Activity
|
||||
|
||||
return default;
|
||||
}
|
||||
public static void AdjustExitlinePosition(this IActionElement element)
|
||||
public static void AdjustExitlinePosition(this IContainerWithExitline container)
|
||||
{
|
||||
if (element is IExitlineManageable exitlineManageable
|
||||
&& (exitlineManageable.ExitlinePosition == ExitlinePosition.LeftLower
|
||||
|| exitlineManageable.ExitlinePosition == ExitlinePosition.Rightlower))
|
||||
if (container != null
|
||||
&& (container.ExitlinePosition == ExitlinePosition.LeftLower
|
||||
|| container.ExitlinePosition == ExitlinePosition.Rightlower))
|
||||
{
|
||||
//TODO:根据退出线方向是否相同的设置项调整子节点的退出线位置
|
||||
if (exitlineManageable.IsExitlineAtSamePosition == true)
|
||||
var lastChild = container.Elements[container.Elements.Count - 1] as IContainerWithExitline;
|
||||
if (lastChild != null
|
||||
&& (lastChild.ExitlinePosition == ExitlinePosition.LeftLower
|
||||
|| lastChild.ExitlinePosition == ExitlinePosition.Rightlower))
|
||||
{
|
||||
//TODO:同向退出线控制
|
||||
if (container.IsExitlineAtSamePosition == true)
|
||||
{
|
||||
if (container.ExitlinePosition == ExitlinePosition.LeftLower)
|
||||
lastChild.ExitlinePosition = ExitlinePosition.LeftLower;
|
||||
if (container.ExitlinePosition == ExitlinePosition.Rightlower)
|
||||
lastChild.ExitlinePosition = ExitlinePosition.Rightlower;
|
||||
}
|
||||
if (exitlineManageable.IsExitlineAtSamePosition == false)
|
||||
if (container.IsExitlineAtSamePosition == false)
|
||||
{
|
||||
//TODO:对向退出线控制
|
||||
if (container.ExitlinePosition == ExitlinePosition.LeftLower)
|
||||
lastChild.ExitlinePosition = ExitlinePosition.LeftLower;
|
||||
if (container.ExitlinePosition == ExitlinePosition.Rightlower)
|
||||
lastChild.ExitlinePosition = ExitlinePosition.Rightlower;
|
||||
}
|
||||
//lastChild.AdjustExitlinePosition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user