Você está na página 1de 5

Interfaz gráfica de árbol binario de búsqueda

INTERFAZ GRÁFICA DE ÁRBOL DE BÚSQUEDA

R Recorridos

Graphics enorden;
enorden = CreateGraphics();
enorden.FillEllipse(Brushes.Cyan, 100, 310, 35, 35);
enorden.DrawString("1", Font, Brushes.Purple, 110, 320);
// Pen myNodoRaiz = new Pen(Color.Orange, 3);
// nodo.DrawEllipse(myNodoRaiz, 320, 30, 35, 35);

enorden.FillEllipse(Brushes.Cyan, 100, 310, 35, 35);


enorden.DrawString("1", Font, Brushes.Purple, 110, 320);
// Pen myNodoRaiz = new Pen(Color.Orange, 3);
// nodo.DrawEllipse(myNodoRaiz, 320, 30, 35, 35);

enorden.FillEllipse(Brushes.Cyan, 100, 310, 35, 35);


enorden.DrawString("1", Font, Brushes.Purple, 110, 320);
// Pen myNodoRaiz = new Pen(Color.Orange, 3);
// nodo.DrawEllipse(myNodoRaiz, 320, 30, 35, 35);

enorden.FillEllipse(Brushes.Cyan, 100, 310, 35, 35);


enorden.DrawString("1", Font, Brushes.Purple, 110, 320);
// Pen myNodoRaiz = new Pen(Color.Orange, 3);
// nodo.DrawEllipse(myNodoRaiz, 320, 30, 35, 35);

enorden.FillEllipse(Brushes.Cyan, 100, 310, 35, 35);


enorden.DrawString("1", Font, Brushes.Purple, 110, 320);
// Pen myNodoRaiz = new Pen(Color.Orange, 3);
// nodo.DrawEllipse(myNodoRaiz, 320, 30, 35, 35);

enorden.FillEllipse(Brushes.Cyan, 100, 310, 35, 35);


enorden.DrawString("1", Font, Brushes.Purple, 110, 320);
// Pen myNodoRaiz = new Pen(Color.Orange, 3);
// nodo.DrawEllipse(myNodoRaiz, 320, 30, 35, 35);

enorden.FillEllipse(Brushes.Cyan, 100, 310, 35, 35);


