예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ComponentBase" /> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="playlistService">The playlist service.</param>
 /// <param name="player">The player.</param>
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="configurationManager">The configuration manager.</param>
 /// <param name="hotkeyService">The hotkey service.</param>
 public NonManagingPlayerService(ILogger logger,
                                 IPlaylistService playlistService,
                                 IAudioPlayer player,
                                 IPublicTransport publicTransport,
                                 IConfigurationManager configurationManager,
                                 IGlobalHotkeyService hotkeyService)
     : base(logger)
 {
     playlistService.Guard("playlistService");
     player.Guard("player");
     publicTransport.Guard("publicTransport");
     configurationManager.Guard("configurationManager");
     state = PlayingState.Stopped;
     this.playlistService      = playlistService;
     this.player               = player;
     this.publicTransport      = publicTransport;
     this.configurationManager = configurationManager;
     this.hotkeyService        = hotkeyService;
     publicTransport.ApplicationEventBus.Subscribe <PlaylistUpdatedEvent>(OnPlaylistUpdated);
     publicTransport.ApplicationEventBus.Subscribe <ShuffleChangedEvent>(OnShuffleChanged);
     prebufferSongs                 = configurationManager.GetValue("PlayerService.PrebufferSongs", 2);
     PlayNextThreshold              = configurationManager.GetValue("PlayerService.PlayNextThreshnoldMs", 500d);
     TrackInterchangeCrossfadeTime  = configurationManager.GetValue("PlayerService.TrackInterchangeCrossfadeTimeMs", 500d);
     TrackInterchangeCrossFadeSteps = configurationManager.GetValue("PlayerService.TrackInterchangeCrossfadeSteps", 50);
     maxBackStack = configurationManager.GetValue("PlayerService.MaxBackStack", 2000);
     preBuffered  = new List <TrackContainer>(prebufferSongs.Value);
     backStack    = new List <TrackContainer>(maxBackStack.Value);
     RegisterHotkeys();
 }
예제 #2
0
 /// <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();
 }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PlaylistViewModel" /> class.
        /// </summary>
        /// <param name="publicTransport">The public transport.</param>
        /// <param name="playlistService">The playlist service.</param>
        /// <param name="dispatcher">The dispatcher.</param>
        /// <param name="playerService">The audio player service.</param>
        /// <param name="fileInfoBuilder">The fileInfoBuilder.</param>
        /// <param name="configurationManager">The configuration manager.</param>
        /// <param name="globalHotkeyService">The global hotkey service.</param>
        /// <param name="windowManager">The window manager.</param>
        /// <param name="searchView">The search view.</param>
        public PlaylistViewModel(IPublicTransport publicTransport,
                                 IPlaylistService playlistService,
                                 IDispatcher dispatcher,
                                 IPlayerService playerService,
                                 IInfoBuilder <StorableTaggedFile> fileInfoBuilder,
                                 IConfigurationManager configurationManager,
                                 IGlobalHotkeyService globalHotkeyService,
                                 IWindowManager windowManager,
                                 ISearchView searchView)
        {
            this.publicTransport = Guard.IsNull(() => publicTransport);
            Guard.IsNull(() => configurationManager);
            this.dispatcher          = Guard.IsNull(() => dispatcher);
            this.fileInfoBuilder     = Guard.IsNull(() => fileInfoBuilder);
            this.globalHotkeyService = Guard.IsNull(() => globalHotkeyService);
            this.windowManager       = Guard.IsNull(() => windowManager);
            this.searchView          = Guard.IsNull(() => searchView);
            publicTransport.ApplicationEventBus.Subscribe <PlaylistUpdatedEvent>(OnPlaylistUpdated);
            publicTransport.ApplicationEventBus.Subscribe <TrackChangedEvent>(OnTrackChanged);
            searchHotkey = configurationManager.GetValue("Search", new HotkeyDescriptor(ModifierKeys.Control | ModifierKeys.Alt, Key.J),
                                                         KnownConfigSections.GlobalHotkeys);
            searchHotkey.ValueChanged += SearchHotkeyOnValueChanged;
            globalHotkeyService.RegisterHotkey(searchHotkey.Value, OnSearch);
            searchView.PlayFile += SearchViewOnPlayFile;
            Files = new List <FileItem>(playlistService.Files.Select(x => new FileItem(x)));
            var currenTrack = playerService.CurrentTrackAsReadonly;

            if (null == currenTrack)
            {
                return;
            }
            SetPlayingFile(playlistService.Files.Find(x => x.Filename == currenTrack.Name));
        }
