Skip to content

Instantly share code, notes, and snippets.

@WildGenie
Created December 11, 2016 16:42
Show Gist options
  • Save WildGenie/01af255f17065fd9cdfe5c05642eae45 to your computer and use it in GitHub Desktop.
Save WildGenie/01af255f17065fd9cdfe5c05642eae45 to your computer and use it in GitHub Desktop.
#r "System.Windows.Forms"
#r "System.Drawing"
using System.Windows.Forms;
using System.Drawing;
using System;
public static Form form = new Form();
public Button[,] buttons = new Button[10, 10];
Main();
void Main()
{
form.AutoSize = true;
Random rnd = new Random();
for (int x = 0; x < buttons.GetLength(0); x++)
for (int y = 0; y < buttons.GetLength(1); y++)
{
buttons[x, y] = new Button();
Button button = buttons[x, y];
button.Text = Convert.ToChar(x + Convert.ToByte('A')).ToString() + (y + 1).ToString();
button.ForeColor = Color.LightGray;
button.Size = new Size(39, 39);
button.Location = new Point(x * 40, y * 40);
int harfNo = '@';
if (rnd.Next(10) < 7)
{
harfNo = 'A' + rnd.Next(26);
string harf = ((char)harfNo).ToString();
button.ForeColor = SystemColors.ControlText;
button.BackColor = Color.DarkSalmon;
button.Text = harf;
}
button.Tag = (object)new int[] { x, y, harfNo };
button.Click += buttonClick;
button.FlatStyle = FlatStyle.Standard;
form.Controls.Add(button);
}
Application.Run(form);
}
void buttonClick(object sender, EventArgs e)
{
Button button = sender as Button;
int[] xy = button.Tag as int[];
string dikeyYazi = string.Empty;
string yatayYazi = string.Empty;
for (int i = 0; i < buttons.GetLength(0); i++)
{
dikeyYazi += ((char)(buttons[xy[0], i].Tag as int[])[2]).ToString();
}
for (int i = 0; i < buttons.GetLength(1); i++)
{
yatayYazi += ((char)(buttons[i, xy[1]].Tag as int[])[2]).ToString();
}
Console.WriteLine("Tıklanan sütundaki yazı: " + dikeyYazi);
Console.WriteLine("Tıklanan satırdaki yazı: " + yatayYazi);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment