Example #1
0
        private void DrawPanel_MouseClick(object sender, MouseEventArgs e)
        {
            DrawPanel.Focus();
            Drawing.Editing(e.Location, SemanticNetwork);
            if (e.Button == MouseButtons.Left)
            {
                SemanticNetwork.Deselect();
            }

            if (AddingNewEdgeFlag)
            {
                for (int i = 0; i < SemanticNetwork.Nodes.Count; i++)
                {
                    Node node = Drawing.CheckNode(e.X, e.Y, SemanticNetwork);
                    if (node == null)
                    {
                        return;
                    }

                    if (selected1 == null)
                    {
                        selected1 = node;
                        break;
                    }
                    if (selected2 == null)
                    {
                        selected2 = node;
                        if (selected1 == null)
                        {
                            return;
                        }

                        EdgeForm addNewEdgeForm = new EdgeForm();
                        addNewEdgeForm.SetRelations = SemanticNetwork.Relations;
                        addNewEdgeForm.Converter    = converter;
                        if (addNewEdgeForm.ShowDialog() == DialogResult.OK)
                        {
                            Relation   relation = addNewEdgeForm.Relation;
                            EdgeConfig ec       = addNewEdgeForm.EdgeConfig;
                            Edge       edge     = new Edge(relation, selected1, selected2, ec);
                            //edge.EdgeConfig.SetDefaultValues(edge.NodeOne, edge.NodeTwo);
                            SemanticNetwork.AddEdge(edge);
                            AddingNewEdgeFlag = false;
                        }
                        DrawPanel.Invalidate();
                        selected1 = null;
                        selected2 = null;
                        break;
                    }
                }
            }
        }
Example #2
0
        private void DrawPanel_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Drawing.Select(e.Location, SemanticNetwork);

            if (SemanticNetwork.SelectedNode != null)
            {
                if (e.Button == MouseButtons.Left)
                {
                    NodeForm nf = new NodeForm();
                    nf.Info      = SemanticNetwork.SelectedNode.Concept;
                    nf.Converter = converter;
                    if (nf.ShowDialog() == DialogResult.OK)
                    {
                        NodeConfig nc = nf.NodeConfig;
                        SemanticNetwork.SelectedNode.Concept    = nf.Info;
                        SemanticNetwork.SelectedNode.NodeConfig = nc;
                    }
                }
                else if (e.Button == MouseButtons.Right)
                {
                    if (MessageBox.Show("Вы уверены?", "Подтвердите действие", MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        SemanticNetwork.DeleteNode(SemanticNetwork.SelectedNode);
                    }
                }
            }
            else if (SemanticNetwork.SelectedEdge != null)
            {
                if (e.Button == MouseButtons.Left)
                {
                    EdgeForm addNewEdgeForm = new EdgeForm();
                    addNewEdgeForm.SetRelations = SemanticNetwork.Relations;
                    addNewEdgeForm.Relation     = SemanticNetwork.SelectedEdge.Relation;
                    addNewEdgeForm.Converter    = converter;
                    addNewEdgeForm.EdgeConfig   = SemanticNetwork.SelectedEdge.EdgeConfig;
                    if (addNewEdgeForm.ShowDialog() == DialogResult.OK)
                    {
                        Relation   relation = addNewEdgeForm.Relation;
                        EdgeConfig ec       = addNewEdgeForm.EdgeConfig;
                        ec.Selected = true;
                        SemanticNetwork.SelectedEdge.EdgeConfig = ec;
                        SemanticNetwork.SelectedEdge.Relation   = relation;
                        SemanticNetwork.DeSelectEditing();
                    }
                }
                else if (e.Button == MouseButtons.Right)
                {
                    if (MessageBox.Show("Вы уверены?", "Подтвердите действие", MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        SemanticNetwork.DeleteEdge(SemanticNetwork.SelectedEdge);
                    }
                }
            }
            else
            {
                if (e.Button == MouseButtons.Left)
                {
                    NodeForm nf = new NodeForm();
                    nf.Converter = converter;
                    if (nf.ShowDialog() == DialogResult.OK)
                    {
                        NodeConfig nc = nf.NodeConfig;
                        SemanticNetwork.AddNode(new Node(nf.Info, converter.IJtoXY(e.Location), nc));
                    }
                }
            }
            DrawPanel.Invalidate();
        }