예제 #4
0
 /// <summary>
 /// </summary>
 /// <param name="playlistService">The playlist service.</param>
 /// <param name="player">The player.</param>
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="configurationManager">The configuration manager.</param>
 /// <param name="hotkeyService">The hotkey service.</param>
 public NonManagingPlayerService(IPlaylistService playlistService,
                                 IAudioPlayer player,
                                 IPublicTransport publicTransport,
                                 IConfigurationManager configurationManager,
                                 IGlobalHotkeyService hotkeyService)
 {
     state = PlayingState.Stopped;
     this.playlistService      = Guard.IsNull(() => playlistService);
     this.player               = Guard.IsNull(() => player);
     this.publicTransport      = Guard.IsNull(() => publicTransport);
     this.configurationManager = Guard.IsNull(() => configurationManager);
     this.hotkeyService        = Guard.IsNull(() => hotkeyService);
     Subscribe();
     prebufferSongs                 = configurationManager.GetValue("PrebufferSongs", 2, "PlayerService");
     PlayNextThreshold              = configurationManager.GetValue("PlayNextThreshnoldMs", 500d, "PlayerService");
     TrackInterchangeCrossfadeTime  = configurationManager.GetValue("TrackInterchangeCrossfadeTimeMs", 500d, "PlayerService");
     TrackInterchangeCrossFadeSteps = configurationManager.GetValue("TrackInterchangeCrossfadeSteps", 50, "PlayerService");
     maxBackStack              = configurationManager.GetValue("MaxBackStack", 2000, "PlayerService");
     LastPlayed                = configurationManager.GetValue("PlayerService.LastPlayed", Guid.Empty, KnownConfigSections.Hidden);
     LastPlayedOffset          = configurationManager.GetValue("PlayerService.LastPlayedOffset", 0d, KnownConfigSections.Hidden);
     VolumeValue               = configurationManager.GetValue("PlayerService.Volume", 1f, KnownConfigSections.Hidden);
     preBuffered               = new List <TrackContainer>(prebufferSongs.Value);
     backStack                 = new List <TrackContainer>(maxBackStack.Value);
     VolumeValue.ValueChanged += VolumeValueOnValueChanged;
     RegisterHotkeys();
     LoadLastPlayed();
     UpdateState();
     SendProgress();
 }
예제 #5
0
 public WindowManager(IPublicTransport publicTransport, IWindowFactoryService windowFactory,
                      IDispatcher dispatcher)
 {
     publicTransport.Guard("publicTransport");
     this.windowFactory = windowFactory;
     this.dispatcher    = dispatcher;
     publicTransport.ApplicationEventBus.Subscribe <ShutdownEvent>(OnShutdown);
 }
예제 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VisualizationViewModel" /> class.
 /// </summary>
 /// <param name="visualizationRegistry">The visualization registry.</param>
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="dispatcher">The dispatcher.</param>
 /// <param name="logger">The logger.</param>
 public VisualizationViewModel(IVisualizationRegistry visualizationRegistry, IPublicTransport publicTransport, IDispatcher dispatcher, ILogger logger)
     : base(logger)
 {
     this.visualizationRegistry = visualizationRegistry;
     this.dispatcher            = dispatcher;
     publicTransport.ApplicationEventBus.Subscribe <VisualizationsChangedEvent>(OnVisualizationsChanged);
     ResetAvailable();
 }
예제 #7
0
파일: App.xaml.cs 프로젝트: ilynx/lmaml
        /// <summary>
        /// Runs the debug.
        /// </summary>
        private void RunDebug()
        {
            var bootstrapper = new Bootstrapper();

            bootstrapper.Run();
            publicTransport = bootstrapper.Container.Resolve <IPublicTransport>();
            logger          = bootstrapper.Container.Resolve <ILogger>();
            publicTransport.ApplicationEventBus.Subscribe <ShutdownEvent>(OnShutdown);
        }
