public void CreateVertexes()
        {
            int countVertex = 0;

            if (matrixGraph.Matrix != null)
            {
                countVertex = matrixGraph.Matrix.GetLength(0);
            }

            float x = 90f;

            float y = 50f;

            float step = 2 * (float)VertexParameters.Radius + 10;

            for (int i = 0; i < countVertex; ++i)
            {
                VertexDraw vertexDraw = new VertexDraw(BrushColor.Orange, BrushColor.Orange, x + i * step, y, (float)VertexParameters.Width
                                                       , (float)VertexParameters.Height, "", i);

                if (collisionVertex.IsDrawVertex(vertexDraw, vertexDraws))
                {
                    vertexDraws.Add(vertexDraw);
                }
            }
        }
Example #2
0
        public void Setup()
        {
            vertexDraws = new List <VertexDraw>();

            collisionVertex = new CollisionVertex();

            float x = 30.5f;
            float y = 20.7f;

            vertexDraw = new VertexDraw(BrushColor.Orange, BrushColor.Green, x, y, (float)VertexParameters.Width, (float)VertexParameters.Height, "", vertexDraws.Count);
        }
Example #3
0
        public void IsDrawVertexTest_IsCollision_FalseExpected()
        {
            float x = vertexDraw.X + 2 * (float)VertexParameters.Radius - 0.1f;
            float y = vertexDraw.Y;

            VertexDraw vertexItemList = new VertexDraw(BrushColor.Orange, BrushColor.Green, x, y, (float)VertexParameters.Width
                                                       , (float)VertexParameters.Height, "", vertexDraws.Count);

            vertexDraws.Add(vertexItemList);

            bool actual = collisionVertex.IsDrawVertex(vertexDraw, vertexDraws);

            Assert.IsFalse(actual);
        }
Example #4
0
        private bool IsCollision(VertexDraw vertexDraw, List <VertexDraw> vertexDraws)
        {
            foreach (var vertex in vertexDraws)
            {
                int distance = (int)GetDistance(vertex.X, vertexDraw.X, vertex.Y, vertexDraw.Y);

                if (distance < 2 * (int)VertexParameters.Radius)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #5
0
        private void MouseClickDrawForm(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                VertexDraw vertexDraw = new VertexDraw(BrushColor.Orange, BrushColor.Green
                                                       , e.X - (int)VertexParameters.Radius, e.Y - (int)VertexParameters.Radius
                                                       , (int)VertexParameters.Width, (int)VertexParameters.Height, "Саси"
                                                       , vertexDraws.Count);


                if ((collisionVertex.IsDrawVertex(vertexDraw, vertexDraws)) && (startVertexId != -1))
                {
                    vertexDraw.VertexMove(vertexDraws, ref startVertexId
                                          , e.X - (int)VertexParameters.Radius, e.Y - (int)VertexParameters.Radius);

                    Refresh();
                }
                else if (collisionVertex.IsDrawVertex(vertexDraw, vertexDraws))
                {
                    adjacencyList.AddVertex(new CraphModel.Vertex {
                        Id = vertexDraws.Count, Nodes = new List <CraphModel.Node>()
                    });

                    adListPanel.UpdateIdPanel();

                    vertexDraws.Add(vertexDraw);

                    matrixWeightPanel.ExpandMatrix(1);

                    Refresh();
                }
                else
                {
                    drawingEdges.VertexFind(newEdgeDefinition, e, vertexDraws, edgeDraws, ref startVertexId, ref endVertexId, ref adjacencyList, adListPanel, matrixWeightPanel);

                    Refresh();
                }

                if (DialogResult == DialogResult.Cancel)
                {
                    Application.Exit();
                }
            }
        }
        private void DrawingLoadedVertexs(List <List <CellBox> > matrix)
        {
            int countVertex = matrix.Count;

            float x = 90f;

            float y = 50f;

            float step = 2 * (float)VertexParameters.Radius + 10;

            for (int i = 0; i < countVertex; ++i)
            {
                VertexDraw vertexDraw = new VertexDraw(BrushColor.Orange, BrushColor.Orange, x + i * step, y, (float)VertexParameters.Width
                                                       , (float)VertexParameters.Height, "", i);

                if (collisionVertex.IsDrawVertex(vertexDraw, vertexDraws))
                {
                    vertexDraws.Add(vertexDraw);
                }
            }
        }
Example #7
0
 public bool IsDrawVertex(VertexDraw vertexDraw, List <VertexDraw> vertexDraws)
 {
     return(!IsCollision(vertexDraw, vertexDraws));
 }
Example #8
0
 public StoneDrawingVisitor(Graphics graphics, VertexDraw method)
 {
     _graphics = graphics;
     _method   = method;
 }