/// <summary> /// Initializes a new instance of the <see cref="BrowserViewModel" /> class. /// </summary> /// <param name="scannerService">The scanner.</param> /// <param name="dispatcher">The dispatcher.</param> /// <param name="filteringService">The filtering service.</param> /// <param name="menuService">Blah</param> /// <param name="referenceAdapters">The reference adapters.</param> /// <param name="publicTransport"></param> public BrowserViewModel(IDirectoryScannerService <StorableTaggedFile> scannerService, IDispatcher dispatcher, IFilteringService filteringService, IMenuService menuService, IReferenceAdapters referenceAdapters, IPublicTransport publicTransport) { this.publicTransport = Guard.IsNull(() => publicTransport); scannerService.Guard("scannerService"); dispatcher.Guard("dispatcher"); filteringService.Guard("filteringService"); menuService.Guard("menuService"); referenceAdapters.Guard("referenceAdapters"); // TODO: Localize menuService.Register(new CallbackMenuItem(null, "Library", new CallbackMenuItem(OnAddFiles, "Add Files"))); this.scannerService = Guard.IsNull(() => scannerService); this.dispatcher = Guard.IsNull(() => dispatcher); this.filteringService = Guard.IsNull(() => filteringService); this.scannerService.ScanCompleted += ScannerServiceOnScanCompleted; this.scannerService.ScanProgress += ScannerServiceOnScanProgress; localizedMemberPaths = filteringService.FilterColumns.Select(x => new Alias <string>(x, x)).ToList(); // TODO: Localize searchTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(500) }; searchTimer.Tick += SearchTimerOnTick; FirstColumn = new DynamicColumnViewModel(dispatcher); SecondColumn = new DynamicColumnViewModel(dispatcher); ThirdColumn = new DynamicColumnViewModel(dispatcher); InitViewModels(); BuildColumns(); InitFirstColumn(); }
/// <summary> /// Initializes a new instance of the <see cref="FilteringService" /> class. /// </summary> /// <param name="libraryManagerService">The library manager service.</param> /// <param name="referenceAdapters">The reference adapters.</param> public FilteringService(ILibraryManagerService libraryManagerService, IReferenceAdapters referenceAdapters) { libraryManagerService.Guard("libraryManagerService"); referenceAdapters.Guard("referenceAdapters"); this.libraryManagerService = libraryManagerService; this.referenceAdapters = referenceAdapters; Initialize(); }
/// <summary> /// Loads the references of this file. /// </summary> /// <param name="referenceAdapters">The reference adapters.</param> /// <returns></returns> public virtual StorableTaggedFile LoadReferences(IReferenceAdapters referenceAdapters) { referenceAdapters.Guard("referenceAdapters"); Album = referenceAdapters.AlbumAdapter.GetFirst(a => a.Id == AlbumId) ?? Album; Genre = referenceAdapters.GenreAdapter.GetFirst(a => a.Id == GenreId) ?? Genre; Title = referenceAdapters.TitleAdapter.GetFirst(a => a.Id == TitleId) ?? Title; Artist = referenceAdapters.ArtistAdapter.GetFirst(a => a.Id == ArtistId) ?? Artist; Year = referenceAdapters.YearAdapter.GetFirst(a => a.Id == YearId) ?? Year; WasFullyLoaded = true; return(this); }
/// <summary> /// Initializes a new instance of the <see cref="TaggedFilePersister" /> class. /// </summary> /// <param name="fileAdapter">The file adapter.</param> /// <param name="referenceAdapters">The reference adapters.</param> /// <param name="configurationManager">The configuration manager.</param> public TaggedFilePersister(IDataAdapter <StorableTaggedFile> fileAdapter, IReferenceAdapters referenceAdapters, IConfigurationManager configurationManager) { fileAdapter.Guard("fileAdapter"); referenceAdapters.Guard("referenceAdapters"); configurationManager.Guard("configurationManager"); this.fileAdapter = fileAdapter; this.referenceAdapters = referenceAdapters; maxCacheSize = configurationManager.GetValue("StorableTaggedFilePersister.MaxCacheItems", 200); CreateIndices(); }
/// <summary> /// Initializes a new instance of the <see cref="LazyLoadedTaggedFile" /> class. /// </summary> /// <param name="adapters">The adapters.</param> /// <param name="original">The original.</param> public LazyLoadedTaggedFile(IReferenceAdapters adapters, StorableTaggedFile original) { adapters.Guard("adapters"); original.Guard("original"); this.adapters = adapters; Duration = original.Duration; AlbumId = original.AlbumId; ArtistId = original.ArtistId; Comment = original.Comment; Filename = original.Filename; GenreId = original.GenreId; Id = original.Id; TitleId = original.TitleId; YearId = original.YearId; }
/// <summary> /// Initializes a new instance of the <see cref="PlaylistService" /> class. /// </summary> /// <param name="publicTransport">The public transport.</param> /// <param name="referenceAdapters">The reference adapters.</param> /// <param name="threadManager">The thread manager.</param> /// <param name="configurationManager">The configuration manager.</param> /// <param name="fileAdapter"></param> public PlaylistService(IPublicTransport publicTransport, IReferenceAdapters referenceAdapters, IThreadManager threadManager, IConfigurationManager configurationManager, IDataAdapter <StorableTaggedFile> fileAdapter) { publicTransport.Guard("publicTransport"); referenceAdapters.Guard("referenceAdapters"); threadManager.Guard("threadManager"); this.publicTransport = publicTransport; this.referenceAdapters = referenceAdapters; this.threadManager = threadManager; this.fileAdapter = fileAdapter; playList = configurationManager.GetValue("Playlist.LastPlaylist", new Guid[0], KnownConfigSections.Hidden); LoadPlaylist(playList.Value); shuffleValue = configurationManager.GetValue("Playlist.Shuffle", false, KnownConfigSections.Hidden); shuffleValue.ValueChanged += ShuffleValueOnValueChanged; publicTransport.ApplicationEventBus.Subscribe <ShutdownEvent>(OnShutdown); SubscribeCommands(); }
/// <summary> /// Initializes a new instance of the <see cref="PlaylistService" /> class. /// </summary> /// <param name="publicTransport">The public transport.</param> /// <param name="referenceAdapters">The reference adapters.</param> /// <param name="threadManager">The thread manager.</param> /// <param name="configurationManager">The configuration manager.</param> /// <param name="serializerService">The serializer service.</param> /// <param name="logger">The logger.</param> public PlaylistService(IPublicTransport publicTransport, IReferenceAdapters referenceAdapters, IThreadManager threadManager, IConfigurationManager configurationManager, ISerializerService serializerService, ILogger logger) : base(logger) { publicTransport.Guard("publicTransport"); referenceAdapters.Guard("referenceAdapters"); threadManager.Guard("threadManager"); serializerService.Guard("serializerService"); logger.Guard("logger"); this.publicTransport = publicTransport; this.referenceAdapters = referenceAdapters; this.threadManager = threadManager; this.logger = logger; this.serializerService = serializerService; playlistRelPath = configurationManager.GetValue("Playlist Relative Path", ".\\Playlist.bin"); LoadPlaylist(playlistRelPath.Value); publicTransport.ApplicationEventBus.Subscribe <ShutdownEvent>(OnShutdown); }