public AdjacencyListTable(GraphRepresentation.AdjacencyList adjacencyList, AdjacencyListPanel adListPanel)
        {
            this.adjacencyList = adjacencyList;

            this.adListPanel = adListPanel;

            Cells = new List <List <CellAdjacencyList> >();

            int stepX = 160;

            int stepY = 80;

            for (int i = 0; i < adjacencyList.adjacencyList.Count; ++i)
            {
                Cells.Add(new List <CellAdjacencyList>());

                InfoTextLabel startId = new InfoTextLabel(40, 20, adListPanel.HorizontalScroll.Value, 20 + i * stepY, Convert.ToString(i) + ": ");

                adListPanel.Controls.Add(startId);

                for (int j = 0; j < adjacencyList.adjacencyList[i].Count; ++j)
                {
                    int id = adjacencyList.adjacencyList[i][j].Connectable;

                    int weight = adjacencyList.adjacencyList[i][j].Weight;

                    Cells[i].Add(new CellAdjacencyList(id, weight, 40 + stepX * j, stepY * i));

                    adListPanel.Controls.Add(Cells[i][j]);
                }
            }
        }
        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;
            }
        }
예제 #3
0
        public BackToMenuFromDrawButton(AdjacencyList adjacencyList, List <VertexDraw> vertexDraws,
                                        List <EdgeDraw> edgeDraws, StartForm.DrawForm drawForm, AdjacencyListPanel adjacencyListPanel,
                                        WeightTable weightTable, List <List <CellBox> > matrix, List <List <CellAdjacencyList> > cells,
                                        string buttonText = "Menu") : base(buttonText)
        {
            ForeColor = Color.Black;

            this.BackColor = Color.Orange;

            Font = new System.Drawing.Font("Comic Sans MS", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(204)));

            FlatStyle = System.Windows.Forms.FlatStyle.Popup;

            Text = buttonText;

            Location = new System.Drawing.Point(300, 410);

            this.adjacencyList = adjacencyList;

            this.vertexDraws = vertexDraws;

            this.edgeDraws = edgeDraws;

            this.drawForm = drawForm;

            this.weightTable = weightTable;

            this.adjacencyListPanel = adjacencyListPanel;

            this.matrix = matrix;

            this.cells = cells;
        }
        public DeleteAllButton(int width, int height, AdjacencyList adjacencyList, List <VertexDraw> vertexDraws,
                               List <EdgeDraw> edgeDraws, StartForm.DrawForm drawForm, AdjacencyListPanel adjacencyListPanel,
                               WeightTable weightTable, List <List <CellBox> > matrix, List <List <CellAdjacencyList> > cells)
        {
            Size = new System.Drawing.Size(width, height);

            Dock = DockStyle.Top;

            Text = "Delete all";

            Click += new EventHandler(ButtonClick);

            this.adjacencyList = adjacencyList;

            this.vertexDraws = vertexDraws;

            this.edgeDraws = edgeDraws;

            this.drawForm = drawForm;

            this.weightTable = weightTable;

            this.adjacencyListPanel = adjacencyListPanel;

            this.matrix = matrix;

            this.cells = cells;
        }
예제 #5
0
        public ToolPanel(int positionX, int positionY, WeightTable weightTable, List <EdgeDraw> edgeDraws
                         , AdjacencyList adjacencyList, StartForm.DrawForm drawForm, AdjacencyListPanel adListPanel
                         , List <VertexDraw> vertexDraws, List <List <CellBox> > matrix, List <List <CellAdjacencyList> > cells
                         , ShortestPathPanel shortestPathPanel)

        {
            Location = new System.Drawing.Point(positionX, positionY);

            Dock = DockStyle.Left;

            LayoutStyle = ToolStripLayoutStyle.VerticalStackWithOverflow;

            saveWeightButton = new SaveWeightButton(20, 20, adjacencyList, matrix, weightTable, adListPanel);

            tableButton = new WeightTableButton(20, 20, weightTable, adListPanel, saveWeightButton);

            cycleButton = new CycleButton(20, 20, adjacencyList, edgeDraws, drawForm);

            shortestPathButton = new ShortestPathPanelButton(20, 20, shortestPathPanel);

            adListButton = new AdjacencyListPanelButton(20, 20, adListPanel, weightTable, saveWeightButton);

            saveButton = new SaveButton(20, 20, adjacencyList, drawForm);

            deleteAllButton = new DeleteAllButton(20, 20, adjacencyList, vertexDraws, edgeDraws, drawForm, adListPanel, weightTable, matrix, cells);


            Items.Add(tableButton);

            Items.Add(new ToolStripSeparator());

            Items.Add(adListButton);

            Items.Add(new ToolStripSeparator());

            Items.Add(cycleButton);

            Items.Add(new ToolStripSeparator());

            Items.Add(shortestPathButton);

            Items.Add(new ToolStripSeparator());

            Items.Add(saveButton);

            Items.Add(new ToolStripSeparator());

            Items.Add(deleteAllButton);

            Items.Add(new ToolStripSeparator());

            Items.Add(saveWeightButton);

            Items.Add(new ToolStripSeparator());
        }
예제 #6
0
        public WeightTableButton(int width, int height, WeightTable weightTable, AdjacencyListPanel adListPanel
                                 , SaveWeightButton saveWeightButton)
        {
            Size = new System.Drawing.Size(width, height);

            Dock = DockStyle.Top;

            Click += new EventHandler(ButtonClick);

            Text = "Weight Table";

            this.weightTable = weightTable;

            this.adListPanel = adListPanel;

            this.saveWeightButton = saveWeightButton;
        }
예제 #7
0
        public SaveWeightButton(int width, int height, AdjacencyList adjacencyList, List <List <CellBox> > matrix, WeightTable weightTable, AdjacencyListPanel adListPanel)
        {
            this.adjacencyList = adjacencyList;

            this.matrix = matrix;

            this.weightTable = weightTable;

            this.adListPanel = adListPanel;

            Size = new System.Drawing.Size(width, height);

            Text = "Save Changes";

            Click += new EventHandler(ButtonClick);

            Enabled = false;
        }