private void BtnLimpar_Click(object sender, EventArgs e)
        {
            count_exec             = 0;
            pointCount             = 0;
            i                      = 0;
            iTemp                  = 0;
            evolucoes              = 0;
            lbEvolucoes.Text       = "00";
            lbMenorDistancia.Text  = "00";
            lbMenorDistancia2.Text = "00";

            ConfigurationGA.tamPopulacao = 0;
            TablePoints.clear();
            pop = null;

            lbQtdeCidades.Text = "--";

            btnCriarPop.Enabled = false;
            btnExecutar.Enabled = false;
            btnLimpar.Enabled   = false;

            g.Clear(Color.White);
            count = 0;

            mediaPopulacao.Clear();
            zedMedia.Refresh();
        }
Beispiel #2
0
        /// <summary>
        /// Função para marcar as cidades
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseClick(MouseEventArgs e)
        {
            base.OnMouseClick(e);

            Pen blackPen = new Pen(Color.Aquamarine, 3);
            int X        = e.X;
            int Y        = e.Y;

            //TablePoints.AddPoint(X, Y);

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

            g.DrawEllipse(blackPen, rec);

            //distancias entre as coordenadas X,Y -> para mostrar na tela
            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 - 12);

            pointCount++;
            lbQtdCidade.Text = pointCount.ToString();
            lbComplex.Text   = Fatorial((ulong)pointCount).ToString();

            Console.WriteLine(TablePoints.Print());
        }
        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;
        }
Beispiel #4
0
        protected override void ReEnter()
        {
            BrowserClick(0, 995, 607);
            TablePoints tablePoints = Tables.GetInstance().GetTablePoints(setting.tableName);

            BrowserClick(10000, tablePoints.reEnterPoint.X, tablePoints.reEnterPoint.Y);
        }
        private void BtnSalvar_Click(object sender, EventArgs e)
        {
            //Criar "Dados" para colocar os conteudos dentro dar get nos dados depois ...

            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            //define o titulo
            saveFileDialog1.Title = "Salvar Arquivo Texto";
            //Define as extensões permitidas
            saveFileDialog1.Filter = "tsp File|.tsp";
            //define o indice do filtro
            saveFileDialog1.FilterIndex = 0;
            //Atribui um valor vazio ao nome do arquivo
            saveFileDialog1.FileName = "arq_" + lbQtdeCidades.Text;
            //Define a extensão padrão como .txt
            saveFileDialog1.DefaultExt = ".tsp";
            //define o diretório padrão
            saveFileDialog1.InitialDirectory = @"c:\";
            //restaura o diretorio atual antes de fechar a janela
            saveFileDialog1.RestoreDirectory = true;
            //exibe aviso se o usuario informar um caminho que nao existe
            saveFileDialog1.CheckPathExists = true;

            //Abre a caixa de dialogo e determina qual botão foi pressionado
            DialogResult resultado = saveFileDialog1.ShowDialog();

            PlotPoints();
            if (pop != null && count_exec != 0)
            {
                PlotLines(pop, Color.Blue);
            }
            //Se o ousuário pressionar o botão Salvar
            if (resultado == DialogResult.OK)
            {
                //Cria um stream usando o nome do arquivo
                FileStream   fs     = new FileStream(saveFileDialog1.FileName, FileMode.Create);
                StreamWriter writer = new StreamWriter(fs);
                //Colocar informacoes dos dados...
                writer.WriteLine("Name: TC_AG ");
                writer.WriteLine("Type: TSP ");
                writer.WriteLine("DIMENSION: " + pointCount);
                writer.WriteLine("EDGE_WEIGHT_TYPE: EUC_2D");
                writer.WriteLine("NODE_COORD_SECTION");
                for (int i = 0; i < TablePoints.pointCount; i++)
                {
                    int[] coo = TablePoints.getCoordenadas(i);
                    writer.Write(i + 1 + " ");
                    writer.Write(coo[0] + " ");
                    writer.Write(coo[1] + "\r\n");
                }
                writer.WriteLine("EOF");
                writer.Close();
            }
        }