예제 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StatusViewModel" /> class.
 /// </summary>
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="dispatcher">The dispatcher.</param>
 public StatusViewModel(IPublicTransport publicTransport, IDispatcher dispatcher)
 {
     publicTransport.Guard("publicTransport");
     dispatcher.Guard("dispatcher");
     this.dispatcher = dispatcher;
     publicTransport.ApplicationEventBus.Subscribe <ProgressEvent>(OnProgress);
     publicTransport.ApplicationEventBus.Subscribe <WorkStartedEvent>(OnWorkStarted);
     publicTransport.ApplicationEventBus.Subscribe <WorkCompletedEvent>(OnWorkCompleted);
 }
예제 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MainMenuViewModel" /> class.
 /// </summary>
 /// <param name="menuService">The menu service.</param>
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="dispatcher">The dispatcher.</param>
 public MainMenuViewModel(IMenuService menuService, IPublicTransport publicTransport, IDispatcher dispatcher)
 {
     menuService.Guard("menuService");
     publicTransport.Guard("publicTransport");
     dispatcher.Guard("dispatcher");
     this.menuService = menuService;
     this.dispatcher  = dispatcher;
     BuildMenu();
     publicTransport.ApplicationEventBus.Subscribe <MainMenuChangedEvent>(OnMainMenuChanged);
 }
예제 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VisualizationViewModel" /> class.
 /// </summary>
 /// <param name="visualizationRegistry">The visualization registry.</param>
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="dispatcher">The dispatcher.</param>
 /// <param name="configurationManager">...</param>
 public VisualizationViewModel(IVisualizationRegistry visualizationRegistry, IPublicTransport publicTransport, IDispatcher dispatcher, IConfigurationManager configurationManager)
 {
     this.visualizationRegistry = visualizationRegistry;
     this.dispatcher            = dispatcher;
     publicTransport.ApplicationEventBus.Subscribe <VisualizationsChangedEvent>(OnVisualizationsChanged);
     lastVisualization = configurationManager.GetValue("Visualizations.LastVisualization", string.Empty,
                                                       KnownConfigSections.Hidden);
     publicTransport.ApplicationEventBus.Subscribe <ShutdownEvent>(OnShutdown);
     ResetAvailable();
 }
예제 #11
0
파일: App.xaml.cs 프로젝트: ilynx/lmaml
        private void RunRelease()
        {
            var bootstrapper = new Bootstrapper();

            try
            {
                bootstrapper.Run();
                publicTransport = bootstrapper.Container.Resolve <IPublicTransport>();
                logger          = bootstrapper.Container.Resolve <ILogger>();
            }
            catch (Exception e) { RuntimeCommon.DefaultLogger.Log(LoggingType.Critical, this, string.Format("APPFAILURE:{0}{1}", Environment.NewLine, e)); }
        }
예제 #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PlayerService" /> class.
 /// </summary>
 /// <param name="playlistService">The playlist service.</param>
 /// <param name="player">The player.</param>
 /// <param name="threadManager">The thread manager service.</param>
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="configurationManager">The configuration manager.</param>
 /// <param name="hotkeyService">The hotkey service.</param>
 public PlayerService(IPlaylistService playlistService,
                      IAudioPlayer player,
                      IThreadManager threadManager,
                      IPublicTransport publicTransport,
                      IConfigurationManager configurationManager,
                      IGlobalHotkeyService hotkeyService)
     : base(playlistService, player, publicTransport, configurationManager, hotkeyService)
 {
     threadManager.Guard("threadManagerService");
     managerThread = threadManager.StartNew(Manage);
     tokenSource   = new CancellationTokenSource();
     token         = tokenSource.Token;
 }
