Author Topic: The Hello Project...  (Read 3670 times)

0 Members and 1 Guest are viewing this topic.

LE

  • Guest
The Hello Project...
« on: September 19, 2006, 04:35:28 PM »
Hi I been following/taking a class about C# - it is not focus on AutoCAD - for now.

It is the semi-basic hello project with just some adding features.... hope that could help someone.

MainForm.cs
Code: [Select]
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace THEHELLO
{
/// <summary>
/// Description of MainForm.
/// </summary>
public partial class MainForm
{
[STAThread]
//public static void Main(string[] args)
//{
// Application.EnableVisualStyles();
// Application.SetCompatibleTextRenderingDefault(false);
// Application.Run(new MainForm());
//}
   
static void Main()
{
Application.Run(new MainForm());
}

public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();

//
// TODO: Add constructor code after the InitializeComponent() call.
//

buttonState = true;
rand = new Random(1000); //((int)DateTime.Now.Ticks); // tried to implement this, but for now did not work....

}
}
}

MainForm.Designer.cs
Code: [Select]
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
 
namespace THEHELLO
{
partial class MainForm : System.Windows.Forms.Form
{
   bool buttonState;   
   Random rand;

/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}

/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Dock = System.Windows.Forms.DockStyle.Fill;
this.button1.Location = new System.Drawing.Point(1, 0);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(291, 273);
this.button1.TabIndex = 0;
this.button1.Text = "Just click me..."; //"button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.Button1Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 276);
this.Controls.Add(this.button1);
this.Name = "MainForm";
this.Text = "THEHELLO";
this.ResumeLayout(false);
}
private System.Windows.Forms.Button button1;
//bool buttonState;
//Random rand;

private Color RandColor()
{
Color color = Color.FromArgb(rand.Next(256),
                             rand.Next(256),
                             rand.Next(256));
return color;
}

private void Button1Click(object sender, System.EventArgs e)
{     
if (buttonState)
button1.Text = "Hello TheSwamp";
else
button1.Text = "Hi TheSwamp";
button1.BackColor = RandColor();
buttonState = !buttonState;
}

}
}
« Last Edit: September 20, 2006, 09:47:47 AM by LE »

LE

  • Guest
Re: The Hello Project...
« Reply #1 on: September 19, 2006, 04:38:47 PM »
This is the dialog:

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: The Hello Project...
« Reply #2 on: September 19, 2006, 04:42:00 PM »
Which class is that Luis ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

LE

  • Guest
Re: The Hello Project...
« Reply #3 on: September 19, 2006, 04:44:10 PM »
A programming class here in an university in CA (a friend of mine is taking - I'm just following).
« Last Edit: September 19, 2006, 04:50:48 PM by LE »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: The Hello Project...
« Reply #4 on: September 19, 2006, 05:49:18 PM »
fun little buttonState option .. that allows for toggling the button title, yes ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

LE

  • Guest
Re: The Hello Project...
« Reply #5 on: September 19, 2006, 05:54:49 PM »
Yes, and a random backcolor for the button.

It is impressive how, easy (just to say it) you can make dialogs and have your code skeleton's right away....

T.Willey

  • Needs a day job
  • Posts: 5251
Re: The Hello Project...
« Reply #6 on: September 19, 2006, 05:55:26 PM »
Yes, and a random backcolor for the button.

It is impressive how, easy (just to say it) you can make dialogs and have your code skeleton's right away....
I second this idea.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.