Пример #1
0
        private void button5_Click(object sender, EventArgs e)
        {
            if (selected == null)
            {
                return;
            }

            if (start != null)
            {
                if (start.Equals(selected))
                {
                    return;
                }
            }

            if (end != null)
            {
                if (end.Equals(selected))
                {
                    return;
                }
            }

            selected.blocked = true;
            selected.chosen  = false;
            selected.Invalidate();
        }
Пример #2
0
        public static void ShowPath(Form1 window, List <Node> path, Node[,] nodes, Node end)
        {
            window.ControlBox = false;

            for (int i = 0; i < path.Count; ++i)
            {
                path[i].selected = true;
                path[i].chosen   = false;
                path[i].Invalidate();
            }

            end.selected = true;
            end.Invalidate();

            window.ControlBox = true;
            window.path       = new List <Node>(path);
        }
Пример #3
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (selected == null)
            {
                return;
            }

            if (end != null)
            {
                return;
            }

            end        = selected;
            end.end    = true;
            end.chosen = false;
            end.Invalidate();

            selected = null;
        }
Пример #4
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (selected == null)
            {
                return;
            }

            if (start != null)
            {
                return;
            }

            start        = selected;
            start.start  = true;
            start.chosen = false;
            start.Invalidate();

            selected = null;
        }
Пример #5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.nodes = new Node[size, size];

            for (int y = 0; y < size; y++)
            {
                for (int x = 0; x < size; x++)
                {
                    var node = new Node(false, false, false, false, 0, 0, 0, x, y);
                    node.Size     = new Size(100, 100);
                    node.Location = new Point(10 + 105 * x, 10 + 105 * y);
                    node.Visible  = true;
                    node.Invalidate();

                    this.nodes[x, y] = node;
                    this.Controls.Add(this.nodes[x, y]);
                }
            }
        }