using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WindowsApplication8
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.TextBox textBox4;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.listBox1 = new System.Windows.Forms.ListBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.button2 = new System.Windows.Forms.Button();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(360, 24);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(136, 24);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(16, 24);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(301, 301);
this.pictureBox1.TabIndex = 1;
this.pictureBox1.TabStop = false;
//
// listBox1
//
this.listBox1.Location = new System.Drawing.Point(360, 152);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(144, 173);
this.listBox1.TabIndex = 2;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(360, 344);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(72, 20);
this.textBox1.TabIndex = 3;
this.textBox1.Text = "textBox1";
//
// button2
//
this.button2.Location = new System.Drawing.Point(360, 64);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(136, 24);
this.button2.TabIndex = 0;
this.button2.Text = "button1";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(328, 424);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(80, 20);
this.textBox2.TabIndex = 4;
this.textBox2.Text = "textBox2";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(328, 456);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(80, 20);
this.textBox3.TabIndex = 4;
this.textBox3.Text = "textBox2";
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(328, 488);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(80, 20);
this.textBox4.TabIndex = 4;
this.textBox4.Text = "textBox2";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(520, 542);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.button2);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox4);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
ArrayList a = new ArrayList();
int Index=100;
int Kombination;
int Zahl;
int Split1;
int Split2;
private void Form1_Load(object sender, System.EventArgs e)
{
for (int i=0; i<100; i++)
{
a.Add(i);
}
for (int i=0; i<100; i++)
{
listBox1.Items.Add(a[i]);
}
}
private void button1_Click(object sender, System.EventArgs e)
{
Graphics g = pictureBox1.CreateGraphics();
for (int c=0; c<10; c++)
{
for (int i=0; i<10; i++)
{
g.DrawRectangle(new Pen(Color.Black),i*30,c*30,30,30);
}
}
}
private void button2_Click(object sender, System.EventArgs e)
{
Berechnen();
Zeichnen();
}
private void Berechnen()
{
Random z = new Random();
Kombination = z.Next(0,Index);
Zahl = Convert.ToInt32(a[Kombination]);
a.Remove(Kombination);
Index--;
}
private void Zeichnen()
{
textBox1.Text = Convert.ToString(Zahl);
listBox1.Items.Clear();
for (int i=0; i<Index; i++)
{
listBox1.Items.Add(a[i]);
}
if (Zahl > 9)
{
Split1 = Convert.ToInt32(Convert.ToString(Zahl).Substring(0,1));
Split2 = Convert.ToInt32(Convert.ToString(Zahl).Substring(1));
}
else
{
Split1 = 0;
Split2 = Convert.ToInt32(Convert.ToString(Zahl).Substring(0,1));
}
textBox2.Text = Convert.ToString(Split1);
textBox3.Text = Convert.ToString(Split2);
textBox4.Text = Convert.ToString(Index);
Graphics g = pictureBox1.CreateGraphics();
g.FillRectangle(new SolidBrush(Color.Coral),Split2*30,Split1*30,30,30);
}
}
}