示例#1
0
        public static List <Sound> FetchSounds()
        {
            cnx.Open();
            List <Sound>  sounds = new List <Sound>();
            SQLiteCommand cmd    = new SQLiteCommand(cnx)
            {
                CommandText = "SELECT name, pathToSound, pathToImage, key FROM sounds;"
            };
            SQLiteDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                if (reader.IsDBNull(3))
                {
                    sounds.Add(SQLiteHandler.CreateSoundFromSQL(reader.GetString(0), reader.GetString(1), reader.GetString(2), null));
                }
                else
                {
                    sounds.Add(SQLiteHandler.CreateSoundFromSQL(reader.GetString(0), reader.GetString(1), reader.GetString(2), reader.GetString(3)));
                }
            }
            reader.Close();
            cnx.Close();
            return(sounds);
        }
示例#2
0
 public MainWindow()
 {
     InitializeComponent();
     this.sounds = new ObservableCollection <Sound>();
     DataContext = this.sounds;
     this.lb_sounds.ItemsSource = this.sounds;
     this.keysActivated         = true;
     foreach (Sound s in SQLiteHandler.InitializeSQLite("sounds.sqlite"))
     {
         this.sounds.Add(s);
     }
 }
示例#3
0
 public static List <Sound> InitializeSQLite(string pathToDB)
 {
     if (!File.Exists(pathToDB))
     {
         SQLiteConnection.CreateFile(pathToDB);
         cnx = new SQLiteConnection(String.Format("Data Source={0};Version=3;", pathToDB));
         CreateTables();
     }
     else
     {
         cnx = new SQLiteConnection(String.Format("Data Source={0};Version=3;", pathToDB));
         return(SQLiteHandler.FetchSounds());
     }
     return(new List <Sound>());
 }
示例#4
0
 private void SaveSounds(object sender, MouseButtonEventArgs e)
 {
     SQLiteHandler.SaveSoundsToDatabase(new List <Sound>(this.sounds));
 }