예제 #13
0
 /// <summary>
 /// </summary>
 /// <param name="threadManager">The thread manager.</param>
 /// <param name="playerService">The player service.</param>
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="dispatcher">The dispatcher.</param>
 protected VisualizationViewModelBase(IThreadManager threadManager, IPlayerService playerService, IPublicTransport publicTransport, IDispatcher dispatcher)
 {
     this.threadManager   = threadManager;
     PlayerService        = playerService;
     this.publicTransport = publicTransport;
     this.dispatcher      = dispatcher;
     publicTransport.ApplicationEventBus.Subscribe <PlayingStateChangedEvent>(OnPlayingStateChanged);
     publicTransport.ApplicationEventBus.Subscribe <ShellCollapsedEvent>(OnShellCollapsed);
     publicTransport.ApplicationEventBus.Subscribe <ShellExpandedEvent>(OnShellExpanded);
     publicTransport.ApplicationEventBus.Subscribe <ShellResizeBeginEvent>(OnShellResizeBegin);
     publicTransport.ApplicationEventBus.Subscribe <ShellResizeEndEvent>(OnShellResizeEnd);
     changeTimer = new Timer(SizeChanged);
     isVisible   = true;
 }
예제 #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SearchViewModel" /> class.
 /// </summary>
 /// <param name="playlistService">The playlist service.</param>
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="dispatcher">The dispatcher.</param>
 /// <param name="configurationManager">The configuration manager.</param>
 public SearchViewModel(IPlaylistService playlistService,
                        IPublicTransport publicTransport,
                        IDispatcher dispatcher,
                        IConfigurationManager configurationManager)
 {
     playlistService.Guard("playlistService");
     publicTransport.Guard("publicTransport");
     dispatcher.Guard("dispatcher");
     this.playlistService = playlistService;
     this.dispatcher      = dispatcher;
     publicTransport.ApplicationEventBus.Subscribe <PlaylistUpdatedEvent>(OnPlaylistChanged);
     timer     = new Timer(OnTimerTick);
     staysOpen = configurationManager.GetValue("Stays Open on Double Click", false, "Search Dialog");
     ResetFiles();
 }
 /// <summary>
 /// </summary>
 /// <param name="threadManager">The thread manager.</param>
 /// <param name="playerService">The player service.</param>
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="configurationManager"></param>
 /// <param name="dispatcher">The dispatcher.</param>
 public SpectralFFTVisualizationViewModel(IThreadManager threadManager,
                                          IPlayerService playerService,
                                          IPublicTransport publicTransport,
                                          IConfigurationManager configurationManager,
                                          IDispatcher dispatcher)
     : base(threadManager, playerService, publicTransport, dispatcher,
            configurationManager)
 {
     targetHeight               = configurationManager.GetValue("FFT Count", 512, "Spectral FFT");
     normalizationLevel         = configurationManager.GetValue("Normalization Leve", .75f, "Spectral FFT");
     targetHeight.ValueChanged += TargetHeightOnValueChanged;
     TargetRenderHeight         = targetHeight.Value;
     fftTimer      = new Timer(GetFFT);
     fftBackBuffer = (int *)Marshal.AllocHGlobal((int)TargetRenderHeight * (FFTSize * 4));
 }
예제 #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PlayerControlsViewModel" /> class.
 /// </summary>
 /// <param name="configurationManager"></param>
 /// <param name="playlistService">The playlist service.</param>æ
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="dispatcher">The dispatcher.</param>
 public PlayerControlsViewModel(IConfigurationManager configurationManager, IPlaylistService playlistService, IPublicTransport publicTransport, IDispatcher dispatcher)
 {
     publicTransport.Guard("publicTransport");
     dispatcher.Guard("dispatcher");
     publicTransport.ApplicationEventBus.Subscribe <TrackChangedEvent>(OnTrackChanged);
     publicTransport.ApplicationEventBus.Subscribe <ShuffleChangedEvent>(OnShuffleChanged);
     publicTransport.ApplicationEventBus.Subscribe <PlayingStateChangedEvent>(OnPlayingStateChanged);
     publicTransport.ApplicationEventBus.Subscribe <TrackProgressEvent>(OnTrackProgress);
     volumeValue = configurationManager.GetValue("PlayerService.Volume", 1f, KnownConfigSections.Hidden);
     volumeValue.ValueChanged += VolumeValueOnValueChanged;
     this.playlistService      = playlistService;
     this.publicTransport      = publicTransport;
     this.dispatcher           = dispatcher;
     seekTimer = new Timer(OnSeekTimer);
     Initialize();
 }
