Created
April 14, 2013 19:51
-
-
Save jamiees2/5383951 to your computer and use it in GitHub Desktop.
This file contains 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
private void CreateButtons() | |
{ | |
int y = 50;//y-hnit takkans | |
int x = 0;//x-hnit takkans | |
int width = 35;//Breidd takkans | |
int height = 35;//Hæð takkans | |
int xMargin = 3;//x - Margin takkans | |
int yMargin = 3;//y - Margin takkans | |
seats.Children.Clear();//Hreinsar sætin | |
Button tempButton;//Býr til takka | |
for (int i = 0; i < 10; i++)//fyrir y < 10 | |
{ | |
for (int j = 0; j < 15; j++)//fyrir x < 15 | |
{ | |
tempButton = new Button();//Skilgreinir nýjan takka | |
tempButton.Height = width;//Setur hæð | |
tempButton.Width = height;//Setur breidd | |
//Setur staðsetningu | |
tempButton.Margin = new Thickness(x, y, 0, 0); | |
tempButton.VerticalAlignment = VerticalAlignment.Top; | |
//Staðsetningin á að miðast við top-staðsetningu 0 | |
tempButton.HorizontalAlignment = HorizontalAlignment.Left; | |
//Staðsetningin á að miðast við left-staðsetningu 0 | |
tempButton.Background = new SolidColorBrush(Color.FromRgb(138,43,226));//Bakgrunnsliturinn | |
tempButton.Foreground = new SolidColorBrush(Colors.Black);//Forgrunnsliturinn | |
tempButton.Content = rowNumbers[i].ToString() + (j + 1).ToString();//Setur það sem stendur á takkanum | |
tempButton.Tag = "Empty";//Takkinn er ekki bókaður né seldur | |
tempButton.Focusable = false;//Lagar pirrandi effect sem kemur | |
tempButton.Click += new RoutedEventHandler(MainWindow_Click);//Setur event handler fyrir click | |
//tengir alla takkana við aðferðina MainWindow_Click | |
seats.Children.Add(tempButton);//Bætir við grid containerinn | |
x = x + width + xMargin;//Bætir við x | |
} | |
y = y + height + yMargin;//Bætir við y | |
x = 0;//byrjar á x = 0 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment