コード例 #1
0
        public void PrependFrame()
        {
            Frame newFrame = new Frame()
            {
                name = "!!!newFrame" + _newFrameCounter++.ToString(),
            };

            MainFrameContainer.AddFrame(newFrame);
            newFrame.Id = MainFrameContainer.GetAllFrames().Last().Id;

            ViewModelFramesHierarchy newFrameNode = new ViewModelFramesHierarchy()
            {
                kbEntity = KBEntity.FRAME,

                ParentalNode = _nodeCollection[0],

                Id    = newFrame.Id,
                Name  = newFrame.name,
                Frame = newFrame
            };

            ViewModelFramesHierarchy isA_node = new ViewModelFramesHierarchy()
            {
                kbEntity = KBEntity.IS_A,

                ParentalNode = newFrameNode,
                Name         = frame.isA,
                NodeIndex    = 0,
            };

            newFrameNode.Nodes.Add(isA_node);

            _moveAllOtherNodesRightAfterNewNode(ref newFrameNode, 0); //0 для фреймов

            viewModelGraph.DrawAllKB(MainFrameContainer);

            OnPropertyChanged("PrepEnd");
        }
コード例 #2
0
        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());
            }
        }
コード例 #3
0
        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);
            }
        }