private void BtnInserir_Click(object sender, EventArgs e)
        {
            btnExecutar.Enabled = false;

            Random rnd = new Random();

            maskedCity.Text = maskedCity.Text.Equals("") ? "0" : maskedCity.Text;
            var cities = Convert.ToInt32(maskedCity.Text.ToString());

            for (int k = 0; k <= cities - 1; k++)
            {
                Pen blackPen = new Pen(Color.Red, 3);
                int X        = rnd.Next(256, 1279);
                int Y        = rnd.Next(31, 520);

                TablePoints.AddPoint(X, Y);

                Rectangle rect = new Rectangle(X - 5, Y - 5, 10, 10);
                g.DrawEllipse(blackPen, rect);
                g.DrawString((pointCount + 1).ToString(), new Font("Arial Black", 11), Brushes.Black, X + 3, Y);
                g.DrawString("X:" + X.ToString(), new Font("Arial Black", 6), Brushes.Black, X - 20, Y - 25);
                g.DrawString("Y:" + Y.ToString(), new Font("Arial Black", 6), Brushes.Black, X - 20, Y - 18);

                pointCount++;
                lbQtdeCidades.Text = pointCount.ToString();
            }
            btnCriarPop.Enabled = true;
            btnLimpar.Enabled   = true;
            bestAux             = double.PositiveInfinity;
        }
        protected override void OnMouseClick(MouseEventArgs e)
        {
            base.OnMouseClick(e);

            //Criar um lapis
            Pen blackPen = new Pen(Color.Red, 3);
            int X        = e.X;
            int Y        = e.Y;

            TablePoints.AddPoint(X, Y);

            Rectangle rect = new Rectangle(X - 5, Y - 5, 10, 10);

            g.DrawEllipse(blackPen, rect);
            g.DrawString((pointCount + 1).ToString(), new Font("Arial Black", 11), Brushes.Black, X + 3, Y);
            g.DrawString("X:" + X.ToString(), new Font("Arial Black", 6), Brushes.Black, X - 20, Y - 25);
            g.DrawString("Y:" + Y.ToString(), new Font("Arial Black", 6), Brushes.Black, X - 20, Y - 18);

            pointCount++;
            lbQtdeCidades.Text = pointCount.ToString();

            if (++count >= 1)
            {
                btnCriarPop.Enabled = true;
            }

            if (++count >= 1)
            {
                btnLimpar.Enabled = true;
            }
            else
            {
                btnLimpar.Enabled = false;
            }

            if (countAux != count)
            {
                btnExecutar.Enabled = false;
            }
        }
Beispiel #3
0
        protected override void OnMouseClick(MouseEventArgs e)
        {
            base.OnMouseClick(e);
            //Console.WriteLine("Point Insert");

            Pen blackPen = new Pen(Color.Red, 3);
            int x        = e.X;
            int y        = e.Y;

            TablePoints.AddPoint(x, y);

            Rectangle rect = new Rectangle(x - 5, y - 5, 10, 10);

            G.DrawEllipse(blackPen, rect);
            G.DrawString((PointCount + 1).ToString(), new Font("Arial Black", 11), Brushes.Black, x + 3, y);
            G.DrawString("X: " + x.ToString(), new Font("Arial Black", 6), Brushes.Black, x - 20, y - 25);
            G.DrawString("Y: " + y.ToString(), new Font("Arial Black", 6), Brushes.Black, x - 20, y - 18);

            PointCount++;

            lbQtdeCidades.Text = PointCount.ToString();
            lbComplex.Text     = Fatorial((ulong)PointCount).ToString();

            if (++Count >= 4)
            {
                btnCriarPop.Enabled = true;
            }

            if (++Count >= 1)
            {
                btnLimpar.Enabled = true;
            }
            else
            {
                btnLimpar.Enabled = false;
            }

            //Console.WriteLine(TablePoints.Print());
        }