/// <summary> /// 新建连接线后的链路校验。 /// 缺省的检验是:如果形成闭合循环,则返回 false,否则返回 true /// </summary> protected virtual bool CheckValid(ItemLink link, CustomItemNode node) { if (NodeInPrevRouting(link, node)) { MessageBox.Show( "当前流程不支持闭合循环!", "链路错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } else { return(true); } }
/// <summary> /// 检查指定的结点是否是当前连接线的起始结点 /// </summary> protected virtual bool NodeInPrevRouting(ItemLink link, CustomItemNode node) { if (link.ItemFrom == node) { return(true); } else { foreach (ItemLink prevLink in link.ItemFrom.PrevLinks) { if (NodeInPrevRouting(prevLink, node)) { return(true); } } } return(false); }
protected virtual void AfterSetItemTo(CustomItemNode item) { if (item is ItemNode) { if (ItemFrom is ItemBegin) { (item as ItemNode).Level = 1; ResetNextLevel(); } else { int level = (ItemFrom as ItemNode).Level + 1; if (level > (item as ItemNode).Level) { (item as ItemNode).Level = level; ResetNextLevel(); } } } }
private void ResetItemPoint(CustomItemNode item, Point location) { int itemHorizontalSplitter = 150; int itemVerticalSplitter = 100; if (item.LayoutResetted) { item.ItemLocate = location; item.LayoutResetted = false; } int i = 1; foreach (ItemLink line in item.NextLinks) { Point nextLoation = new Point( location.X + itemHorizontalSplitter, location.Y); ResetItemPoint(line.ItemTo, nextLoation); location.Y = item.ToPoint.Y * i++ + itemVerticalSplitter; } }
protected virtual void AfterSetItemFrom(CustomItemNode item) { }