private void Application_Startup(object sender, StartupEventArgs e) { //Only if user has chosen to generate log var debugMode = Environment.GetEnvironmentVariable("XDM_DEBUG_MODE"); if (!string.IsNullOrEmpty(debugMode) && debugMode == "1") { var logFile = Path.Combine(Config.DataDir, "log.txt"); Log.InitFileBasedTrace(Path.Combine(Config.DataDir, "log.txt")); } Log.Debug($"Application_Startup::args->: {string.Join(" ", Environment.GetCommandLineArgs())}"); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; core = new ApplicationCore(); win = new MainWindow(); app = new XDMApp(); ApplicationContext.Configurer() .RegisterApplicationWindow(win) .RegisterApplication(app) .RegisterApplicationCore(core) .RegisterCapturedVideoTracker(new VideoTracker()) .RegisterClipboardMonitor(new ClipboardMonitor()) .RegisterLinkRefresher(new LinkRefresher()) .RegisterPlatformUIService(new WpfPlatformUIService()) .Configure(); var args = Environment.GetCommandLineArgs(); var commandOptions = ArgsProcessor.ParseArgs(args, 1); AppTrayIcon.AttachToSystemTray(); AppTrayIcon.TrayClick += (_, _) => { win.Show(); if (win.WindowState == WindowState.Minimized) { win.WindowState = WindowState.Normal; } win.Activate(); }; if (!commandOptions.ContainsKey("-m")) { win.Show(); if (commandOptions.ContainsKey("-i")) { Config.Instance.RunOnLogon = true; Config.SaveConfig(); ApplicationContext.PlatformUIService.ShowBrowserMonitoringDialog(); } } }
private void Application_Exit(object sender, ExitEventArgs e) { AppTrayIcon.DetachFromSystemTray(); }