예제 #17
0
 /// <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();
 }
예제 #18
0
 /// <summary>
 /// calls <see cref="ThreadedResultWorker{TArgs,TCompletedArgs}" />
 /// </summary>
 /// <param name="infoBuilder">The info builder.</param>
 /// <param name="storageAdapter">The storage adapter.</param>
 /// <param name="logger">The logger.</param>
 /// <param name="configurationManager">The configuration manager.</param>
 /// <param name="threadManager">The thread manager service.</param>
 /// <param name="publicTransport">The public transport.</param>
 public RecursiveAsyncFileScanner(IInfoBuilder <TInfo> infoBuilder,
                                  IDataPersister <TInfo> storageAdapter,
                                  IConfigurationManager configurationManager,
                                  IThreadManager threadManager,
                                  IPublicTransport publicTransport,
                                  ILogger logger)
     : base(logger)
 {
     infoBuilder.Guard("infoBuilder");
     storageAdapter.Guard("storageAdapter");
     configurationManager.Guard("configurationManager");
     threadManager.Guard("threadManagerService");
     publicTransport.Guard("publicTransport");
     this.infoBuilder     = infoBuilder;
     this.storageAdapter  = storageAdapter;
     this.threadManager   = threadManager;
     this.publicTransport = publicTransport;
     pageSize             = configurationManager.GetValue("PageSize", 2000, "File Scanner");
     scanPaged            = configurationManager.GetValue("ScanPaged", true, "File Scanner");
 }
예제 #19
0
 /// <summary>
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="threadManager">The thread manager.</param>
 /// <param name="playerService">The player service.</param>
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="dispatcher">The dispatcher.</param>
 public SpectralFFTVisualizationViewModel(ILogger logger,
                                          IThreadManager threadManager,
                                          IPlayerService playerService,
                                          IPublicTransport publicTransport,
                                          IDispatcher dispatcher)
     : base(logger, threadManager, playerService, publicTransport, dispatcher)
 {
     palette.MapValue(0d, 0, 0, 0, 0);
     palette.MapValue(0.001, 255, 0, 255, 0);
     palette.MapValue(0.0015, 255, 0, 0, 255);
     palette.MapValue(0.02, 255, 255, 0, 0);
     palette.MapValue(0.05, 255, 192, 0, 64);
     palette.MapValue(0.06, 255, 64, 0, 192);
     palette.MapValue(1d, 255, 255, 0, 255);
     TargetRenderHeight = 256;
     TargetRenderWidth  = 1024;
     fftTimer           = new Timer(GetFFT);
     //fftTimer.Change(1, 1);
     fftBackBuffer = (int *)Marshal.AllocHGlobal((int)TargetRenderHeight * (1024 * 4));
 }
