private IntPtr CallBackMethod(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { // Listening OS message to test whether it is a user activity if ((msg >= 0x0200 && msg <= 0x020A) || (msg <= 0x0106 && msg >= 0x00A0) || msg == 0x0021) { AutoLogOffHelper.ResetLogoffTimer(); } return(IntPtr.Zero); }
private void Container_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { if ((bool)e.NewValue) { AutoLogOffHelper.EnableLogoffTimer(); //MenuItem _startPage = new MenuItem(); //_startPage.Name = "OverView"; //AddWindow_Click(_startPage, null); } else { AutoLogOffHelper.DisableLogoffTimer(); } }
void viewModel_Authenticated(object sender, System.ComponentModel.HandledEventArgs e) { if ((bool)sender) { mainlogin.Hide(); AutoLogOffHelper.ResetLogoffTimer(); if (mainWindow == null) { mainWindow = new MainWindow(); mainWindow.ShowDialog(); } else { mainWindow.ShowDialog(); } } }
private void Window_Loaded(object sender, RoutedEventArgs e) { HwndSource windowSpecificOSMessageListener = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle); windowSpecificOSMessageListener.AddHook(new HwndSourceHook(CallBackMethod)); AutoLogOffHelper.LogOffTime = logOffTime; AutoLogOffHelper.MakeAutoLogOffEvent -= new AutoLogOffHelper.MakeAutoLogOff(LogOffEvent); AutoLogOffHelper.MakeAutoLogOffEvent += new AutoLogOffHelper.MakeAutoLogOff(LogOffEvent); AutoLogOffHelper.StartAutoLogoffOption(); UserName.Header = _main.mainCustomPrincipal.Identity.Name; aTimer = new Timer(800); aTimer.Elapsed -= new ElapsedEventHandler(OnTimedEvent); aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent); aTimer.Enabled = true; // Add hook communication with Real Time Control HwndSource hWndSource; WindowInteropHelper wih = new WindowInteropHelper(this); hWndSource = HwndSource.FromHwnd(wih.Handle); //添加處理進程 hWndSource.AddHook(Win32.WndProc); }