public LocalPlaylists(IHelper aHelper, bool aAddOptionPage) { iLock = new object(); iOptionSaveDirectory = new OptionFolderPath("playlistpath", "Local playlist path", "Path where local playlists are saved", Path.Combine(aHelper.DataPath.FullName, "Playlists")); if (aAddOptionPage) { // create the options page OptionPage optionPage = new OptionPage("Local Playlists"); optionPage.Add(iOptionSaveDirectory); aHelper.AddOptionPage(optionPage); } else { aHelper.AddOption(iOptionSaveDirectory); } // listen for changes to the save directory option iOptionSaveDirectory.EventValueChanged += SaveDirectoryChanged; // initialise as being in its error state iPlaylists = null; iWrapped = new LocalPlaylistsRootError(kRootId); iWrapped.EventContentUpdated += ContentUpdated; iWrapped.EventContentAdded += ContentAdded; iWrapped.EventContentRemoved += ContentRemoved; Refresh(); }
private void InitialisePlaylistFolder() { try { iPlaylists = new LocalPlaylistsRoot(iOptionSaveDirectory.Value); } catch (Exception e) { UserLog.WriteLine(DateTime.Now + ": failed to initialise local playlist folder: " + e); iPlaylists = null; } iWrapped.EventContentUpdated -= ContentUpdated; iWrapped.EventContentAdded -= ContentAdded; iWrapped.EventContentRemoved -= ContentRemoved; if (iPlaylists != null) { iWrapped = new LocalPlaylistsRootOk(kRootId, iPlaylists); } else { iWrapped = new LocalPlaylistsRootError(kRootId); } iWrapped.EventContentUpdated += ContentUpdated; iWrapped.EventContentAdded += ContentAdded; iWrapped.EventContentRemoved += ContentRemoved; }
public LocalPlaylistsRoot(LocalPlaylistCreator aCreator, OptionFolderPath aOptionSaveDirectory) { iLock = new object(); iCreator = aCreator; iOptionSaveDirectory = aOptionSaveDirectory; // initialise as being in its error state iPlaylists = null; iWrapped = new LocalPlaylistsRootError(kRootId); iWrapped.EventContentUpdated += ContentUpdated; iWrapped.EventContentAdded += ContentAdded; iWrapped.EventContentRemoved += ContentRemoved; Refresh(); }