예제 #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PlaylistViewModel" /> class.
 /// </summary>
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="playlistService">The playlist service.</param>
 /// <param name="dispatcher">The dispatcher.</param>
 /// <param name="playerService">The audio player service.</param>
 /// <param name="builder">The builder.</param>
 /// <param name="configurationManager">The configuration manager.</param>
 /// <param name="globalHotkeyService">The global hotkey service.</param>
 /// <param name="windowManager">The window manager.</param>
 /// <param name="searchView">The search view.</param>
 /// <param name="serializerService">The serializer service.</param>
 /// <param name="logger">The logger.</param>
 public PlaylistViewModel(IPublicTransport publicTransport,
                          IPlaylistService playlistService,
                          IDispatcher dispatcher,
                          IPlayerService playerService,
                          IInfoBuilder <StorableTaggedFile> builder,
                          IConfigurationManager configurationManager,
                          IGlobalHotkeyService globalHotkeyService,
                          IWindowManager windowManager,
                          ISearchView searchView,
                          ISerializerService serializerService,
                          ILogger logger)
     : base(logger)
 {
     publicTransport.Guard("publicTransport");
     playlistService.Guard("playlistService");
     dispatcher.Guard("dispatcher");
     playerService.Guard("playerService");
     builder.Guard("builder");
     configurationManager.Guard("configurationManager");
     globalHotkeyService.Guard("globalHotkeyService");
     windowManager.Guard("windowManager");
     searchView.Guard("searchView");
     serializerService.Guard("serializerService");
     this.playlistService     = playlistService;
     this.dispatcher          = dispatcher;
     this.playerService       = playerService;
     this.builder             = builder;
     this.globalHotkeyService = globalHotkeyService;
     this.windowManager       = windowManager;
     this.searchView          = searchView;
     publicTransport.ApplicationEventBus.Subscribe <PlaylistUpdatedEvent>(OnPlaylistUpdated);
     publicTransport.ApplicationEventBus.Subscribe <TrackChangedEvent>(OnTrackChanged);
     searchHotkey = configurationManager.GetValue("Search", new HotkeyDescriptor(ModifierKeys.Control | ModifierKeys.Alt, Key.J),
                                                  KnownConfigSections.GlobalHotkeys);
     searchHotkey.ValueChanged += SearchHotkeyOnValueChanged;
     globalHotkeyService.RegisterHotkey(searchHotkey.Value, OnSearch);
     //globalHotkeyService.RegisterHotkey(new HotkeyDescriptor(ModifierKeys.None, Key.A), () => MessageBox.Show("Stuff"));
     searchView.PlayFile += SearchViewOnPlayFile;
     Files = new List <FileItem>(playlistService.Files.Select(x => new FileItem(x)));
 }
예제 #21
0
 /// <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);
 }
예제 #22
0
 /// <summary>
 /// </summary>
 /// <param name="threadManager">The thread manager.</param>
 /// <param name="playerService">The player service.</param>
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="dispatcher">The dispatcher.</param>
 /// <param name="configurationManager"></param>
 protected FFTVisualizationViewModelBase(IThreadManager threadManager, IPlayerService playerService, IPublicTransport publicTransport, IDispatcher dispatcher,
                                         IConfigurationManager configurationManager)
     : base(threadManager, playerService, publicTransport, dispatcher)
 {
     Palette = configurationManager.GetValue("Palette", GetDefaultPalette(), "FFT Visualization").Value;
     fftSize = configurationManager.GetValue("FFT Size", 1024, "FFT Visualization");
     if (!fftSize.Value.IsPowerOfTwo())
     {
         fftSize.Value = 1024;
     }
     if (256 > fftSize.Value)
     {
         fftSize.Value = 256;
     }
     fftSize.ValueChanged += FFTSizeOnValueChanged;
     TargetRenderWidth     = fftSize.Value;
 }
예제 #23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SimpleFFTVisualizationViewModel" /> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="threadManager">The thread manager.</param>
 /// <param name="playerService">The player service.</param>
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="dispatcher">The dispatcher.</param>
 public SimpleFFTVisualizationViewModel(ILogger logger, IThreadManager threadManager, IPlayerService playerService, IPublicTransport publicTransport, IDispatcher dispatcher)
     : base(logger, threadManager, playerService, publicTransport, dispatcher)
 {
 }
예제 #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MenuService" /> class.
 /// </summary>
 /// <param name="publicTransport">The public transport.</param>
 public MenuService(IPublicTransport publicTransport)
 {
     this.publicTransport = publicTransport;
     publicTransport.Guard("publicTransport");
     items = new Dictionary <string, IMenuItem>();
 }
