protected override void OnStartup(StartupEventArgs e) { ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12; // Check if there was instance before this. If there was-close the current one. if (ProcessUtilities.ThisProcessIsAlreadyRunning()) { ProcessUtilities.SetFocusToPreviousInstance("Carnac"); Shutdown(); return; } trayIcon = new CarnacTrayIcon(); trayIcon.OpenPreferences += TrayIconOnOpenPreferences; var keyShowViewModel = new KeyShowViewModel(settings); keyShowView = new KeyShowView(keyShowViewModel); keyShowView.Show(); carnac = new KeysController(keyShowViewModel.Messages, messageProvider, new ConcurrencyService(), settingsProvider); carnac.Start(); #if !DEBUG if (settings.AutoUpdate) { Observable .Timer(TimeSpan.FromMinutes(5)) .Subscribe(async x => { try { using (var mgr = UpdateManager.GitHubUpdateManager(carnacUpdateUrl)) { await mgr.Result.UpdateApp(); } } catch { // Do something useful with the exception } }); } #endif base.OnStartup(e); }
protected override void OnStartup(StartupEventArgs e) { // Check if there was instance before this. If there was-close the current one. if (ProcessUtilities.ThisProcessIsAlreadyRunning()) { ProcessUtilities.SetFocusToPreviousInstance("Carnac"); Shutdown(); return; } trayIcon = new CarnacTrayIcon(); trayIcon.OpenPreferences += TrayIconOnOpenPreferences; keyCollection = new ObservableCollection <Message>(); keyShowView = new KeyShowView(new KeyShowViewModel(keyCollection, settings)); keyShowView.Show(); carnac = new KeysController(keyCollection, messageProvider, keyProvider, new ConcurrencyService()); carnac.Start(); base.OnStartup(e); }
protected override void OnStartup(StartupEventArgs e) { // Check if there was instance before this. If there was-close the current one. if (ProcessUtilities.ThisProcessIsAlreadyRunning()) { ProcessUtilities.SetFocusToPreviousInstance("Carnac"); Shutdown(); return; } trayIcon = new CarnacTrayIcon(); trayIcon.OpenPreferences += TrayIconOnOpenPreferences; var keyShowViewModel = new KeyShowViewModel(settings); keyShowView = new KeyShowView(keyShowViewModel); keyShowView.Show(); carnac = new KeysController(keyShowViewModel.Messages, messageProvider, new ConcurrencyService(), settingsProvider); carnac.Start(); MouseWatcher.OnMouseInput += (s, me) => { if (!keyShowView.IsVisible) { return; } var msg = me.Message; var needAct = msg == MouseMessages.WM_LBUTTONUP || msg == MouseMessages.WM_RBUTTONUP; if (!needAct) { return; } Dispatcher.Invoke(() => { keyShowViewModel.CursorPosition = keyShowView.PointFromScreen(new System.Windows.Point(me.Point.x, me.Point.y)); if (msg == MouseMessages.WM_LBUTTONUP) { keyShowView.LeftClick(); } if (msg == MouseMessages.WM_RBUTTONUP) { keyShowView.RightClick(); } }); }; if (settings.ShowMouseClicks) { MouseWatcher.Start(); } settings.PropertyChanged += (s, se) => { switch (se.PropertyName) { case "ShowMouseClicks": if (this.settings.ShowMouseClicks) { MouseWatcher.Start(); } else { MouseWatcher.Stop(); } break; } }; #if !DEBUG if (settings.AutoUpdate) { Observable .Timer(TimeSpan.FromMinutes(5)) .Subscribe(async x => { try { using (var mgr = UpdateManager.GitHubUpdateManager(carnacUpdateUrl)) { await mgr.Result.UpdateApp(); } } catch { // Do something useful with the exception } }); } #endif base.OnStartup(e); }