Created
January 21, 2017 04:46
-
-
Save WildGenie/c9629c3b7f7a8fffba3259f26090d926 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "System.Windows.Forms" | |
#r "System.Drawing" | |
using System.Windows.Forms; | |
using System.Drawing; | |
using System; | |
//Application.EnableVisualStyles(); | |
Application.Run(new Form1()); | |
public class Form1 : Form | |
{ | |
Button[] buttons; | |
Label[] labels; | |
public Form1() | |
{ | |
KoltukDizayn(); | |
} | |
private void KoltukDizayn() | |
{ | |
int[,] dizayn = new int[,] { | |
{ 0, 0, 1, 2, 0 }, { 0, 1, 2, 3, 0 }, | |
{ 1, 2, 3, 4, 0 }, { 1, 2, 3, 4, 5 }, { 1, 2, 3, 4, 5 } }; | |
buttons = new Button[dizayn.Length]; | |
labels = new Label[dizayn.GetLength(0) + 5]; | |
for (int i = 0; i < dizayn.GetLength(0); i++) | |
{ | |
labels[i] = new Label | |
{ | |
Text = ((char)('A' + i)).ToString(), | |
Location = new Point(10, 10 + i * 40), | |
Size = new Size(39, 39), | |
TextAlign = ContentAlignment.MiddleCenter, | |
AutoSize = false, | |
BackColor = Color.Gray | |
}; | |
for (int k = 0; k < dizayn.GetLength(1); k++) | |
{ | |
buttons[k + i * dizayn.GetLength(0)] = new Button | |
{ | |
Visible = dizayn[i, k] != 0, | |
Text = dizayn[i, k].ToString(), | |
Tag = ((char)('A' + i)).ToString() + "-" + dizayn[i, k].ToString(), | |
Location = new Point(50 + k * 40, 10 + i * 40), | |
Size = new Size(39, 39) | |
}; | |
buttons[k + i * dizayn.GetLength(0)].Click += KoltukClick; | |
} | |
} | |
char[] perde = "PERDE".ToCharArray(); | |
for (int i = 0; i < perde.Length; i++) | |
{ | |
labels[i + dizayn.GetLength(0)] = new Label | |
{ | |
Text = perde[i].ToString(), | |
Location = new Point(50 + i * 40, 10 + dizayn.GetLength(1) * 40), | |
Size = new Size(39, 39), | |
TextAlign = ContentAlignment.MiddleCenter, | |
AutoSize = false, | |
BackColor = Color.Gray | |
}; | |
} | |
this.Controls.AddRange(buttons); | |
this.Controls.AddRange(labels); | |
} | |
private void KoltukClick(object sender, EventArgs e) | |
{ | |
Button button = sender as Button; | |
MessageBox.Show((string)button.Tag); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment