public void VertexFind(NewEdgeDefinition vertexClick, MouseEventArgs e, List <VertexDraw> vertexDraws, List <EdgeDraw> edgeDraws, ref int startVertexId, ref int endVertexId,
                               ref AdjacencyList adjacencyList, AdjacencyListPanel adListPanel, MatrixWeightPanel matrixWeightPanel)
        {
            vertexClick.VertexRemember(ref startVertexId, ref endVertexId
                                       , e.X - (int)VertexParameters.Radius, e.Y - (int)VertexParameters.Radius
                                       , vertexDraws);


            if ((startVertexId != -1) && (endVertexId != -1) && (startVertexId != endVertexId) && (!IsDuplicate(edgeDraws, startVertexId, endVertexId)))
            {
                EdgeDraw edgeDraw = new EdgeDraw(BrushColor.Black, 0, startVertexId, endVertexId);

                edgeDraws.Add(edgeDraw);

                adjacencyList.AddNode(startVertexId, endVertexId, 1);

                adListPanel.UpdateNodesPanel(startVertexId, endVertexId);

                matrixWeightPanel.UpdateNodes(startVertexId, endVertexId);

                startVertexId = -1;
                endVertexId   = -1;
            }
            else if (IsDuplicate(edgeDraws, startVertexId, endVertexId))
            {
                startVertexId = -1;
                endVertexId   = -1;
            }
        }
Beispiel #2
0
        public DrawForm(List <VertexDraw> vertexDraws, List <EdgeDraw> edgeDraws, List <List <CellBox> > matrix, StartForm startForm,
                        InputCountVertexForm inputCountVertexForm, MatrixGraph matrixGraph, AdjacencyList adjacencyList)

        {
            InitializeComponent();

            StartPosition = FormStartPosition.CenterScreen;

            Text = "GraphVizualizer / Draw";

            this.BackColor = Color.DarkGray;

            DoubleBuffered = true;

            this.vertexDraws = vertexDraws;

            this.edgeDraws = edgeDraws;

            collisionVertex = new CollisionVertex();

            newEdgeDefinition = new NewEdgeDefinition();

            drawingEdges = new DrawingEdges();

            MouseDown += new MouseEventHandler(MouseClickDrawForm);

            vertexBrush = new SolidBrush(Color.Black);

            vertexStringFormat = new StringFormat();

            vertexStringFormat.Alignment = StringAlignment.Center;

            vertexStringFormat.LineAlignment = StringAlignment.Center;

            vertexTextFont = new Font("Times New Roman", 12, FontStyle.Bold);

            pen = new Pen(Brushes.Black, 5);

            weightTable = new WeightTable(200, 200, Size.Width - 200, 0);

            matrixWeightPanel = new MatrixWeightPanel(weightTable, matrix);

            matrixWeightPanel.DrawingMatrix();

            Controls.Add(weightTable);

            converter = new Converter();

            this.adjacencyList = adjacencyList;

            adListPanel = new AdjacencyListPanel(200, 200, Size.Width - 200, 0, adjacencyList);

            Controls.Add(adListPanel);

            Controls.Add(adListPanel);

            shortestPathPanel = new ShortestPathPanel(200, 200, 150, 0, adjacencyList, edgeDraws, this);

            Controls.Add(shortestPathPanel);

            toolPanel = new ToolPanel(0, 100, weightTable, this.edgeDraws
                                      , adjacencyList, this, adListPanel, this.vertexDraws, matrix
                                      , adListPanel.AdListTable.Cells, shortestPathPanel);

            Controls.Add(toolPanel);

            pen.EndCap = LineCap.ArrowAnchor;

            arrow = new Arrow();

            brushes = new Brush[2];

            brushes[(int)BrushColor.Orange] = Brushes.Orange;

            brushes[(int)BrushColor.Black] = Brushes.Black;

            backToMenuOfDrawButton = new BackToMenuFromDrawButton(adjacencyList, vertexDraws, edgeDraws,
                                                                  this, adListPanel, weightTable, matrix, adListPanel.AdListTable.Cells);

            backToInputFromDrawButton = new BackToInputFromDrawButton(adjacencyList, vertexDraws, edgeDraws,
                                                                      this, adListPanel, weightTable, matrix, adListPanel.AdListTable.Cells, inputCountVertexForm, matrixGraph, startForm);

            Controls.Add(backToInputFromDrawButton);

            Controls.Add(backToMenuOfDrawButton);
        }