public void OnEvent(AddonEventKind evt) { foreach (var trigger in _eventTriggers) { if ((trigger.Option == EarTrumpetEventKind.Startup && evt == AddonEventKind.InitializeAddon) || (trigger.Option == EarTrumpetEventKind.Shutdown && evt == AddonEventKind.AppShuttingDown)) { Triggered?.Invoke(trigger); } } }
public void OnAddonEvent(AddonEventKind evt) { if (evt == AddonEventKind.InitializeAddon) { Current = this; DeviceCollection = ((App)App.Current).CollectionViewModel; m_hardwareManager = new HardwareManager(DeviceCollection, WindowsAudioFactory.Create(AudioDeviceKind.Playback)); // Monitor the EarTrumpet flyout so we don't show when the flyout is showing. _flyoutViewModel = (FlyoutViewModel)((App)Application.Current).FlyoutWindow.DataContext; _flyoutViewModel.StateChanged += OnFlyoutViewModelStateChanged; // Create a window to use as OSD. _osdWindowViewModel = new OSDWindowViewModel(); _osdWindow = new OSDWindow(_osdWindowViewModel); _osdWindow.Initialize(); // Listen to events and then present the active ViewModel to the OSD window. PlaybackDataModelHost.Current.AppPropertyChanged += OnAppPropertyChanged; PlaybackDataModelHost.Current.DevicePropertyChanged += OnDevicePropertyChanged; } }