コード例 #1
0
ファイル: App.xaml.cs プロジェクト: walkingthicc/EarTrumpet
        private void CompleteStartup()
        {
            AddonManager.Load();
            Exit += (_, __) => AddonManager.Shutdown();

#if DEBUG
            DebugHelpers.Add();
#endif
            _mixerWindow    = new WindowHolder(CreateMixerExperience);
            _settingsWindow = new WindowHolder(CreateSettingsExperience);

            _settings.FlyoutHotkeyTyped   += () => _flyoutViewModel.OpenFlyout(InputType.Keyboard);
            _settings.MixerHotkeyTyped    += () => _mixerWindow.OpenOrClose();
            _settings.SettingsHotkeyTyped += () => _settingsWindow.OpenOrBringToFront();
            _settings.RegisterHotkeys();

            _trayIcon.PrimaryInvoke   += (_, type) => _flyoutViewModel.OpenFlyout(type);
            _trayIcon.SecondaryInvoke += (_, __) => _trayIcon.ShowContextMenu(GetTrayContextMenuItems());
            _trayIcon.TertiaryInvoke  += (_, __) => _collectionViewModel.Default?.ToggleMute.Execute(null);
            _trayIcon.Scrolled        += (_, wheelDelta) => _collectionViewModel.Default?.IncrementVolume(Math.Sign(wheelDelta) * 2);
            _trayIcon.SetTooltip(_collectionViewModel.GetTrayToolTip());
            _trayIcon.IsVisible = true;

            DisplayFirstRunExperience();
        }
コード例 #2
0
ファイル: App.xaml.cs プロジェクト: hamerstandr/EarTrumpet
        private void DoAppStartup()
        {
            ((Manager)Resources["ThemeManager"]).Load();

            _mixerWindow    = new WindowHolder(CreateMixerExperience);
            _settingsWindow = new WindowHolder(CreateSettingsExperience);

            PlaybackDevicesViewModel        = new DeviceCollectionViewModel(WindowsAudioFactory.Create(AudioDeviceKind.Playback));
            PlaybackDevicesViewModel.Ready += OnMainViewModelReady;

            FlyoutViewModel = new FlyoutViewModel(PlaybackDevicesViewModel);
            FlyoutWindow    = new FlyoutWindow(FlyoutViewModel);

            TrayViewModel              = new TrayViewModel(PlaybackDevicesViewModel);
            TrayViewModel.LeftClick    = new RelayCommand(() => FlyoutViewModel.OpenFlyout(FlyoutShowOptions.Pointer));
            TrayViewModel.OpenMixer    = new RelayCommand(_mixerWindow.OpenOrBringToFront);
            TrayViewModel.OpenSettings = new RelayCommand(_settingsWindow.OpenOrBringToFront);
            FlyoutWindow.DpiChanged   += (_, __) => TrayViewModel.Refresh();

            _trayIcon = new TrayIcon(TrayViewModel);

            SettingsService.RegisterHotkeys();
            HotkeyManager.Current.KeyPressed += OnHotKeyPressed;

            MaybeShowFirstRunExperience();
        }
コード例 #3
0
ファイル: App.xaml.cs プロジェクト: yonatan-mitmit/EarTrumpet
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            ErrorReportingService.Initialize();

            Trace.WriteLine("App Application_Startup");

            if (!SingleInstanceAppMutex.TakeExclusivity())
            {
                Trace.WriteLine("App Application_Startup TakeExclusivity failed");
                Current.Shutdown();
                return;
            }

            ((ThemeManager)Resources["ThemeManager"]).SetTheme(ThemeData.GetBrushData());

            PlaybackDevicesViewModel        = new DeviceCollectionViewModel(DataModelFactory.CreateAudioDeviceManager(AudioDeviceKind.Playback));
            PlaybackDevicesViewModel.Ready += MainViewModel_Ready;

            FlyoutViewModel = new FlyoutViewModel(PlaybackDevicesViewModel);
            FlyoutWindow    = new FlyoutWindow(FlyoutViewModel);

            TrayViewModel              = new TrayViewModel(PlaybackDevicesViewModel);
            TrayViewModel.LeftClick    = new RelayCommand(() => FlyoutViewModel.OpenFlyout(FlyoutShowOptions.Pointer));
            TrayViewModel.OpenMixer    = new RelayCommand(OpenMixer);
            TrayViewModel.OpenSettings = new RelayCommand(OpenSettings);

            _trayIcon = new TrayIcon(TrayViewModel);
            FlyoutWindow.DpiChanged += (_, __) => TrayViewModel.DpiChanged();

            HotkeyManager.Current.Register(SettingsService.Hotkey);
            HotkeyManager.Current.KeyPressed += (hotkey) =>
            {
                if (hotkey.Equals(SettingsService.Hotkey))
                {
                    FlyoutViewModel.OpenFlyout(FlyoutShowOptions.Keyboard);
                }
            };

            StartupUWPDialogDisplayService.ShowIfAppropriate();

            Trace.WriteLine($"App Application_Startup Exit");
        }
