using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Hello585Designer
{
///
/// Summary description for Form1.
///
public class HelloDesigner : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button;
bool buttonState;
Random rand;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public HelloDesigner()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
buttonState = true; // assign boolean state
rand = new Random((int)DateTime.Now.Ticks); // random number gen.
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.button = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button
//
this.button.Dock = System.Windows.Forms.DockStyle.Fill;
this.button.Name = "button";
this.button.Size = new System.Drawing.Size(184, 82);
this.button.TabIndex = 0;
this.button.Text = "Hello CS 585";
this.button.Click += new System.EventHandler(this.button_Click);
//
// HelloDesigner
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(184, 82);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button});
this.Name = "HelloDesigner";
this.Text = "Hello";
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new HelloDesigner());
}
///
/// Get and return a random bright color
/// (upper third 0..255 range)
/// An example of UML tagged auto documentation.
///
private Color RandBrightColor() {
int r,g,b;
r = rand.Next(171, 255);
g = rand.Next(171, 255);
b = rand.Next(171, 255);
return Color.FromArgb(r, g, b);
}
private void button_Click(object sender, System.EventArgs e) {
if (buttonState)
button.Text = "press me again";
else
button.Text = "Hi CS 585";
button.BackColor = RandBrightColor();
buttonState = !buttonState;
}
}
}