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()); var deviceManager = DataModelFactory.CreateAudioDeviceManager(); DiagnosticsService.Advise(deviceManager); _viewModel = new MainViewModel(deviceManager); _viewModel.Ready += MainViewModel_Ready; _flyoutWindow = new FlyoutWindow(_viewModel, new FlyoutViewModel(_viewModel)); _trayIcon = new TrayIcon(new TrayViewModel(_viewModel)); HotkeyService.Register(SettingsService.Hotkey); HotkeyService.KeyPressed += (_, __) => _viewModel.OpenFlyout(); StartupUWPDialogDisplayService.ShowIfAppropriate(); Trace.WriteLine($"App Application_Startup Exit"); }
private void OnAppStartup(object sender, StartupEventArgs e) { Exit += (_, __) => IsShuttingDown = true; HasIdentity = PackageHelper.CheckHasIdentity(); PackageVersion = PackageHelper.GetVersion(HasIdentity); _settings = new AppSettings(); _errorReporter = new ErrorReporter(); if (SingleInstanceAppMutex.TakeExclusivity()) { Exit += (_, __) => SingleInstanceAppMutex.ReleaseExclusivity(); try { ContinueStartup(); } catch (Exception ex) when(IsCriticalFontLoadFailure(ex)) { ErrorReporter.LogWarning(ex); OnCriticalFontLoadFailure(); } } else { Shutdown(); } }
private void OnAppStartup(object sender, StartupEventArgs e) { Exit += (_, __) => IsShuttingDown = true; _errorReporter = new ErrorReporter(); if (SingleInstanceAppMutex.TakeExclusivity()) { Exit += (_, __) => SingleInstanceAppMutex.ReleaseExclusivity(); try { ContinueStartup(); } catch (Exception ex) when(ex.StackTrace.Contains( "MS.Internal.Text.TextInterface.FontFamily.GetFirstMatchingFont")) { ErrorReporter.LogWarning(ex); OnCriticalFontLoadFailure(); } } else { Shutdown(); } }
private void OnAppStartup(object sender, StartupEventArgs e) { Exit += (_, __) => IsShuttingDown = true; _errorReporter = new ErrorReporter(); if (SingleInstanceAppMutex.TakeExclusivity()) { Exit += (_, __) => SingleInstanceAppMutex.ReleaseExclusivity(); ContinueStartup(); } else { Shutdown(); } }
private void Application_Startup(object sender, StartupEventArgs e) { // Initialize must register its App.Current.Exit // handler early to properly report app state ErrorReportingService.Initialize(); Trace.WriteLine("App Application_Startup"); if (!SingleInstanceAppMutex.TakeExclusivity()) { Trace.WriteLine("App Application_Startup TakeExclusivity failed"); Current.Shutdown(); return; } DoAppStartup(); Trace.WriteLine($"App Application_Startup Exit"); }
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"); }
private void OnStartup(object sender, StartupEventArgs e) { if (SingleInstanceAppMutex.TakeExclusivity()) { Exit += (_, __) => SingleInstanceAppMutex.ReleaseExclusivity(); try { ContinueStartup(); } catch (Exception ex) when(IsCriticalFontLoadFailure(ex)) { Trace.WriteLine($"## Warning Notify ##: {ex}"); OnCriticalFontLoadFailure(); } } else { Shutdown(); } }
private void OnStartup(object sender, StartupEventArgs e) { if (SingleInstanceAppMutex.TakeExclusivity()) { Exit += (_, __) => SingleInstanceAppMutex.ReleaseExclusivity(); try { ContinueStartup(); } catch (Exception ex) when(IsCriticalFontLoadFailure(ex)) { Trace.WriteLine($"## Warning Notify ##: {ex}"); Log.Error(ex, "Stopped program because of exception"); } } else { Log.CloseAndFlush(); Shutdown(); } }