/// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="windowManager">WindowManager used to display dialogs.</param>
 /// <param name="client">Factory for creating <see cref="ILastFMClient"/>s.</param>
 /// <param name="scrobblerFactory">Factory for creating <see cref="IAuthScrobbler"/>s.</param>
 /// <param name="localFileFactory">Factory for creating <see cref="Scrobbling.Data.ILocalFile"/>s.</param>
 /// <param name="fileOperator">FileOperator for interfacing with the hard disk.</param>
 /// <param name="directoryOperator">DirectoryOperator for operating with directories.</param>
 /// <param name="serializer">Serializer for <see cref="User"/>s.</param>
 /// <param name="logger">Logger used to log status messages.</param>
 /// <param name="gitHubClient">GitHub client to check for updates.</param>
 /// <param name="processManager">ProcessManager for working with processor functions.</param>
 public MainViewModel(IExtendedWindowManager windowManager, ILastFMClient client, IScrobblerFactory scrobblerFactory, ILocalFileFactory localFileFactory,
                      IFileOperator fileOperator, IDirectoryOperator directoryOperator, ISerializer serializer, ILogger logger, IGitHubClient gitHubClient, IProcessManager processManager)
 {
     _windowManager    = windowManager ?? throw new ArgumentNullException(nameof(windowManager));
     _client           = client ?? throw new ArgumentNullException(nameof(client));
     _scrobblerFactory = scrobblerFactory ?? throw new ArgumentNullException(nameof(scrobblerFactory));
     _fileOperator     = fileOperator ?? throw new ArgumentNullException(nameof(fileOperator));
     _logger           = logger;
     SetupViewModels(localFileFactory, directoryOperator, serializer, gitHubClient, processManager);
     TitleString   = "Last.fm Scrubbler WPF Beta " + Assembly.GetExecutingAssembly().GetName().Version;
     CurrentStatus = "Waiting to scrobble...";
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="windowManager">WindowManager used to display dialogs.</param>
 /// <param name="clientFactory">Factory for creating <see cref="ILastFMClient"/>s.</param>
 /// <param name="scrobblerFactory">Factory for creating <see cref="IAuthScrobbler"/>s.</param>
 /// <param name="localFileFactory">Factory for creating <see cref="ILocalFile"/>s.</param>
 /// <param name="fileOperator">FileOperator for interfacing with the hard disk.</param>
 /// <param name="directoryOperator">DirectoryOperator for operating with directories.</param>
 /// <param name="userSerializer">Serializer for <see cref="User"/>s.</param>
 public MainViewModel(IExtendedWindowManager windowManager, ILastFMClientFactory clientFactory, IScrobblerFactory scrobblerFactory, ILocalFileFactory localFileFactory,
                      IFileOperator fileOperator, IDirectoryOperator directoryOperator, ISerializer <User> userSerializer)
 {
     _windowManager       = windowManager;
     _lastFMClientFactory = clientFactory;
     _scrobblerFactory    = scrobblerFactory;
     _fileOperator        = fileOperator;
     TitleString          = "Last.fm Scrubbler WPF " + Assembly.GetExecutingAssembly().GetName().Version;
     _client = _lastFMClientFactory.CreateClient(APIKEY, APISECRET);
     SetupViewModels(localFileFactory, directoryOperator, userSerializer);
     CurrentStatus = "Waiting to scrobble...";
 }
Exemplo n.º 3
0
        /// <summary>
        /// Creates the ViewModels.
        /// </summary>
        /// <param name="windowManager">WindowManager used to display dialogs.</param>
        /// <param name="localFileFactory">Factory used to create <see cref="Scrobbling.Data.ILocalFile"/>s.</param>
        /// <param name="fileOperator">FileOperator used to interface with files.</param>
        /// <param name="lastFMClient">Last.fm client.</param>
        private void CreateViewModels(IExtendedWindowManager windowManager, ILocalFileFactory localFileFactory, IFileOperator fileOperator, ILastFMClient lastFMClient)
        {
            var manualScrobbleViewModel = new ManualScrobbleViewModel(windowManager);

            manualScrobbleViewModel.StatusUpdated += Scrobbler_StatusUpdated;
            var friendScrobbleViewModel = new FriendScrobbleViewModel(windowManager, lastFMClient.User);

            friendScrobbleViewModel.StatusUpdated += Scrobbler_StatusUpdated;
            var databaseScrobbleViewModel = new DatabaseScrobbleViewModel(windowManager, lastFMClient.Artist, lastFMClient.Album);

            databaseScrobbleViewModel.StatusUpdated += Scrobbler_StatusUpdated;
            var csvScrobbleViewModel = new CSVScrobbleViewModel(windowManager, new CSVTextFieldParserFactory(), fileOperator);

            csvScrobbleViewModel.StatusUpdated += Scrobbler_StatusUpdated;
            var fileScrobbleViewModel = new FileScrobbleViewModel(windowManager, localFileFactory, fileOperator);

            fileScrobbleViewModel.StatusUpdated += Scrobbler_StatusUpdated;
            var mediaPlayerDatabaseScrobbleViewModel = new MediaPlayerDatabaseScrobbleViewModel(windowManager);

            mediaPlayerDatabaseScrobbleViewModel.StatusUpdated += Scrobbler_StatusUpdated;
            var iTunesScrobbleVM = new ITunesScrobbleViewModel(windowManager, lastFMClient.Track, lastFMClient.Album, lastFMClient.Auth);

            iTunesScrobbleVM.StatusUpdated += Scrobbler_StatusUpdated;
            // todo: put back in once local api is working again
            //var spotifyScrobbleVM = new SpotifyScrobbleViewModel(windowManager, lastFMClient.Track, lastFMClient.Album, lastFMClient.Auth);
            //spotifyScrobbleVM.StatusUpdated += Scrobbler_StatusUpdated;
            var setlistFMScrobbleVM = new SetlistFMScrobbleViewModel(windowManager, lastFMClient.Artist);

            setlistFMScrobbleVM.StatusUpdated += Scrobbler_StatusUpdated;
            var cacheScrobblerVM = new CacheScrobblerViewModel(windowManager);

            cacheScrobblerVM.StatusUpdated += Scrobbler_StatusUpdated;

            ActivateItem(manualScrobbleViewModel);
            ActivateItem(friendScrobbleViewModel);
            ActivateItem(databaseScrobbleViewModel);
            ActivateItem(csvScrobbleViewModel);
            ActivateItem(fileScrobbleViewModel);
            ActivateItem(mediaPlayerDatabaseScrobbleViewModel);
            ActivateItem(iTunesScrobbleVM);
            //ActivateItem(spotifyScrobbleVM);
            ActivateItem(setlistFMScrobbleVM);
            ActivateItem(cacheScrobblerVM);

            // this one should be selected
            ActivateItem(manualScrobbleViewModel);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="windowManager">WindowManager used to display dialogs.</param>
 /// <param name="localFileFactory">Factory used to create <see cref="Scrobbling.Data.ILocalFile"/>s.</param>
 /// <param name="fileOperator">FileOperator used to interface with files.</param>
 /// <param name="lastFMClient">Last.fm client.</param>
 public ScrobblerViewModel(IExtendedWindowManager windowManager, ILocalFileFactory localFileFactory, IFileOperator fileOperator, ILastFMClient lastFMClient)
 {
     DisplayName = "Scrobbler";
     CreateViewModels(windowManager, localFileFactory, fileOperator, lastFMClient);
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="windowManager">WindowManager used to display dialogs.</param>
 /// <param name="localFileFactory">Factory used to create <see cref="Data.ILocalFile"/>s.</param>
 /// <param name="fileOperator">FileOperator used to interface with files.</param>
 /// <param name="lastFMClient">Last.fm client.</param>
 /// <param name="discogsClient">Client used to interact with Discogs.com</param>
 /// <param name="fileParserFactory">Factory for creating <see cref="IFileParser"/></param>
 public ScrobblerViewModel(IExtendedWindowManager windowManager, ILocalFileFactory localFileFactory, IFileOperator fileOperator, ILastFMClient lastFMClient,
                           IDiscogsDataBaseClient discogsClient, IFileParserFactory fileParserFactory)
 {
     DisplayName = "Scrobbler";
     CreateViewModels(windowManager, localFileFactory, fileOperator, lastFMClient, discogsClient, fileParserFactory);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Creates the ViewModels.
        /// </summary>
        /// <param name="windowManager">WindowManager used to display dialogs.</param>
        /// <param name="localFileFactory">Factory used to create <see cref="Data.ILocalFile"/>s.</param>
        /// <param name="fileOperator">FileOperator used to interface with files.</param>
        /// <param name="lastFMClient">Last.fm client.</param>
        /// <param name="discogsClient">Client used to interact with Discogs.com</param>
        /// <param name="fileParserFactory">Factory for creating <see cref="IFileParser"/></param>
        private ScrobbleViewModelBase[] CreateViewModels(IExtendedWindowManager windowManager, ILocalFileFactory localFileFactory, IFileOperator fileOperator, ILastFMClient lastFMClient,
                                                         IDiscogsDataBaseClient discogsClient, IFileParserFactory fileParserFactory)
        {
            var manualScrobbleViewModel = new ManualScrobbleViewModel(windowManager);

            manualScrobbleViewModel.StatusUpdated += Scrobbler_StatusUpdated;
            var friendScrobbleViewModel = new FriendScrobbleViewModel(windowManager, lastFMClient.User);

            friendScrobbleViewModel.StatusUpdated += Scrobbler_StatusUpdated;
            var databaseScrobbleViewModel = new DatabaseScrobbleViewModel(windowManager, lastFMClient.Artist, lastFMClient.Album, discogsClient);

            databaseScrobbleViewModel.StatusUpdated += Scrobbler_StatusUpdated;
            var csvScrobbleViewModel = new FileParseScrobbleViewModel(windowManager, fileParserFactory, fileOperator);

            csvScrobbleViewModel.StatusUpdated += Scrobbler_StatusUpdated;
            var fileScrobbleViewModel = new FileScrobbleViewModel(windowManager, localFileFactory, fileOperator);

            fileScrobbleViewModel.StatusUpdated += Scrobbler_StatusUpdated;
            var mediaPlayerDatabaseScrobbleViewModel = new MediaPlayerDatabaseScrobbleViewModel(windowManager);

            mediaPlayerDatabaseScrobbleViewModel.StatusUpdated += Scrobbler_StatusUpdated;
            var iTunesScrobbleVM = new ITunesScrobbleViewModel(windowManager, lastFMClient.Track, lastFMClient.Album, lastFMClient.Artist);

            iTunesScrobbleVM.StatusUpdated += Scrobbler_StatusUpdated;
            // todo: put back in once local api is working again
            //var spotifyScrobbleVM = new SpotifyScrobbleViewModel(windowManager, lastFMClient.Track, lastFMClient.Album, lastFMClient.Auth);
            //spotifyScrobbleVM.StatusUpdated += Scrobbler_StatusUpdated;
            var setlistFMScrobbleVM = new SetlistFMScrobbleViewModel(windowManager, lastFMClient.Artist);

            setlistFMScrobbleVM.StatusUpdated += Scrobbler_StatusUpdated;
            var cacheScrobblerVM = new CacheScrobblerViewModel(windowManager);

            cacheScrobblerVM.StatusUpdated += Scrobbler_StatusUpdated;

            return(new ScrobbleViewModelBase[] { manualScrobbleViewModel, friendScrobbleViewModel, databaseScrobbleViewModel, csvScrobbleViewModel,
                                                 fileScrobbleViewModel, mediaPlayerDatabaseScrobbleViewModel, iTunesScrobbleVM, setlistFMScrobbleVM, cacheScrobblerVM });
        }