Пример #1
0
        private async Task InitializeAsync()
        {
            try
            {
                Logger.Debug("Initialization started");

                await Task.Run(() =>
                {
                    _audioSourceContextMenuItems = new List <DeskBandMenuAction>();
                    _settingsMenuItem            = new DeskBandMenuAction("Audio Band Settings");
                    _settingsMenuItem.Clicked   += SettingsMenuItemOnClicked;
                    RefreshContextMenu();

                    InitializeModels();
                }).ConfigureAwait(false);

                _settingsWindowVm = await SetupViewModels().ConfigureAwait(false);

                await _uiDispatcher.InvokeAsync(() =>
                {
                    _settingsWindow           = new SettingsWindow(_settingsWindowVm);
                    _settingsWindow.Saved    += SettingsWindowOnSaved;
                    _settingsWindow.Canceled += SettingsWindowOnCanceled;
                    ElementHost.EnableModelessKeyboardInterop(_settingsWindow);
                });

                _audioSourceManager = new AudioSourceManager();
                _audioSourceManager.AudioSources.CollectionChanged += AudioSourcesOnCollectionChanged;
                _audioSourceManager.LoadAudioSources();

                Logger.Debug("Initialization complete");
            }
            catch (Exception e)
            {
                Logger.Error(e, "Error during initialization");
            }
        }