Exemple #1
0
        private void Output_MouseDown(object sender, MouseEventArgs e)
        {
            menuwork = false;
            DrawGraph <int> draw = sender == OutputA ? DrawA : DrawB;

            if (e.Button == MouseButtons.Right)
            {
                SelectedNode = draw.GetNode(e.Location);
                SelectedEdge = draw.GetEdge(e.Location);
                if (SelectedNode != null || SelectedEdge != null)
                {
                    contextMenuStrip.Show((Control)sender, e.Location);
                }
                menuwork = true;
                return;
            }
            if (AddBtn.Checked)
            {
                if (draw.PlaceFree(e.Location))
                {
                    GetValue get = new GetValue();
                    if (get.ShowDialog() == DialogResult.OK)
                    {
                        draw.Add(get.Value, e.Location);
                        UpdatePicter(sender);
                    }
                }
            }
            if (AddEdge.Checked)
            {
                if (SelectedNode == null)
                {
                    SelectedNode = draw.GetNode(e.Location);
                }
                else
                {
                    if (SelectedNode.Head == draw.graph)
                    {
                        Node <NP <int> > T = draw.GetNode(e.Location);
                        if (T != SelectedNode && T != null && T.GetEdge(SelectedNode) == null)
                        {
                            GetValue get = new GetValue();
                            if (get.ShowDialog() == DialogResult.OK)
                            {
                                SelectedNode.AddDualLinkedEdgeTo(T, get.Value);
                            }
                            UpdatePicter(sender);
                        }
                        SelectedNode = null;
                    }
                    else
                    {
                        SelectedNode = draw.GetNode(e.Location);
                    }
                }
            }
            if (ChangeBtn.Checked)
            {
                SelectedNode = draw.GetNode(e.Location);
            }
        }