private void DataGridViewCell_Click(object sender, DataGridViewCellEventArgs e) { int count; try { using (db = new DataModelContainer()) { db.Database.CreateIfNotExists(); count = db.GameSet.Count(); if (count != 0) { serverInit.Remove(db.GameSet.ToList().ElementAt(e.RowIndex).Id); ((Form)((DataGridView)sender).Parent).Close(); } } } catch (Exception ex) { recordBase.ErrorBase(ex); } }
private void OldGame() { while (true) { Console.Clear(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Выберите сохранённую игру. Для удаления игры нажмите Delete"); Console.WriteLine(string.Format("| {0,-20} | {1,-20} | {2,-20} | {3,-20} | {4,-20}", "Идентификатор", "Тип игры", "Итерация", "Количество строк", "Количество столбцов")); int i = 0; try { using (db = new DataModelContainer()) { int count = db.GameSet.Count(); if (count == 0) { break; } menu3 = new string[count]; foreach (var item in db.GameSet) { menu3[i] = string.Format("| {0,-20} | {1,-20} | {2,-20} | {3,-20} | {4,-20}", item.Id, item.Type, item.Iteration, item.SizeX, item.SizeY); i++; } join = string.Join("\n", menu3); Console.ForegroundColor = ConsoleColor.White; Console.Write(join); Console.SetCursorPosition(0, choise3 + 2); Console.BackgroundColor = ConsoleColor.DarkGreen; Console.WriteLine(menu3[choise3]); Console.ResetColor(); answer = Console.ReadKey(true); if (answer.Key == ConsoleKey.Escape) { exit = true; break; } else if (answer.Key == ConsoleKey.Enter) { options.gameProperty.SizeX = db.GameSet.ToList().ElementAt(choise3).SizeX; options.gameProperty.SizeY = db.GameSet.ToList().ElementAt(choise3).SizeY; Move(db.GameSet.ToList().ElementAt(choise3).Type); serverInit.RunSave(db.GameSet.ToList().ElementAt(choise3).Id, db.GameSet.ToList().ElementAt(choise3).Iteration, igame); Begin(); } else if (answer.Key == ConsoleKey.Delete) { serverInit.Remove(db.GameSet.ToList().ElementAt(choise3).Id); } else if (answer.Key == ConsoleKey.UpArrow) { choise3--; } else if (answer.Key == ConsoleKey.DownArrow) { choise3++; } if (choise3 < 0) { choise3 = menu3.Length - 1; } else if (choise3 == menu3.Length) { choise3 = 0; } } } catch (Exception ex) { recordBase.ErrorBase(ex); } } }