protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); MainWindow = new MainWindow(userSystemEventRepository, userWindowEventRepository, windowsAppRepository); MainWindow.Closing += MainWindow_Closing; _notifyIcon = new SWF.NotifyIcon(); _notifyIcon.DoubleClick += (s, args) => ShowMainWindow(); _notifyIcon.Icon = BackgroundApp.Properties.Resources.time; _notifyIcon.Visible = true; systemActivityService = new SystemActivityService(); windowActivityService = new WindowActivityService(); dbContext = new TimeTrackerDbContext(); dbContext.Database.EnsureCreated(); userSystemEventRepository = new UserSystemEventRepository(dbContext); userWindowEventRepository = new UserWindowEventRepository(dbContext); windowsAppRepository = new WindowsAppRepository(dbContext); systemActivityService.SystemActivitySnapshot += SystemActivityService_SystemActivitySnapshot; windowActivityService.WindowActivitySnapshot += WindowActivityService_WindowActivitySnapshot; systemActivityService.Start(); windowActivityService.Start(); CreateContextMenu(); }
protected override void OnStart(string[] args) { systemActivityService.SystemActivitySnapshot += SystemActivityService_SystemActivitySnapshot; windowActivityService.WindowActivitySnapshot += WindowActivityService_WindowActivitySnapshot; systemActivityService.Start(); windowActivityService.Start(); }
static void Main(string[] args) { SystemActivityService systemActivityService = new SystemActivityService(); WindowActivityService windowActivityService = new WindowActivityService(); dbContext = new TimeTrackerDbContext(); dbContext.Database.EnsureCreated(); userSystemEventRepository = new UserSystemEventRepository(dbContext); userWindowEventRepository = new UserWindowEventRepository(dbContext); windowsAppRepository = new WindowsAppRepository(dbContext); systemActivityService.SystemActivitySnapshot += SystemActivityService_SystemActivitySnapshot; windowActivityService.WindowActivitySnapshot += WindowActivityService_WindowActivitySnapshot; systemActivityService.Start(); windowActivityService.Start(); while (true) { Thread.Sleep(10); } }