private void itemBox_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (MainMenu.ChosenIsCommon()) { try { _chosencommon = itemBox.SelectedItem as CommonRecipes; foreach (var item in MainMenu.CommonList()) { if (_chosencommon == item) { _indexofitemA = MainMenu.CommonList().IndexOf(item); } } if (LoginPage.IsLogged()) { _chosencommon = itemBox.SelectedItem as CommonRecipes; foreach (var item in MainMenu.UsersList()) { if (_chosencommon == item) { _indexofitemU = MainMenu.UsersList().IndexOf(item); } } } RecipeWindow rw = new RecipeWindow(); rw.Show(); } catch { } } else { try { _chosengame = itemBox.SelectedItem as GameRecipes; foreach (var item in MainMenu.GameList()) { if (_chosengame == item) { _indexofitemA = MainMenu.GameList().IndexOf(item); } } RecipeWindow rw = new RecipeWindow(); rw.Show(); } catch { } } }
private void Button_Click(object sender, RoutedEventArgs e) { if (CheckBoxes()) { CommonRecipes _commonRecipe = new CommonRecipes(_kind, _name, _recipe, _link, _time); MainMenu.CommonList().Add(_commonRecipe); if (LoginPage.IsLogged()) { MainMenu.UsersList().Add(_commonRecipe); Save(MainMenu.UsersList(), 2); } Save(MainMenu.CommonList(), 1); ClearAll(); FillComboBox(); _kind = _name = _recipe = _link = _time = null; // Pages.MainMenu.LoadData(); не работает, приходится использовать кнопку "Refresh" с точно таким же методом. } else { MessageBox.Show("Not all fields are filled in."); } }