public gamePage() { InitializeComponent(); if (!LoginPage.IsLogged()) { editButton.IsEnabled = false; saveButton.IsEnabled = false; } gameBox.Text = RecipePage.ChosenGame().Game; gameBox.IsReadOnly = true; nameBox.Text = RecipePage.ChosenGame().Name; _tblist.Add(nameBox); linkBox.Text = RecipePage.ChosenGame().Link; _tblist.Add(linkBox); ingBox.Text = RecipePage.ChosenGame().Ingredients; _tblist.Add(ingBox); foreach (var box in _tblist) { box.IsReadOnly = true; } }
private void saveButton_Click(object sender, RoutedEventArgs e) { int _mistakes = 0; DeleteSpaces(gameBox); gameBox.ItemsSource = null; foreach (var box in _tblist) { DeleteSpaces(box); } if (gameBox.Text == "") { _mistakes += 1; } if (nameBox.Text == "") { _mistakes += 1; } if (ingBox.Text == "") { _mistakes += 1; } if (_mistakes == 0) { RecipePage.ChosenGame().Game = gameBox.Text; RecipePage.ChosenGame().Name = nameBox.Text; RecipePage.ChosenGame().Link = linkBox.Text; RecipePage.ChosenGame().Ingredients = ingBox.Text; MainMenu.GameList()[RecipePage.IndexOfItem()] = RecipePage.ChosenGame(); } else { MessageBox.Show("Incorrect data was entered"); gameBox.Text = RecipePage.ChosenGame().Game; nameBox.Text = RecipePage.ChosenGame().Name; linkBox.Text = RecipePage.ChosenGame().Link; ingBox.Text = RecipePage.ChosenGame().Ingredients; } }