예제 #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VisualizationRegistry" /> class.
 /// </summary>
 /// <param name="publicTransport">The public transport.</param>
 public VisualizationRegistry(IPublicTransport publicTransport)
 {
     publicTransport.Guard("publicTransport");
     eventBus = publicTransport.ApplicationEventBus;
 }
        /// <summary>
        /// </summary>
        /// <param name="threadManager">The thread manager.</param>
        /// <param name="playerService">The player service.</param>
        /// <param name="publicTransport">The public transport.</param>
        /// <param name="dispatcher">The dispatcher.</param>
        /// <param name="configurationManager"></param>
        public SimpleWaveformVisualizationViewModel(IThreadManager threadManager, IPlayerService playerService, IPublicTransport publicTransport, IDispatcher dispatcher,
                                                    IConfigurationManager configurationManager)
            : base(threadManager, playerService, publicTransport, dispatcher)
        {
            publicTransport.ApplicationEventBus.Subscribe <ShutdownEvent>(OnShutdown);
            waveformLength = configurationManager.GetValue("Length", 512, "Waveform");
            color1         = configurationManager.GetValue("Colour 1", Color.FromArgb(255, 192, 0, 0), "Waveform");
            color2         = configurationManager.GetValue("Colour 2", Color.FromArgb(255, 192, 192, 0), "Waveform");
            color3         = configurationManager.GetValue("Colour 3", Color.FromArgb(255, 0, 192, 0), "Waveform");
            palette        = GetDefaultPalette();

            color1.ValueChanged += Color1OnValueChanged;
            color2.ValueChanged += Color2OnValueChanged;
            color3.ValueChanged += Color3OnValueChanged;
            offsetTimer          = new Timer(OnOffset, null, 10, 10);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SimpleFFTVisualizationViewModel" /> class.
 /// </summary>
 /// <param name="threadManager">The thread manager.</param>
 /// <param name="playerService">The player service.</param>
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="dispatcher">The dispatcher.</param>
 /// <param name="configurationManager"></param>
 public SimpleFFTVisualizationViewModel(IThreadManager threadManager, IPlayerService playerService, IPublicTransport publicTransport, IDispatcher dispatcher,
                                        IConfigurationManager configurationManager)
     : base(threadManager, playerService, publicTransport, dispatcher,
            configurationManager)
 {
     normalizeFft       = configurationManager.GetValue("Normalize", true, "FFT Visualization");
     TargetRenderHeight = 512;
 }
예제 #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PlayerControlsViewModel" /> class.
 /// </summary>
 /// <param name="playerService">The player service.</param>
 /// <param name="playlistService">The playlist service.</param>
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="dispatcher">The dispatcher.</param>
 /// <param name="logger">The logger.</param>
 public PlayerControlsViewModel(IPlayerService playerService, IPlaylistService playlistService, IPublicTransport publicTransport, IDispatcher dispatcher, ILogger logger)
     : base(logger)
 {
     playerService.Guard("playerService");
     publicTransport.Guard("publicTransport");
     dispatcher.Guard("dispatcher");
     publicTransport.ApplicationEventBus.Subscribe <TrackChangedEvent>(OnTrackChanged);
     publicTransport.ApplicationEventBus.Subscribe <ShuffleChangedEvent>(OnShuffleChanged);
     publicTransport.ApplicationEventBus.Subscribe <PlayingStateChangedEvent>(OnPlayingStateChanged);
     publicTransport.ApplicationEventBus.Subscribe <TrackProgressEvent>(OnTrackProgress);
     this.playerService   = playerService;
     this.playlistService = playlistService;
     this.dispatcher      = dispatcher;
     state     = playerService.State;
     seekTimer = new Timer(OnSeekTimer);
 }
예제 #29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VisualizationRegistry" /> class.
 /// </summary>
 /// <param name="publicTransport">The public transport.</param>
 public VisualizationRegistry(IPublicTransport publicTransport)
 {
     this.publicTransport = Guard.IsNull(() => publicTransport);
 }
예제 #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SettingsViewModel" /> class.
 /// </summary>
 /// <param name="viewFactory">The view factory.</param>
 /// <param name="configurationManager">The configuration manager.</param>
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="dispatcher">The dispatcher.</param>
 public SettingsViewModel(ISectionViewFactory viewFactory, IConfigurationManager configurationManager, IPublicTransport publicTransport, IDispatcher dispatcher)
 {
     viewFactory.Guard("viewFactory");
     configurationManager.Guard("configurationManager");
     publicTransport.Guard("publicTransport");
     dispatcher.Guard("dispatcher");
     this.viewFactory          = viewFactory;
     this.configurationManager = configurationManager;
     this.dispatcher           = dispatcher;
     publicTransport.ApplicationEventBus.Subscribe <ConfigSectionsChangedEvent>(OnConfigSectionsChanged);
 }