/// <summary> /// Fills the genre template list collection with default genre directories. /// </summary> public static void FillGenreTemplateListCollection() { MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name; GenreDefaultListCollection.ClearCollection(); GenreDefaultListCollection.AddItem("#"); GenreDefaultListCollection.AddItem(Bigbands); GenreDefaultListCollection.AddItem(Bluegrass); GenreDefaultListCollection.AddItem(Blues); GenreDefaultListCollection.AddItem(Cajun); GenreDefaultListCollection.AddItem(Calypso); GenreDefaultListCollection.AddItem(Caribbean); GenreDefaultListCollection.AddItem(Celtic); GenreDefaultListCollection.AddItem(Children); GenreDefaultListCollection.AddItem(Classical); GenreDefaultListCollection.AddItem(Country); GenreDefaultListCollection.AddItem(Dance); GenreDefaultListCollection.AddItem(EasyListening); GenreDefaultListCollection.AddItem(Finnish); GenreDefaultListCollection.AddItem(HipHop); GenreDefaultListCollection.AddItem(Holiday); GenreDefaultListCollection.AddItem(Insperational); GenreDefaultListCollection.AddItem(Instrumental); GenreDefaultListCollection.AddItem(Irish); GenreDefaultListCollection.AddItem(Japan); GenreDefaultListCollection.AddItem(Jazz); GenreDefaultListCollection.AddItem(Latin); GenreDefaultListCollection.AddItem(NewAge); GenreDefaultListCollection.AddItem(Opera); GenreDefaultListCollection.AddItem(Polka); GenreDefaultListCollection.AddItem(Pop); GenreDefaultListCollection.AddItem(Rap); GenreDefaultListCollection.AddItem(RB); GenreDefaultListCollection.AddItem(Reggae); GenreDefaultListCollection.AddItem(Rock); GenreDefaultListCollection.AddItem(Soul); GenreDefaultListCollection.AddItem(SoundTrack); GenreDefaultListCollection.AddItem(SouthAmerica); GenreDefaultListCollection.AddItem(Vocals); GenreDefaultListCollection.AddItem(WorkOut); }
/// <summary> /// If the user has made a back up file then they can restore it from here. /// </summary> public static void RestoreGenreDefaultListFromBackup() { try { MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name; var validate = false; GenreDefaultListCollection.ClearCollection(); using (var ofd = new OpenFileDialog()) { ofd.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; ofd.FilterIndex = 2; ofd.RestoreDirectory = true; ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); if (ofd.ShowDialog() == DialogResult.OK) { using (var sr = new StreamReader(ofd.FileName)) { string genreName; while ((genreName = sr.ReadLine()) != null) { if (!validate) { validate = CheckForValidGenreName(genreName); } else { if (!string.IsNullOrEmpty(genreName)) { GenreDefaultListCollection.AddItem(genreName); } } } } } } if (GenreDefaultListCollection.ItemCount() <= 0) { return; } MyMessages.QuestionMessage = "This will overwrite your current genre default list." + " Do you wish to continue."; var result = MyMessages.ShowQuestionMessage(MyMessages.QuestionMessage, MyMessages.NameOfClass); if (result == DialogResult.Yes) { GenreFileReadWrite.WriteGenreTemplateList(); } } catch (FileNotFoundException ex) { MyMessages.ErrorMessage = "Not a valid path. Exiting operation."; MyMessages.BuildErrorString( MyMessages.NameOfClass, MyMessages.NameOfMethod, MyMessages.ErrorMessage, ex.Message); } catch (ArgumentNullException ex) { MyMessages.ErrorMessage = "Not a valid path. Exiting operation."; MyMessages.BuildErrorString( MyMessages.NameOfClass, MyMessages.NameOfMethod, MyMessages.ErrorMessage, ex.Message); } }