コード例 #4
0
ファイル: App.xaml.cs プロジェクト: hamerstandr/EarTrumpet
 private void OnHotKeyPressed(HotkeyData hotkey)
 {
     if (hotkey.Equals(SettingsService.FlyoutHotkey))
     {
         FlyoutViewModel.OpenFlyout(FlyoutShowOptions.Keyboard);
     }
     else if (hotkey.Equals(SettingsService.SettingsHotkey))
     {
         _settingsWindow.OpenOrBringToFront();
     }
     else if (hotkey.Equals(SettingsService.MixerHotkey))
     {
         _mixerWindow.OpenOrClose();
     }
 }
コード例 #5
0
ファイル: App.xaml.cs プロジェクト: privatuser/EarTrumpet
        private void ContinueStartup()
        {
            ((UI.Themes.Manager)Resources["ThemeManager"]).Load();

            _settings = new AppSettings();
            _settings.FlyoutHotkeyTyped   += () => FlyoutViewModel.OpenFlyout(InputType.Keyboard);
            _settings.MixerHotkeyTyped    += () => _mixerWindow.OpenOrClose();
            _settings.SettingsHotkeyTyped += () => _settingsWindow.OpenOrBringToFront();
            _mixerWindow                    = new WindowHolder(CreateMixerExperience);
            _settingsWindow                 = new WindowHolder(CreateSettingsExperience);
            PlaybackDevicesViewModel        = new DeviceCollectionViewModel(DataModel.WindowsAudio.WindowsAudioFactory.Create(DataModel.WindowsAudio.AudioDeviceKind.Playback), _settings);
            PlaybackDevicesViewModel.Ready += (_, __) => CompleteStartup();
            PlaybackDevicesViewModel.TrayPropertyChanged += () => UpdateTrayTooltipAndIcon();
            FlyoutViewModel = new FlyoutViewModel(PlaybackDevicesViewModel, () => _trayIcon.SetFocus());
            FlyoutWindow    = new FlyoutWindow(FlyoutViewModel);

            CreateTrayExperience();
        }
コード例 #6
0
ファイル: App.xaml.cs プロジェクト: privatuser/EarTrumpet
        private void CreateTrayExperience()
        {
            if (!SndVolSSO.SystemIconsAreAvailable())
            {
                _settings.UseLegacyIcon = true;
            }

            TaskbarIconSource iconSource = null;

            iconSource = new TaskbarIconSource(icon =>
            {
                if (_settings.UseLegacyIcon)
                {
                    icon?.Dispose();
                    icon = IconHelper.LoadIconForTaskbar(SystemSettings.IsSystemLightTheme ? $"{AssetBaseUri}Application.ico" : $"{AssetBaseUri}Tray.ico");
                }

                double iconFillPercent = ((SndVolSSO.IconId)iconSource.Tag) == SndVolSSO.IconId.NoDevice && !_settings.UseLegacyIcon ? 0.4 : 1;
                if (SystemParameters.HighContrast)
                {
                    icon = IconHelper.ColorIcon(icon, iconFillPercent, _trayIcon.IsMouseOver ? SystemColors.HighlightTextColor : SystemColors.WindowTextColor);
                }
                else if (SystemSettings.IsSystemLightTheme && !_settings.UseLegacyIcon)
                {
                    icon = IconHelper.ColorIcon(icon, iconFillPercent, System.Windows.Media.Colors.Black);
                }
                return(icon);
            },
                                               () => $"hc={SystemParameters.HighContrast} {(SystemParameters.HighContrast ? $"mouse={_trayIcon.IsMouseOver}" : "")} dpi={WindowsTaskbar.Dpi} theme={SystemSettings.IsSystemLightTheme} legacy={_settings.UseLegacyIcon}");
            _settings.UseLegacyIconChanged += (_, __) => iconSource.CheckForUpdate();

            _trayIcon = new ShellNotifyIcon(iconSource, () => _settings.TrayIconIdentity, _settings.ResetTrayIconIdentity);
            _trayIcon.PrimaryInvoke   += (_, type) => FlyoutViewModel.OpenFlyout(type);
            _trayIcon.SecondaryInvoke += (_, __) => _trayIcon.ShowContextMenu(GetTrayContextMenuItems());
            _trayIcon.TertiaryInvoke  += (_, __) => PlaybackDevicesViewModel.Default?.ToggleMute.Execute(null);
            _trayIcon.Scrolled        += (_, wheelDelta) => PlaybackDevicesViewModel.Default?.IncrementVolume(Math.Sign(wheelDelta) * 2);
            Exit += (_, __) => _trayIcon.IsVisible = false;

            UpdateTrayTooltipAndIcon();
        }