Created
July 2, 2015 16:54
-
-
Save Fhernd/4148e8b94e20bcd6a3a8 to your computer and use it in GitHub Desktop.
Control de personalizado `ControlAvion`.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ===++=== | |
// | |
// OrtizOL - xCSw | |
// | |
// Proyecto: Cupi2.NET | |
// | |
// ===--=== | |
/*============================================================ | |
// | |
// Clase(s): ControlAvion. | |
// | |
// Propósito: Representar una avión gráfica. | |
// | |
// Original: http://cupi2.uniandes.edu.co/sitio/index.php/cursos/apo1/nivel-3/avion/visualizacion-codigo/panelavion | |
// | |
============================================================*/ | |
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Drawing; | |
using System.Data; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Windows.Forms; | |
using ElAvión.Modelo; | |
namespace ElAvión.GUI | |
{ | |
/// <summary> | |
/// Clase que representa el control personalizado de avión gráfica. | |
/// </summary> | |
public partial class ControlAvion : UserControl | |
{ | |
#region Campos: | |
/// <summary> | |
/// Instancia de referencia al objeto `Avion` principal. | |
/// </summary> | |
private Avion m_avion; | |
#endregion | |
#region Constructores | |
/// <summary> | |
/// Crea un nuevo control avión gráfica. | |
/// </summary> | |
public ControlAvion() | |
{ | |
InitializeComponent(); | |
} | |
/// <summary> | |
/// Crea un nuevo control avión gráfica. | |
/// </summary> | |
/// <param name="avion">Referencia a objeto `Avion` principal.</param> | |
public ControlAvion(Avion avion) | |
{ | |
InitializeComponent(); | |
m_avion = avion; | |
DibujarSillasEjecutivas(); | |
DibujarSillasEconomicas(); | |
} | |
#endregion | |
#region Métodos privados: | |
/// <summary> | |
/// Dibuja las sillas económicas con la iconografía y textos respectivos. | |
/// </summary> | |
private void DibujarSillasEconomicas() | |
{ | |
Silla[] sillasEconomicas = m_avion.ObtenerSillasEconomicas(); | |
Silla silla; | |
byte fila_silla = 0; | |
byte col_silla = 0; | |
ControlSillaGrafica ctlSillaGrafica; | |
for(int num_silla = 0; num_silla < sillasEconomicas.Length; ++num_silla) | |
{ | |
silla = sillasEconomicas[num_silla]; | |
ctlSillaGrafica = new ControlSillaGrafica(silla); | |
ctlSillaGrafica.Dock = DockStyle.Fill; | |
ctlSillaGrafica.BackColor = Color.Black; | |
if (num_silla > 0 & num_silla % 6 == 0) | |
{ | |
++fila_silla; | |
col_silla = 0; | |
} | |
tplSillasEconomicas.Controls.Add(ctlSillaGrafica, col_silla == 3? ++col_silla : col_silla, fila_silla); | |
++col_silla; | |
} | |
} | |
/// <summary> | |
/// Dibuja las sillas ejecutivas con la iconografía y textos respectivos. | |
/// </summary> | |
private void DibujarSillasEjecutivas() | |
{ | |
Silla[] sillasEjecutivas = m_avion.ObtenerSillasEjecutivas(); | |
Silla silla; | |
for (int num_silla = 0; num_silla < sillasEjecutivas.Length; ++num_silla) | |
{ | |
silla = sillasEjecutivas[num_silla]; | |
ControlSillaGrafica ctlSillaGrafica = new ControlSillaGrafica(silla); | |
ctlSillaGrafica.Dock = DockStyle.Fill; | |
ctlSillaGrafica.BackColor = Color.Black; | |
switch (silla.Numero) | |
{ | |
case 1: | |
tlpSillasEjecutivas.Controls.Add(ctlSillaGrafica, 0, 0); | |
break; | |
case 2: | |
tlpSillasEjecutivas.Controls.Add(ctlSillaGrafica, 1, 0); | |
break; | |
case 3: | |
tlpSillasEjecutivas.Controls.Add(ctlSillaGrafica, 3, 0); | |
break; | |
case 4: | |
tlpSillasEjecutivas.Controls.Add(ctlSillaGrafica, 4, 0); | |
break; | |
case 5: | |
tlpSillasEjecutivas.Controls.Add(ctlSillaGrafica, 0, 1); | |
break; | |
case 6: | |
tlpSillasEjecutivas.Controls.Add(ctlSillaGrafica, 1, 1); | |
break; | |
case 7: | |
tlpSillasEjecutivas.Controls.Add(ctlSillaGrafica, 3, 1); | |
break; | |
case 8: | |
tlpSillasEjecutivas.Controls.Add(ctlSillaGrafica, 4, 1); | |
break; | |
} | |
ctlSillaGrafica.Size = new Size(21, 23); | |
} | |
} | |
#endregion | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment