/// <summary> /// 获取连入的图元链表 /// </summary> /// <param name="graphElement">当前图元</param> /// <returns>连入的图元链表</returns> public List <GraphElement> GetPreviousGraphElements(GraphElement graphElement) { List <GraphElement> list = new List <GraphElement>(); if (graphElement is SlotContainer) // 当前图元是插槽容器 { SlotContainer slotContaienr = graphElement as SlotContainer; foreach (SlotGraphElement slot in slotContaienr.GetInSlotList()) { if (slot.Binded) { list.Add(slot.BindingConnector.Line); } } } else if (graphElement is ConnectorContainer) // 当前图元是连接线控制点容器 { ConnectorContainer line = graphElement as ConnectorContainer; if (line.InSlotContainer != null) { list.Add(line.InSlotContainer); } } return(list); }
/// <summary> /// 获取连入的所有插槽容器的链表(辅助函数) /// </summary> /// <param name="slotContainer">当前插槽容器</param> /// <param name="list">当前搜索的所有插槽容器的练表</param> public void GetAllPreviousSlotContainers(SlotContainer slotContainer, List <SlotContainer> list) { if (!list.Contains(slotContainer)) // 避免出现死循环 { list.Add(slotContainer); foreach (SlotGraphElement slot in slotContainer.GetInSlotList()) { if (slot.Binded && slot.BindingConnector.Line.InSlotContainer != null) { GetAllPreviousSlotContainers(slot.BindingConnector.Line.InSlotContainer, list); } } } }