aboutsummaryrefslogtreecommitdiff
path: root/Histacom2/OS/Win95/Win95Apps/GuessTheNumber.cs
diff options
context:
space:
mode:
authorAlex-TIMEHACK <alexbu2015@hotmail.com>2017-08-27 11:32:44 +0100
committerAlex-TIMEHACK <alexbu2015@hotmail.com>2017-08-27 11:32:44 +0100
commitf8f3bd0b1eb57c5a289513200b192e1d54d58292 (patch)
treec9b79515fb81d90320ef386a522a5830875f6d49 /Histacom2/OS/Win95/Win95Apps/GuessTheNumber.cs
parentbffcb720f811623015ed4795032e5c57d1064c8a (diff)
parentcd6273d7c95098e0e0dd9948c6b5cec1c5f9cd3f (diff)
downloadhistacom2-f8f3bd0b1eb57c5a289513200b192e1d54d58292.tar.gz
histacom2-f8f3bd0b1eb57c5a289513200b192e1d54d58292.tar.bz2
histacom2-f8f3bd0b1eb57c5a289513200b192e1d54d58292.zip
Updated my fork!
Diffstat (limited to 'Histacom2/OS/Win95/Win95Apps/GuessTheNumber.cs')
-rw-r--r--Histacom2/OS/Win95/Win95Apps/GuessTheNumber.cs56
1 files changed, 56 insertions, 0 deletions
diff --git a/Histacom2/OS/Win95/Win95Apps/GuessTheNumber.cs b/Histacom2/OS/Win95/Win95Apps/GuessTheNumber.cs
new file mode 100644
index 0000000..72adc0e
--- /dev/null
+++ b/Histacom2/OS/Win95/Win95Apps/GuessTheNumber.cs
@@ -0,0 +1,56 @@
+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;
+
+namespace Histacom2.OS.Win95.Win95Apps
+{
+ public partial class GuessTheNumber : UserControl
+ {
+ private Random rnd;
+ private int num;
+
+ public GuessTheNumber()
+ {
+ InitializeComponent();
+
+ rnd = new Random();
+ num = rnd.Next(0, 101);
+
+ pictureBox1.MouseDown += (s, a) => pictureBox1.BackgroundImage = Properties.Resources.GTN95_CheckClicked;
+ pictureBox1.MouseUp += (s, a) => pictureBox1.BackgroundImage = Properties.Resources.GTN95_Check;
+ pictureBox3.MouseDown += (s, a) => pictureBox3.BackgroundImage = Properties.Resources.GTN95_RestartClicked;
+ pictureBox3.MouseUp += (s, a) => pictureBox3.BackgroundImage = Properties.Resources.GTN95_Restart;
+ }
+
+ private void pictureBox3_Click(object sender, EventArgs e)
+ {
+ pictureBox2.BackgroundImage = null;
+ textBox1.Enabled = true;
+ num = rnd.Next(0, 101);
+ }
+
+ private void pictureBox1_Click(object sender, EventArgs e)
+ {
+ try {
+ int guess = int.Parse(textBox1.Text);
+
+ if (guess < num) pictureBox2.BackgroundImage = Properties.Resources.GTN95_Higher;
+ else if (guess > num) pictureBox2.BackgroundImage = Properties.Resources.GTN95_Lower;
+ else if (guess == num)
+ {
+ pictureBox2.BackgroundImage = Properties.Resources.GTN95_Correct;
+ textBox1.Enabled = false;
+ }
+ } catch
+ {
+ pictureBox2.BackgroundImage = Properties.Resources.GTN95_Error;
+ }
+ }
+ }
+}