Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (int i = 0; i < arr.GetLength(0); i++)
- {
- cx = x;
- for (int j = 0; j < arr.GetLength(1); j++)
- {
- value = rnd.Next(0, 2);
- t = new Button();
- t.Tag = new Place(i,j);
- //if (value == 1)
- //{
- // t.Text = "";
- //} // A TEST TO TEST VALUES OF TEXTS ON BUTTONS.
- //else
- //{
- // t.Text = "CsdUS";
- //}
- if (value == 0)
- { rndmimg = rnd.Next(1, 2); }
- else
- { rndmimg = rnd.Next(2, 6); }
- t.BackColor = Color.Red;
- t.BackgroundImageLayout = ImageLayout.Stretch;
- t.BackgroundImage = Image.FromFile("..\..\Pictures\"+rndmimg+".png");
- //t.BackgroundImage = Image.FromFile("..\..\Pictures\2000.png");
- t.Bounds = new Rectangle(cx, y, w, h);
- //t.BackColor = Color.Red;
- t.Click += new System.EventHandler(this.qqq_Click);
- this.Controls.Add(t);
- arr[i, j] = t;
- cx += w;
- }
- y += h;
- }
- }
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- rnd = new Random();
- }
- private void qqq_Click(object sender, EventArgs e) //When Click
- {
- int px;
- int py;
- Place pl = (Place)(((Button)sender).Tag);
- px = pl.GetR();
- py = pl.GetC();
- rndmcus = rnd.Next(0, 2); //Rndmcus Determines the color when clicked the button.
- if (rndmcus == 0)
- {
- mishvalue = 0;
- arr[px,py].BackColor = Color.Green;
- arr[px, py].Enabled = false;
- }
- if (rndmcus == 1)
- {
- mishvalue = 1;
- arr[px, py].BackColor = Color.Blue;
- arr[px, py].Enabled = false;
- }
- ((Button)sender).Text = " ";
- scanner();
- }
- public void scanner()
- {
- int counter=0;
- for (int i = 0; i < arr.GetLength(0); i++)
- {
- for (int j = 0; j < arr.GetLength(0); j++)
- {
- if (arr[i, j].Text == " ")
- {
- counter++;
- }
- }
- }
- if (counter == boardsize * boardsize) // מה קורה כאשר כל הלוח מלא בתשובות נכונות?
- {
- this.Close();
- }
- }
- //public int Linescan(int px)
- //{
- // if (px == boardsize)
- // {
- // return px; //CHANGEEEEE
- // }
- //}
- }
- }
- //Class Place:
- class Place
- {
- private int r;
- private int c;
- public Place(int r, int c)
- {
- this.r = r;
- this.c = c;
- }
- public int GetR()
- {
- return this.r;
- }
- public int GetC()
- {
- return this.c;
- }
- public void SetR(int r)
- {
- this.r = r;
- }
- public void SetC(int c)
- {
- this.c = c;
- }
- }
- for (int j = 0; j < arr.GetLength(1); j++)
- {
- value = rnd.Next(0, 2);
- t = new Button();
- t.ID = j.ToString();
- Button button = (Button)sender;
- string buttonId = button.ID;
Add Comment
Please, Sign In to add comment