public void AddRelationDefinition()
        {
            var s = this.sv.selectedGraph.graphWrapper.Graph as SemanticGraph;

            var f = new AddRelationDefinitionForm();
            f.ShowDialog();
            if (!s.RelationsDefinitions.Exists(rd => rd.Name == f.RelationDefinition.Name || rd.Id == f.RelationDefinition.Id))
            {
                s.RelationsDefinitions.Add(f.RelationDefinition.Clone() as RelationDefinition);
            }
            sv.Refresh();
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (this.selectedGraph.action == GraphEditActions.Edit)
            {
                if (firstConceptComboBox.SelectedIndex == -1 || relationComboBox.SelectedIndex == -1 || secondConceptComboBox.SelectedIndex == -1)
                {
                    return;
                }
                var f = this.selectedGraph.graphWrapper.Graph.GetVertex(v => v.Value == firstConceptComboBox.SelectedItem) as ConceptVertex;
                var s = this.selectedGraph.graphWrapper.Graph.GetVertex(v => v.Value == secondConceptComboBox.SelectedItem) as ConceptVertex;

                var r = (this.selectedGraph.graphWrapper.Graph as SemanticGraph).RelationsDefinitions.Find(rd => rd.Name == relationComboBox.SelectedItem.ToString());

                this.selectedGraph.Debug((this.selectedGraph as SemanticGraphView).SemanticNerwork.Question(
                    f == null ? SemanticNetwork.anyValue : f.Id,
                    r == null ? SemanticNetwork.anyValue : r.Id,
                    s == null ? SemanticNetwork.anyValue : s.Id));
            }
            else
            {
                var s = this.selectedGraph.graphWrapper.Graph as SemanticGraph;

                var r = s.RelationsDefinitions.Find(rd => rd.Name == relationComboBox.SelectedItem.ToString());

                if (r != null)
                {
                    var f = new AddRelationDefinitionForm() { RelationDefinition = r };
                    f.ShowDialog();
                    if (f.RelationDefinition.Id != r.Id && !s.RelationsDefinitions.Exists(rd => rd.Id == f.RelationDefinition.Id))
                        r.Id = f.RelationDefinition.Id;

                    if (f.RelationDefinition.Name != r.Name && !s.RelationsDefinitions.Exists(rd => rd.Name == f.RelationDefinition.Name))
                        r.Name = f.RelationDefinition.Name;

                    r.TypeId = f.RelationDefinition.TypeId;
                }
                else
                {
                    MainController.AddRelationDefinition();
                }

                this.Refresh();
            }
        }