Beispiel #6
0
        void ReleaseDesignerOutlets()
        {
            if (ButtonCheck != null)
            {
                ButtonCheck.Dispose();
                ButtonCheck = null;
            }

            if (ButtonClose != null)
            {
                ButtonClose.Dispose();
                ButtonClose = null;
            }

            if (ConstTopText != null)
            {
                ConstTopText.Dispose();
                ConstTopText = null;
            }

            if (LableStatus != null)
            {
                LableStatus.Dispose();
                LableStatus = null;
            }

            if (MapPoints != null)
            {
                MapPoints.Dispose();
                MapPoints = null;
            }

            if (TablePoints != null)
            {
                TablePoints.Dispose();
                TablePoints = null;
            }

            if (TextCode != null)
            {
                TextCode.Dispose();
                TextCode = null;
            }

            if (ViewStatus != null)
            {
                ViewStatus.Dispose();
                ViewStatus = null;
            }
        }
 private void plotPoints()
 {
     if (TablePoints.pointCount > 0)
     {
         for (int i = 0; i < TablePoints.pointCount; i++)
         {
             Pen       blackPen = new Pen(Color.Red, 3);
             int[]     coo      = TablePoints.getCoordinates(i); //vetor de cordenadas;
             Rectangle rect     = new Rectangle(coo[0] - 5, coo[1] - 5, 10, 10);
             g.DrawEllipse(blackPen, rect);
             g.DrawString((i + 1).ToString(), new Font("Arial Black", 11), Brushes.Black, coo[0] + 3, coo[1]);
             g.DrawString("X: " + coo[0].ToString(), new Font("Arial Black", 6), Brushes.Black, coo[0] - 20, coo[1] - 25);
             g.DrawString("Y: " + coo[1].ToString(), new Font("Arial Black", 6), Brushes.Black, coo[0] - 20, coo[1] - 18);
         }
     }
 }
Beispiel #8
0
        public void SetList(List <ServicePoint> points)
        {
            if (points == null || points.Count == 0)
            {
                TablePoints.BackgroundView.Alpha = 1;
            }
            else
            {
                TablePoints.BackgroundView.Alpha = 0;
            }
            SetNavBar("Map");
            TablePoints.Alpha = 1;
            MapPoints.Alpha   = 0;
            var source = new StoresTableSource(points, this);

            TablePoints.Source = source;
            TablePoints.ReloadData();
        }
        private void PlotPoints()
        {
            //Vericando se a tabela possui pontos
            if (TablePoints.pointCount > 0)
            {
                for (int i = 0; i < TablePoints.pointCount; i++)
                {
                    //Criar um lapis
                    Pen blackPen = new Pen(Color.Red, 3);
                    //Vetor de coordenadas (x, y) (0, 1)
                    int[] coo = TablePoints.getCoordenadas(i);

                    Rectangle rect = new Rectangle(coo[0] - 5, coo[1] - 5, 10, 10);
                    g.DrawEllipse(blackPen, rect);
                    g.DrawString((i + 1).ToString(), new Font("Arial Black", 11), Brushes.Black, coo[0] + 3, coo[1]);
                    g.DrawString("X:" + coo[0].ToString(), new Font("Arial Black", 6), Brushes.Black, coo[0] - 20, coo[1] - 25);
                    g.DrawString("Y:" + coo[1].ToString(), new Font("Arial Black", 6), Brushes.Black, coo[0] - 20, coo[1] - 18);
                }
            }
        }
        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;
            }
        }
        private void BtnClean_Click(object sender, EventArgs e)
        {
            ConfigurationGA.sizePopulation = 0;
            count      = 0;
            pointCount = 0;

            TablePoints.clear();
            pop = null;
            lbQtyCities.Text  = "--";
            lbDifficulty.Text = "0";

            i                = 0;
            itemp            = 0;
            evolucoes        = 0;
            lbEvolucoes.Text = "00";

            btnExecute.Enabled            = false;
            btnPopulationGenerate.Enabled = false;
            btnClean.Enabled = false;
            g.Clear(Color.White);

            mediaPopulation.Clear();
            zedMedia.Refresh();
        }
        private void Form1_MouseClick(object sender, MouseEventArgs e)
        {
            Pen blackPen = new Pen(Color.Red, 3);
            int x        = e.X;
            int y        = e.Y;

            TablePoints.addPoint(x, y);
            TablePoints.print();

            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 - 15);

            pointCount++;

            lbQtdeCidades.Text = "Quantidade de cidade: " + pointCount.ToString();
            lblComplex.Text    = "Complexidade: " + Fatorial((ulong)pointCount).ToString();

            btnCriarPop.Enabled = pointCount >= 3 ? true : false;
            btnLimpar.Enabled   = pointCount >= 1 ? true : false;
        }
Beispiel #13
0
        protected override void Exit()
        {
            TablePoints tablePoints = Tables.GetInstance().GetTablePoints(setting.tableName);

            BrowserClick(0, tablePoints.exitPoint.X, tablePoints.exitPoint.Y);
        }