enorden.DrawString("1", Font, Brushes.Purple, 110, 320);
// Pen myNodoRaiz = new Pen(Color.Orange, 3);
// nodo.DrawEllipse(myNodoRaiz, 320, 30, 35, 35);
//////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Etapa_4_PedroRoncancio
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//metodo salir aplicacion
private void salirToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
//metodo para diseñar interfaz grafica
private void gráficaDeÁrbolToolStripMenuItem_Click(object sender, EventArgs
e)
{
//Diseño del nodo Raiz
Graphics nodo;
nodo = CreateGraphics();
nodo.FillEllipse(Brushes.Cyan,320,30,35,35);
nodo.DrawString("25", Font, Brushes.Purple, 330, 40);
Pen myNodoRaiz = new Pen(Color.Orange, 3);
nodo.DrawEllipse(myNodoRaiz, 320, 30,35,35);

//Diseño del nodo del subarbol Izquierdo

nodo.FillEllipse(Brushes.Cyan,200,80,35,35);
nodo.DrawString("10", Font, Brushes.Purple, 210, 90 );
// Pen myNodo1 = new Pen(Color.Orange, 3);
// nodo.DrawEllipse(myNodo1, 320, 30,35,35);

nodo.FillEllipse(Brushes.Cyan,140, 130, 35, 35);


nodo.DrawString("7", Font, Brushes.Purple, 150, 140);
// Pen myNodo1 = new Pen(Color.Orange, 3);
// nodo.DrawEllipse(myNodo1, 320, 30,35,35);

nodo.FillEllipse(Brushes.Cyan, 260, 130, 35, 35);


nodo.DrawString("12", Font, Brushes.Purple,270,140);
// Pen myNodo1 = new Pen(Color.Orange, 3);
// nodo.DrawEllipse(myNodo1, 320, 30,35,35);

nodo.FillEllipse(Brushes.Cyan, 440, 80, 35, 35);


nodo.DrawString("35", Font, Brushes.Purple, 450, 90);
// Pen myNodo1 = new Pen(Color.Orange, 3);
// nodo.DrawEllipse(myNodo1, 320, 30,35,35);

nodo.FillEllipse(Brushes.Cyan, 500, 130, 35, 35);


nodo.DrawString("50", Font, Brushes.Purple, 510, 140);
// Pen myNodo1 = new Pen(Color.Orange, 3);
// nodo.DrawEllipse(myNodo1, 320, 30,35,35);

nodo.FillEllipse(Brushes.Cyan,380,200, 35, 35);


nodo.DrawString("28", Font, Brushes.Purple, 390, 210);
// Pen myNodo1 = new Pen(Color.Orange, 3);
// nodo.DrawEllipse(myNodo1, 320, 30,35,35);
//Diseño del nodo del subarbol Dercho

nodo.FillEllipse(Brushes.Cyan, 440, 80, 35, 35);


nodo.DrawString("35", Font, Brushes.Purple, 450, 90);
Pen myNodo4 = new Pen(Color.Orange, 3);
nodo.DrawEllipse(myNodo4, 320, 30, 35, 35);

//////////////////
//Diseño del nodo del subarbol2 Izquierdo

//nodo.FillEllipse(Brushes.Cyan, 200, 80, 35, 35);


// nodo.DrawString("17", Font, Brushes.Purple, 210, 90);

//

//linea para conectar el primer nodo izquierdo

Pen myLinea1 = new Pen(Color.Orange, 3);


nodo.DrawLine(myLinea1, 235, 90, 320, 55);

//linea para conectar el primer nodo derecho


Pen myLinea2 = new Pen(Color.Orange, 3);
nodo.DrawLine(myLinea2,335, 55, 440, 90);

Pen myLinea3 = new Pen(Color.Orange, 3);


nodo.DrawLine(myLinea3, 460, 100, 530, 150);

Pen myLinea4 = new Pen(Color.Orange, 3);


nodo.DrawLine(myLinea4, 220, 110, 280, 130);

Pen myLinea5 = new Pen(Color.Orange, 3);


nodo.DrawLine(myLinea5, 160, 130, 220, 100);

// Pen myLinea6 = new Pen(Color.Orange, 3);


//nodo.DrawLine(myLinea6, 400, 130, 445, 110);

Pen myLinea6 = new Pen(Color.Orange, 3);


nodo.DrawLine(myLinea4, 290, 140, 380, 200);

private void recorridoEnPreordenToolStripMenuItem_Click(object sender,


EventArgs e)
{
//metodo para mostrar recorrido en Preorden
Graphics preorden;
preorden = CreateGraphics();
preorden.DrawString("Preorden;", Font, Brushes.Red, 30, 310);

Pen myPreorden = new Pen(Color.Green, 1);


preorden.DrawEllipse(myPreorden, 90, 300, 35, 35);
preorden.DrawString("25", Font, Brushes.Purple, 100, 310);

preorden.DrawString("10", Font, Brushes.Purple, 140, 310);

preorden.DrawString("17", Font, Brushes.Purple, 180, 310);

preorden.DrawString("12", Font, Brushes.Purple, 220, 310);

preorden.DrawString("35", Font, Brushes.Purple, 260, 310);

preorden.DrawString("28", Font, Brushes.Purple, 300, 310);

preorden.DrawString("50", Font, Brushes.Purple, 340, 310);

}
// recorrido en inorden

private void recorridoEnInordenToolStripMenuItem_Click(object sender,


EventArgs e)
{
//metodo para mostrar recorrido en inorden
Graphics enorden;
enorden = CreateGraphics();
enorden.DrawString("Inorden;", Font, Brushes.Red, 30, 360);

Pen myPreorden = new Pen(Color.Green, 1);


enorden.DrawEllipse(myPreorden, 90, 350, 35, 35);
enorden.DrawString("25", Font, Brushes.Purple, 100, 360);

enorden.DrawString("10", Font, Brushes.Purple, 140, 360);

enorden.DrawString("17", Font, Brushes.Purple, 180, 360);

enorden.DrawString("12", Font, Brushes.Purple, 220, 360);

enorden.DrawString("35", Font, Brushes.Purple, 260, 360);

enorden.DrawString("28", Font, Brushes.Purple, 300, 360);

enorden.DrawString("50", Font, Brushes.Purple, 340, 360);


}

private void recorridosToolStripMenuItem_Click(object sender, EventArgs e)


{

}
}
}

Você também pode gostar