Ejemplo n.º 1
0
        /// <summary>
        /// Opens an existing music library
        /// </summary>
        /// <param name="libraryName"></param>
        /// <returns>MusicLibrary</returns>
        public static MusicLibrary OpenLibrary(string libraryName)
        {
            if (System.IO.File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\wamp\\" + libraryName + ".sqlite"))
            {
                MusicLibrary ml                  = new MusicLibrary(libraryName);
                string       databaseName        = libraryName + ".sqlite";
                string       sqlConnectionString = "Data Source=" + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\wamp\\" + databaseName + ";Version=3;";

                string sql = "select directory_path from library_root";

                SQLiteConnection dbConnection = new SQLiteConnection(sqlConnectionString);
                dbConnection.Open();
                SQLiteCommand command = new SQLiteCommand(sql, dbConnection);
                //SQLiteDataReader reader = command.ExecuteReader();
                //ml.LibraryRoot = reader["library_root"].ToString();
                ml.LibraryRoot = command.ExecuteScalar().ToString();

                dbConnection.Close();

                return(ml);
            }
            else
            {
                throw new LibraryNotFoundException("No library found by the name of " + libraryName);
            }
        }
Ejemplo n.º 2
0
 void HandleSelectedLibraryChangedEvent(object sender, SelectedLibraryChangedEventArgs slcea)
 {
     selectedLibrary = slcea.SelectedLibrary;
     playlistEditorControl.SelectedLibrary = selectedLibrary;
     playerControl.SelectedLibrary = selectedLibrary;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Opens an existing music library
        /// </summary>
        /// <param name="libraryName"></param>
        /// <returns>MusicLibrary</returns>
        public static MusicLibrary OpenLibrary(string libraryName)
        {
            if (System.IO.File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\wamp\\" + libraryName + ".sqlite"))
            {
                MusicLibrary ml = new MusicLibrary(libraryName);
                string databaseName = libraryName + ".sqlite";
                string sqlConnectionString = "Data Source=" + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\wamp\\" + databaseName + ";Version=3;";

                string sql = "select directory_path from library_root";

                SQLiteConnection dbConnection = new SQLiteConnection(sqlConnectionString);
                dbConnection.Open();
                SQLiteCommand command = new SQLiteCommand(sql, dbConnection);
                //SQLiteDataReader reader = command.ExecuteReader();
                //ml.LibraryRoot = reader["library_root"].ToString();
                ml.LibraryRoot = command.ExecuteScalar().ToString();

                dbConnection.Close();

                return ml;
            }
            else
                throw new LibraryNotFoundException("No library found by the name of " + libraryName);
        }
 public SelectedLibraryChangedEventArgs(MusicLibrary ml)
 {
     library = ml;
 }
Ejemplo n.º 5
0
 private void lstLibraries_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (lstLibraries.SelectedIndex == -1)
         return;
     selectedLibrary = (MusicLibrary)lstLibraries.SelectedItem;
     OnRaiseSelectedLibraryChangedEvent(new SelectedLibraryChangedEventArgs(selectedLibrary));
     Properties.Settings.Default.SelectedLibraryName = selectedLibrary.LibraryName;
     Properties.Settings.Default.Save();
 }
Ejemplo n.º 6
0
        private void btnRemoveLibrary_Click(object sender, RoutedEventArgs e)
        {
            string sMessageBoxText = "Are you sure you want to delete the library " + selectedLibrary.LibraryName + "?";
            string sCaption = "Delete Library";

            MessageBoxButton btnMessageBox = MessageBoxButton.YesNo;
            MessageBoxImage icnMessageBox = MessageBoxImage.Warning;

            MessageBoxResult result = MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox);

            if (result == MessageBoxResult.Yes)
            {
                try
                {
                    MusicLibrary.DeleteLibrary(selectedLibrary.LibraryName);
                    libraries.Remove((MusicLibrary)lstLibraries.SelectedItem);
                    lstLibraries.Items.Refresh();
                    if (lstLibraries.Items.Count > 0)
                    {
                        lstLibraries.SelectedItem = lstLibraries.Items[0];
                        selectedLibrary = (MusicLibrary)lstLibraries.SelectedItem;
                    }
                    else
                        selectedLibrary = null;
                }
                catch (Exception exc)
                {
                    Console.WriteLine(exc.Message);
                }

            }
        }
Ejemplo n.º 7
0
        void btnAddLibrary_Click(object sender, RoutedEventArgs e)
        {
            string libraryRoot;
            string libraryName;

            InputDialog iDialog = new InputDialog("Please give this library a name: ", "");
            if (iDialog.ShowDialog() == true)
            {
                libraryName = iDialog.Answer;

                FolderBrowser fb = new FolderBrowser();
                fb.IncludeFiles = false;
                fb.Description = "Please select root folder for library";
                if (fb.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    libraryRoot = fb.SelectedPath;
                    MusicLibrary ml = new MusicLibrary(libraryName, libraryRoot);
                    ml.StatusChangedEvent += HandleStatusChangedEvent;

                    Thread MyNewThread = new Thread(new ThreadStart(() =>
                    {
                        ml.CreateLibrary();

                    }));
                    MyNewThread.Start();

                    libraries.Add(ml);
                    lstLibraries.Items.Refresh();
                    lstLibraries.SelectedItem = ml;
                    selectedLibrary = ml;
                }
            }
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            MusicLibrary library;
            Console.WriteLine("Listing available libraries:");
            List<string> libraries = MusicLibrary.GetAvailableLibraries();
            foreach (string lib in libraries)
                Console.WriteLine(lib);
            Console.WriteLine("Finished listing available libraries. Press Enter to continue");
            Console.ReadLine();

            if (libraries.Count > 0)
            {
                Console.WriteLine("Opening first available library:");
                library = MusicLibrary.OpenLibrary(libraries[0]);
            }
            else
            {
                library = new MusicLibrary("Small Library", @"C:\Users\aljordan\Music");
            }

            //library.CreateLibrary();
            //Console.WriteLine("Finished processing.  Press Enter to continue.");
            //Console.ReadLine();

            Console.WriteLine("Listing all genres:");
            List<string> genres = library.GetGenres();
            foreach (string s in genres)
                Console.WriteLine(s);

            Console.WriteLine("\nPress return to continue");
            Console.ReadLine();

            Console.WriteLine("Listing genres filtered by the word rock:");
            List<string> filteredGenres = library.GetGenres("rock");
            foreach (string s in filteredGenres)
                Console.WriteLine(s);

            Console.WriteLine("\nPress return to continue");
            Console.ReadLine();

            Console.WriteLine("List all artists:");
            List<string> artists = library.GetArtists();
            foreach (string s in artists)
                Console.WriteLine(s);

            Console.WriteLine("\nPress return to continue");
            Console.ReadLine();

            Console.WriteLine("Listing artists filtered by the word Dave:");
            List<string> filteredArtists = library.GetArtists("Dave");
            foreach (string s in filteredArtists)
                Console.WriteLine(s);

            Console.WriteLine("\nPress return to continue");
            Console.ReadLine();

            Console.WriteLine("Listing all albums:");
            List<string> albums = library.GetAlbums();
            foreach (string s in albums)
                Console.WriteLine(s);

            Console.WriteLine("\nPress return to continue");
            Console.ReadLine();

            Console.WriteLine("Listing albums filtered by the word rock:");
            List<string> filteredAlbums = library.GetAlbums("rock");
            foreach (string s in filteredAlbums)
                Console.WriteLine(s);

            Console.WriteLine("\nPress return to continue");
            Console.ReadLine();

            Console.WriteLine("Listing all song titles:");
            List<string> songs = library.GetSongTitles();
            foreach (string s in songs)
                Console.WriteLine(s);

            Console.WriteLine("\nPress return to continue");
            Console.ReadLine();

            Console.WriteLine("Listing song titles filtered by the word rock:");
            List<string> filteredSongs = library.GetSongTitles("rock");
            foreach (string s in filteredSongs)
                Console.WriteLine(s);

            Console.WriteLine("\nPress return to continue");
            Console.ReadLine();

            Console.WriteLine("Listing all track objects:");
            List<Track> tracks = library.GetSongs();
            foreach (Track t in tracks)
                Console.WriteLine(t.Title);

            Console.WriteLine("\nPress return to continue");
            Console.ReadLine();

            Console.WriteLine("Listing track objects filtered by the word rock:");
            List<Track> filteredTracks = library.GetSongs("rock");
            foreach (Track t in filteredTracks)
                Console.WriteLine(t.Title);

            Console.WriteLine("\nPress return to quit");
            Console.ReadLine();
        }