Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Drawing;
- using System.Windows.Forms;
- namespace Ch02
- {
- ///<summary>
- /// Representa el formulario para el 'dibujo' de la interfaz.
- ///</summary>
- public partial class AlarmClockGUI : Form
- {
- System.ComponentModel.Container components = null;
- ///<summary>
- /// Constructor sin-argumentos.
- ///</summary>
- public AlarmClockGUI()
- {
- InitializeComponents();
- }
- ///<summary>
- /// Uso del patrón Disposable para la liberación 'responsable' de recursos del sistema.
- ///</summary>
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose(disposing);
- }
- #region COMMON_CODE
- ///<summary>
- /// Iniciliaza algunas de las propiedades del formulario, e
- /// invoca los métodos auxiliares para la construcción de la interfaz
- // de usuario.
- ///</summary>
- protected void InitializeComponents()
- {
- this.Font = new Font("Segoe UI", 9);
- this.FormBorderStyle = FormBorderStyle.FixedSingle;
- this.MaximizeBox = false;
- this.Name = "frmAlarmClockGui";
- this.Size = new Size(438, 170);
- this.Text = "Alarm Clock";
- CreateTopButtons();
- CreateTimeLabel();
- CreateGroupBoxAmPm();
- CreateTimerButton();
- CreateSnoozeButton();
- }
- #endregion COMMON_CODE
- #region CUSTOM_CODE
- ///<summary>
- /// Crea e inicializa varias de las propiedades de los controles y los
- /// agrega a la estructura de datos del formulario para su presentación.
- ///</summary>
- private void CreateTopButtons()
- {
- // Create the Hour button.
- Button btnHour = new Button();
- btnHour.Location = new Point(11, 13);
- btnHour.Name = "btnHour";
- btnHour.Text = "Hour";
- this.Controls.Add (btnHour);
- // Create the Minute button.
- Button btnMinute = new Button();
- btnMinute.Location = new Point(95, 13);
- btnMinute.Name = "btnMinute";
- btnMinute.Text = "Minute";
- this.Controls.Add (btnMinute);
- // Create the Second button.
- Button btnSecond = new Button();
- btnSecond.Location = new Point(179, 13);
- btnSecond.Name = "btnSecond";
- btnSecond.Text = "Second";
- this.Controls.Add(btnSecond);
- // Create the On button.
- Button btnOn = new Button();
- btnOn.Location = new Point(263, 13);
- btnOn.Name = "btnOn";
- btnOn.Text = "On";
- this.Controls.Add(btnOn);
- // Create the Off button.
- Button btnOff = new Button();
- btnOff.Location = new Point(347, 13);
- btnOff.Name = "btnOff";
- btnOff.Text = "Off";
- this.Controls.Add(btnOff);
- }
- ///<summary>
- /// Crea e inicializa la etiqueta para representar el tiempo programado de la alarma.
- ///</summary>
- private void CreateTimeLabel()
- {
- Label lblTime = new Label();
- lblTime.BackColor = Color.Black;
- lblTime.BorderStyle = BorderStyle.Fixed3D;
- lblTime.Font = new Font("Segoe UI", 12, FontStyle.Bold);
- lblTime.ForeColor = Color.Silver;
- lblTime.Location = new Point(13,69);
- lblTime.Name = "lblTime";
- lblTime.Text = "00:00:00";
- this.Controls.Add (lblTime);
- }
- ///<summary>
- /// Crea el objeto GroupBox para los radios de alternación entre AM/FM.
- ///</summary>
- private void CreateGroupBoxAmPm()
- {
- GroupBox gbxAmPm = new GroupBox();
- gbxAmPm.Location = new Point(170, 51);
- gbxAmPm.Name = "gbxAmPm";
- gbxAmPm.Size = new Size(100, 50);
- gbxAmPm.Text = "AM/PM";
- // AM RadioButton
- RadioButton rbnAm = new RadioButton();
- rbnAm.AutoSize = true;
- rbnAm.Location = new Point(7, 19);
- rbnAm.Name = "rbnAm";
- rbnAm.Text = "AM";
- gbxAmPm.Controls.Add(rbnAm);
- // PM RadioButton
- RadioButton rbnPm = new RadioButton();
- rbnPm.AutoSize = true;
- rbnPm.Location = new Point(53,19);
- rbnPm.Name = "rbnPm";
- rbnPm.Text = "PM";
- gbxAmPm.Controls.Add(rbnPm);
- this.Controls.Add(gbxAmPm);
- }
- ///<summary>
- /// Crea e inicializa propiedades para el Button de inicio de la alarma.
- ///</summary>
- private void CreateTimerButton()
- {
- Button btnTimer = new Button();
- btnTimer.Location = new Point(347, 67);
- btnTimer.Name = "btnTimer";
- btnTimer.Text = "Timer";
- this.Controls.Add(btnTimer);
- }
- ///<summary>
- /// Crea e inicializa las propiedades del Button para postponer la alama.
- ///<summary>
- private void CreateSnoozeButton()
- {
- Button btnSnooze = new Button();
- btnSnooze.Location = new Point(13, 107);
- btnSnooze.Name = "btnSnooze";
- btnSnooze.Size = new Size(409,25);
- btnSnooze.Text = "Snooze";
- this.Controls.Add(btnSnooze);
- }
- #endregion
- #region CLIENT_CODE
- ///<summary>
- /// Código cliente para administrar la ejecución de la aplicación.
- ///</summary>
- public static void Main()
- {
- Application.Run(new AlarmClockGUI());
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement