示例#1
0
        /// <summary>
        /// Initializes the wrapper.
        /// </summary>
        /// <param name="audioSourceDirectory">The directory of the audio source.</param>
        /// <returns>True if successful.</returns>
        public bool Initialize(string audioSourceDirectory)
        {
            try
            {
                _logger = AudioBandLogManager.GetLogger($"AudioSourceWrapper({new DirectoryInfo(audioSourceDirectory).Name})");
                _logger.Debug("Initializing wrapper");

                AppDomain.CurrentDomain.UnhandledException += (o, e) => _logger.Error(e.ExceptionObject as Exception, "Unhandled exception in wrapper");

                _audioSource        = AudioSourceLoader.LoadFromDirectory(audioSourceDirectory);
                _audioSource.Logger = new AudioSourceLogger(_audioSource.Name);

                _audioSource.SettingChanged       += (o, e) => SettingChanged?.Invoke(this, e);
                _audioSource.TrackInfoChanged     += (o, e) => TrackInfoChanged?.Invoke(this, e);
                _audioSource.IsPlayingChanged     += (o, e) => IsPlayingChanged?.Invoke(this, e);
                _audioSource.TrackProgressChanged += (o, e) => TrackProgressChanged?.Invoke(this, e);
                _audioSource.VolumeChanged        += (o, e) => VolumeChanged?.Invoke(this, e);
                _audioSource.ShuffleChanged       += (o, e) => ShuffleChanged?.Invoke(this, e);
                _audioSource.RepeatModeChanged    += (o, e) => RepeatModeChanged?.Invoke(this, e);

                _audioSourceSettingsList = _audioSource.GetSettings();
                foreach (AudioSourceSetting setting in _audioSourceSettingsList)
                {
                    _audioSourceSettings.Add(setting.Attribute.Name, setting);
                }

                _logger.Debug("Wrapper initialization complete");
                return(true);
            }
            catch (Exception e)
            {
                _logger.Error(e);
                return(false);
            }
        }
示例#2
0
        private static void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs args)
        {
            GlobalSettings.Default.UnhandledException = true;
            GlobalSettings.Default.Save();

            AudioBandLogManager.GetLogger("AudioBand").Error((Exception)args.ExceptionObject, "Unhandled Exception");
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Deskband"/> class.
        /// </summary>
        public Deskband()
        {
            // Fluentwpf requires an application window
            if (System.Windows.Application.Current == null)
            {
                new System.Windows.Application().MainWindow = new Window();
            }

            var initialSize = new DeskBandSize(50, 30);

            Options.HorizontalSize    = initialSize;
            Options.MinHorizontalSize = initialSize;
            AudioBandLogManager.Initialize();
            _logger = AudioBandLogManager.GetLogger("AudioBand");
            _logger.Info("Starting AudioBand. Version: {version}, OS: {os}", GetType().Assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>().InformationalVersion, Environment.OSVersion);

            StartupCheck();

            AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
            AppDomain.CurrentDomain.AssemblyResolve    += CurrentDomainOnAssemblyResolve;

            ConfigureDependencies();

            _settingsWindow   = _container.GetInstance <SettingsWindow>();
            _audioBandToolbar = _container.GetInstance <AudioBandToolbar>();

            _container.GetInstance <IMessageBus>().Subscribe <FocusChangedMessage>(FocusCaptured);
        }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ViewModelBase"/> class.
        /// </summary>
        protected ViewModelBase()
        {
            Logger = AudioBandLogManager.GetLogger(GetType().FullName);

            BeginEditCommand  = new RelayCommand(BeginEdit);
            EndEditCommand    = new RelayCommand(EndEdit);
            CancelEditCommand = new RelayCommand(CancelEdit);
            ResetCommand      = new RelayCommand(Reset);

            GetTrackingProperties();
        }
示例#5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ViewModelBase"/> class.
        /// </summary>
        protected ViewModelBase()
        {
            Logger   = AudioBandLogManager.GetLogger(GetType().FullName);
            Accessor = TypeAccessor.Create(GetType());

            BeginEditCommand  = new RelayCommand(o => BeginEdit());
            EndEditCommand    = new RelayCommand(o => EndEdit());
            CancelEditCommand = new RelayCommand(o => CancelEdit());
            ResetCommand      = new RelayCommand(o => Reset());

            SetupAlsoNotify();
        }
示例#6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Deskband"/> class.
        /// </summary>
        public Deskband()
        {
            // Assign a fake main window since some libraries require one
            if (System.Windows.Application.Current?.MainWindow == null)
            {
                new System.Windows.Application().MainWindow = new Window();
            }

            AudioBandLogManager.Initialize();
            AppDomain.CurrentDomain.UnhandledException += (sender, args) => AudioBandLogManager.GetLogger("AudioBand").Error((Exception)args.ExceptionObject, "Unhandled Exception");
            ConfigureDependencies();
            _mainControl = _container.GetInstance <MainControl>();
            this.Subscribe <FocusChangedMessage>(FocusCaptured);
        }
示例#7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AudioSourceProxy"/> class
        /// with the directory and the host service.
        /// </summary>
        /// <param name="directory">The audio source directory.</param>
        public AudioSourceProxy(string directory)
        {
            _directory = directory;
            var directoryName = new DirectoryInfo(directory).Name;

            _logger = AudioBandLogManager.GetLogger($"AudioSourceProxy({directoryName})");

            AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolve;

            var domainSetupInfo = new AppDomainSetup
            {
                ApplicationName = $"AudioSourceHost({directoryName})",
                ApplicationBase = DirectoryHelper.BaseDirectory,
            };

            _appDomain = AppDomain.CreateDomain(directoryName, null, domainSetupInfo);
            CreateWrapper();
        }
示例#8
0
        private void ConfigureDependencies()
        {
            try
            {
                _container = new Container();
                _container.RegisterInstance(Options);
                _container.RegisterInstance(TaskbarInfo);
                _container.Register <IMessageBus, MessageBus>(Lifestyle.Singleton);
                _container.Register <IAudioSourceManager, AudioSourceManager>(Lifestyle.Singleton);
                _container.Register <IAppSettings, AppSettings>(Lifestyle.Singleton);
                _container.Register <IDialogService, DialogService>(Lifestyle.Singleton);
                _container.Register <IViewModelContainer, ViewModelContainer>(Lifestyle.Singleton);
                _container.Register <IAudioSession, AudioSession>(Lifestyle.Singleton);
                _container.Register <IPersistSettings, PersistSettings>(Lifestyle.Singleton);

                _container.Register <AboutDialogViewModel>(Lifestyle.Singleton);
                _container.Register <AlbumArtViewModel>(Lifestyle.Singleton);
                _container.Register <AlbumArtPopupViewModel>(Lifestyle.Singleton);
                _container.Register <GeneralSettingsViewModel>(Lifestyle.Singleton);
                _container.Register <CustomLabelsViewModel>(Lifestyle.Singleton);
                _container.Register <NextButtonViewModel>(Lifestyle.Singleton);
                _container.Register <PlayPauseButtonViewModel>(Lifestyle.Singleton);
                _container.Register <PreviousButtonViewModel>(Lifestyle.Singleton);
                _container.Register <ProgressBarViewModel>(Lifestyle.Singleton);
                _container.Register <SettingsWindowViewModel>(Lifestyle.Singleton);
                _container.Register <AudioSourceSettingsViewModel>(Lifestyle.Singleton);
                _container.Register <RepeatModeButtonViewModel>(Lifestyle.Singleton);
                _container.Register <ShuffleModeButtonViewModel>(Lifestyle.Singleton);

                _container.Verify();
            }
            catch (Exception e)
            {
                AudioBandLogManager.GetLogger("AudioBand").Error(e);
                throw;
            }
        }
示例#9
0
        private void ConfigureDependencies()
        {
            try
            {
                _container = new Container();
                _container.RegisterInstance(Options);
                _container.RegisterInstance(TaskbarInfo);
                _container.Register <Track>(Lifestyle.Singleton);
                _container.Register <IAudioSourceManager, AudioSourceManager>(Lifestyle.Singleton);
                _container.Register <IAppSettings, AppSettings>(Lifestyle.Singleton);
                _container.Register <IResourceLoader, ResourceLoader>(Lifestyle.Singleton);
                _container.Register <ICustomLabelService, CustomLabelService>(Lifestyle.Singleton);
                _container.Register <IDialogService, DialogService>(Lifestyle.Singleton);
                _container.Register <ISettingsWindow, SettingsWindow>(Lifestyle.Transient);

                var viewmodelExclude = new Type[] { typeof(AudioSourceSettingVM), typeof(AudioSourceSettingsVM) };
                var viewmodels       = typeof(ViewModelBase)
                                       .Assembly
                                       .GetTypes()
                                       .Where(type => type.Namespace == "AudioBand.ViewModels" &&
                                              type.IsClass &&
                                              !type.IsAbstract &&
                                              typeof(ViewModelBase).IsAssignableFrom(type) &&
                                              !viewmodelExclude.Contains(type));
                foreach (var viewmodel in viewmodels)
                {
                    _container.Register(viewmodel);
                }

                _container.Verify();
            }
            catch (Exception e)
            {
                AudioBandLogManager.GetLogger("AudioBand").Error(e);
                throw;
            }
        }
示例#10
0
        private List <AudioSourceSetting> _audioSourceSettingsList; // so we can keep the order of the settings.

        /// <summary>
        /// Initializes a new instance of the <see cref="AudioSourceWrapper"/> class.
        /// </summary>
        public AudioSourceWrapper()
        {
            AudioBandLogManager.Initialize();
        }
示例#11
0
 public AudioSourceLogger(string audiosourceName)
 {
     _logger = AudioBandLogManager.GetLogger($"AudioSource({audiosourceName})");
 }
示例#12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Deskband"/> class.
 /// </summary>
 public Deskband()
 {
     AudioBandLogManager.Initialize();
     AppDomain.CurrentDomain.UnhandledException += (sender, args) => AudioBandLogManager.GetLogger("AudioBand").Error((Exception)args.ExceptionObject, "Unhandled Exception");
     _mainControl = new MainControl(Options, TaskbarInfo);
 }
示例#13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ModelBase"/> class.
 /// </summary>
 public ModelBase()
 {
     Logger = AudioBandLogManager.GetLogger(GetType().FullName);
 }