void UpdateDomainNodes() { _nodeCollection[1].Nodes.Clear(); foreach (Domain newDomain in MainFrameContainer.GetDomains()) { ViewModelFramesHierarchy domainToNode = new ViewModelFramesHierarchy() { kbEntity = KBEntity.DOMAIN_NAME, Domain = newDomain, ParentalNode = _nodeCollection[1], Name = newDomain.name, Frame = null, }; for (int i = 0; i < newDomain.values.Count; i++) { ViewModelFramesHierarchy domainValueNode = new ViewModelFramesHierarchy() { kbEntity = KBEntity.DOMAIN_VALUE, NodeIndex = i, ParentalNode = domainToNode, Name = newDomain.values[i], }; domainToNode.Nodes.Add(domainValueNode); } _nodeCollection[1].Nodes.Add(domainToNode); } }
public void DrawAllKB(FrameContainer mainFrameContainer) { try { List <Frame> currentFrames = mainFrameContainer.GetAllFrames(); List <Domain> currentDomains = mainFrameContainer.GetDomains(); List <string> currentDomainValues = new List <string>(); foreach (Domain domain in currentDomains) { foreach (string value in domain.values) { currentDomainValues.Add(value); } } EasyGraph dataGraph = new EasyGraph();//TODO: Нужно определить полем в классе. foreach (Frame frame in currentFrames) { //находим корневой фрейм bool isFrameInDomains = currentDomainValues.Contains(frame.name); bool isFrameIsNil = frame.isA == "null"; if (!isFrameInDomains && isFrameIsNil) { Frame nilFrame = frame; DataVertex nilDataVertex = new DataVertex(nilFrame.name) { ID = nilFrame.Id }; dataGraph.AddVertex(nilDataVertex); DrawAllRelatedVertices(nilFrame, ref dataGraph, mainFrameContainer); } } _graphArea.SetEdgesDashStyle(EdgeDashStyle.Solid); var logicCore = new GXLogicCoreExample() { Graph = dataGraph }; //CompoundFDP,ISOM,LinLog, //Sugiyama logicCore.DefaultLayoutAlgorithm = LayoutAlgorithmTypeEnum.LinLog; logicCore.DefaultLayoutAlgorithmParams = logicCore.AlgorithmFactory.CreateLayoutParameters(LayoutAlgorithmTypeEnum.LinLog); logicCore.DefaultOverlapRemovalAlgorithm = OverlapRemovalAlgorithmTypeEnum.FSA; logicCore.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.None; logicCore.AsyncAlgorithmCompute = true; _graphArea.LogicCore = logicCore; _graphArea.GenerateGraph(true, false); } catch (Exception e) { MessageBox.Show("При отрисовке что-то пошло не так :( \n" + e.ToString()); } }
bool DrawAllRelatedVertices(Frame mainFrame, ref EasyGraph dataGraph, FrameContainer mainFrameContainer) { try { //Нижний блок можно извлеч в метод DataVertex mainVertex = AddNewVertexSafety(mainFrame, dataGraph); //ПОИСК И ОТРИСОВКА СУБФРЕЙМОВ List <string> allDomainValues = new List <string>(); foreach (var domain in mainFrameContainer.GetDomains()) { foreach (var domainValue in domain.values) { allDomainValues.Add(domainValue); } } foreach (var slot in mainFrame.slots) { if (allDomainValues.Contains(slot.value)) { Frame subFrame = mainFrameContainer.FrameFinder(slot.value); if (subFrame != null) { DataVertex subFrameVertex = AddNewVertexSafety(subFrame, dataGraph); var dataEdge = new DataEdge(subFrameVertex, mainVertex); dataGraph.AddEdge(dataEdge); DrawAllRelatedVertices(subFrame, ref dataGraph, mainFrameContainer); } } } //ПОИСК И ОТРИСОВКА IS_A foreach (var frame in mainFrameContainer.GetAllFrames()) { if (frame.isA == mainFrame.name) { Frame inheritedFrame = frame; if (inheritedFrame != null) { DataVertex inheritedFrameVertex = AddNewVertexSafety(inheritedFrame, dataGraph); var dataEdge = new DataEdge(inheritedFrameVertex, mainVertex) { Text = "is_a" }; dataGraph.AddEdge(dataEdge); DrawAllRelatedVertices(inheritedFrame, ref dataGraph, mainFrameContainer); } } } return(true); } catch (Exception e) { MessageBox.Show("DrawAllRelatedVertices " + e.ToString()); return(false); } }