public Deck Clone() { var clone_deck = new Deck(); foreach (Word w in dc) { clone_deck.AddWord(w.Clone()); } return clone_deck; }
public void _OpenDeck(string FileName, int GameType) { //this.Title = "Pamya - " + fname; //FIXME CurrentDeckFolder = DecksFolder + @"\" + FileName; DeckFile = CurrentDeckFolder + @"\deck.sqlite"; UserFile = CurrentDeckFolder + @"\userdata.sqlite"; //I feel like this is too much overhead SQLiteConnection deckdbcon; deckdbcon = new SQLiteConnection("Data Source=" + DeckFile + ";Version=3;"); deckdbcon.Open(); SQLiteConnection userdbcon; userdbcon = new SQLiteConnection("Data Source=" + UserFile + ";Version=3;"); userdbcon.Open(); string sql = "SELECT * FROM deck ORDER BY id ASC"; SQLiteCommand command = new SQLiteCommand(sql, deckdbcon); SQLiteDataReader deck_reader = command.ExecuteReader(); CurrentDeck = new Deck(); while (deck_reader.Read()) { var word = new Word(deck_reader["question"].ToString(), deck_reader["answer"].ToString()); word.id = Convert.ToInt32(deck_reader["id"]); word.wav_file_loc = deck_reader["wavfileloc"].ToString(); word.guid = deck_reader["guid"].ToString(); word.example = deck_reader["example"].ToString(); word.image_file_location = deck_reader["imagefileloc"].ToString(); var user_sql = "SELECT * FROM deck WHERE guid='" + deck_reader["guid"].ToString() + "'"; var user_command = new SQLiteCommand(user_sql, userdbcon); try { var user_reader = user_command.ExecuteReader(); user_reader.Read(); word.EF = Convert.ToDouble(user_reader["ef"]); word.I = Convert.ToDouble(user_reader["i"]); word.n = Convert.ToInt32(user_reader["n"]); word.studied = Convert.ToBoolean(user_reader["studied"]); word.time_due = Convert.ToInt32(user_reader["timedue"]); user_reader.Close(); CurrentDeck.AddWord(word); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } deck_reader.Close(); userdbcon.Close(); deckdbcon.Close(); //TODO //FIND OUT WHICH GAME IS PLAYED //OPEN THE GAME GameChangeDelegates[GameType + 1].DynamicInvoke(); // +1 as 0 is the mainmenu page }