public bool Initialize() { if (!isInitialized) { try { // Initialize Clevo WMI Interface Connection if (!clevo.Initialize()) { throw new Exception("Could not connect to Clevo WMI Interface"); } // Update Lights on Logon (Clevo sometimes resets the lights when you Hibernate, this would fix wrong colors) if (updateLightsOnLogon) { sseh = new SessionSwitchEventHandler(SystemEvents_SessionSwitch); SystemEvents.SessionSwitch += sseh; } // Mark Initialized = TRUE isInitialized = true; return(true); } catch (Exception ex) { Global.logger.Error("Clevo device, Exception! Message:" + ex); } // Mark Initialized = FALSE isInitialized = false; return(false); } return(isInitialized); }
public void Run() { //Setting screenLocked to false for now to wait until a screenLocked event happens. If a user needs it to go immediately they can use the /force flag. screenLocked = false; sseh = new SessionSwitchEventHandler(SysEventsCheck); SystemEvents.SessionSwitch += sseh; }
public AdminWindow() { InitializeComponent(); initialiseLoggingFramework(); WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; ssh = new SessionSwitchEventHandler(SysEventsCheck); SystemEvents.SessionSwitch += ssh; initaliseWirelessList(); if (Global.isadmin) { initaliseLeftPanel(); } else { List <String> l = new List <String>(); l.Add(Global.empName); updateLeftPanelView(l); } /* * A non admin does not need admin privledge . Hence disabling buttons which a non admin should not use . */ if (!Global.isadmin) { bluetooth.IsEnabled = false; wireless.IsEnabled = false; } }
public MainProgramForm() { InitializeComponent(); if (Settings.Default.UpgradeRequired) { Settings.Default.Upgrade(); Settings.Default.UpgradeRequired = false; Settings.Default.Save(); reloadSettings(); } allowVisible = !startMinimized; sseh = new SessionSwitchEventHandler(SystemEvents_SessionSwitch); SystemEvents.SessionSwitch += sseh; sysTrayIcon.MouseDoubleClick += new MouseEventHandler(sysTrayIcon_MouseDoubleClick); sysTrayIcon.BalloonTipText = "Timers Running"; this.sysTrayIcon.Icon = this.Icon; sysTrayIcon.Visible = true; sysTrayIcon.ShowBalloonTip(500); this.Left = windowXPos; this.Top = windowYPos; richTextBox1.AppendText(DateTime.Now.ToString() + "\n"); Start(); #if DEBUG testLockBtn.Enabled = true; testLockBtn.Visible = true; testUnlockBtn.Enabled = true; testUnlockBtn.Visible = true; #endif }
/// <summary> /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed. /// <example> /// sessionswitcheventhandler.BeginInvoke(sender, e, callback); /// </example> /// </summary> public static IAsyncResult BeginInvoke(this SessionSwitchEventHandler sessionswitcheventhandler, Object sender, SessionSwitchEventArgs e, AsyncCallback callback) { if (sessionswitcheventhandler == null) { throw new ArgumentNullException("sessionswitcheventhandler"); } return(sessionswitcheventhandler.BeginInvoke(sender, e, callback, null)); }
public static void startListen() { mSystemEvents_SessionSwitch = new SessionSwitchEventHandler(SystemEvents_SessionSwitch); mSystemEvents_PowerModeChanged = new PowerModeChangedEventHandler(SystemEvents_PowerModeChanged); mSystemEvent_ScreenChanged = new EventHandler(SystemEvents_DisplaySettingsChanged); SystemEvents.SessionSwitch += mSystemEvents_SessionSwitch; SystemEvents.PowerModeChanged += mSystemEvents_PowerModeChanged; SystemEvents.DisplaySettingsChanged += mSystemEvent_ScreenChanged; }
public void Run(frmTimeOut form) { timer = new Timer(); timer.Tick += Timer_Tick; timer.Interval = 5000; this.form = form; sseh = new SessionSwitchEventHandler(SysEventsCheck); SystemEvents.SessionSwitch += sseh; }
public Capture() { sessionSwitchEventHandler = new SessionSwitchEventHandler(SwitchHandler); SystemEvents.SessionSwitch += sessionSwitchEventHandler; myEncoderParameters = new EncoderParameters(1); myEncoderParameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 50L); lastInputInfo = new LASTINPUTINFO(); lastInputInfo.cbSize = (uint)Marshal.SizeOf(lastInputInfo); lastInputInfo.dwTime = 0; ni = new NotifyIcon(); ni.Click += Ni_Click; logPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "TickTock"); activityFile = Path.Combine(logPath, "activity.js"); System.IO.Directory.CreateDirectory(logPath); //create the log directory if it doesn't exist var indexHtml = Path.Combine(logPath, "index.html"); if (!File.Exists(indexHtml)) { File.WriteAllText(indexHtml, Resources.index_html); } if (File.Exists(activityFile)) { //scan activity file to get the last lastDay (can scan backwards) var lines = File.ReadAllLines(activityFile).Reverse().Take(6000); foreach (string line in lines) { if (line.StartsWith("b=a['")) { lastDay = line.Substring(5, 10); Console.WriteLine("LastDay: " + lastDay); break; } } } timer = new Timer(); timer.Tick += new EventHandler(TimerEvent); timer.Interval = 120000; //2 minute default //15000; //15 seconds default //Capture once on start. TimerEvent(null, null); toggle = new ToolStripMenuItem(); toggle.Text = "Start"; toggle.Click += new System.EventHandler(Toggle_Click); toggle.Image = Resources.Start; }
/** * Create event handlers needed to detect various state changes that affect window capture. * This is done explicitly with assigned fields to allow proper disposal. According to the * documentation, if not properly disposed, there will be leaks (although I'm skeptical for * this use case, since they live the lifetime of the process). */ private void CreateEventHandlers() { this.displaySettingsChangingHandler = (s, e) => { Log.Trace("Display settings changing handler invoked"); this.ignoreCaptureRequests = true; CancelDelayedCapture(); // Throw away any pending captures }; this.displaySettingsChangedHandler = (s, e) => { Log.Trace("Display settings changed"); StateDetector.WaitForWindowStabilization(() => { // CancelDelayedCapture(); // Throw away any pending captures BeginRestoreApplicationsOnCurrentDisplays(); }); }; this.powerModeChangedHandler = (s, e) => { switch (e.Mode) { case PowerModes.Suspend: Log.Info("System Suspending"); break; case PowerModes.Resume: Log.Info("System Resuming"); this.ignoreCaptureRequests = true; CancelDelayedCapture(); // Throw away any pending captures BeginRestoreApplicationsOnCurrentDisplays(); break; default: Log.Trace("Unhandled power mode change: {0}", nameof(e.Mode)); break; } }; this.sessionSwitchEventHandler = (sender, args) => { if (args.Reason == SessionSwitchReason.SessionLock) { Log.Trace("Session locked"); this.isSessionLocked = true; } else if (args.Reason == SessionSwitchReason.SessionUnlock) { Log.Trace("Session unlocked"); this.isSessionLocked = false; } }; }
public void Run() { sessionActiveTimer.Elapsed += new System.Timers.ElapsedEventHandler(sessionActiveTime_Elapsed); sessionLockTimer.Elapsed += new System.Timers.ElapsedEventHandler(sessionLockTime_Elapsed); sessionActiveTimer.Start(); sessionStateChangedHandler = new SessionSwitchEventHandler(OnStatusChanged); SystemEvents.SessionSwitch += sessionStateChangedHandler; }
public Form1() { InitializeComponent(); comboBox1.Text = "OFF"; SetControlDevice(DEVICE_INDEX.DEV_MKeys_L); lockeffect = Properties.Settings.Default.LOCKEFFECT; Console.WriteLine("Lockscreen Setting: " + Properties.Settings.Default.LOCKEFFECT + " Lockscreen Variable: " + lockeffect); sseh = new SessionSwitchEventHandler(SystemEvents_SessionSwitch); SystemEvents.SessionSwitch += sseh; }
public Form1() { InitializeComponent(); sseh = new SessionSwitchEventHandler(SystemEvents_SessionSwitch); SystemEvents.SessionSwitch += sseh; _effects_KeyPress_1.TempColor = Color.FromArgb(_effects_KeyPress_1.primaryRED, _effects_KeyPress_1.primaryGREEN, _effects_KeyPress_1.primaryBLUE); panelPrimaryColor.BackColor = _effects_KeyPress_1.TempColor; _effects_KeyPress_1.TempColor = Color.FromArgb(_effects_KeyPress_1.secondaryRED, _effects_KeyPress_1.secondaryGREEN, _effects_KeyPress_1.secondaryBLUE); panelSecondary.BackColor = _effects_KeyPress_1.TempColor; SetControlDevice(DEVICE_INDEX.DEV_MKeys_L); }
public BusySimulatorUI() { this.AppConfig = new BusySimulatorConfig(); this.SessionLockHandler = new SessionSwitchEventHandler(SystemEvents_SessionSwitch); SystemEvents.SessionSwitch += this.SessionLockHandler; InitUIControls(); this.AppConfig.PropertyChanged += AppConfig_PropertyChanged; this.AppConfig.AutoSavePropertyValuesInRegistry = true; this.AppConfig.RefreshUI(); }
public void Shutdown() { if (this.IsInitialized()) { // Release Clevo Connection clevo.ResetKBLEDColors(); clevo.Release(); // Uninstantiate Session Switch if (sseh != null) { SystemEvents.SessionSwitch -= sseh; sseh = null; } } }
public Form1() { InitializeComponent(); ControladorCamara = new ControladorCamara(); ControladorCamara.BuscarDispositivos(); cboDispositivos.DataSource = ControladorCamara.lstCant; cboDispositivos.ValueMember = "MonikeCam"; cboDispositivos.DisplayMember = "NameCam"; //=================================================== //Sobrecargas para la captura de estado de Windows(Bloqueado o desbloqueado) sseh = new SessionSwitchEventHandler(SystemEvents_SessionSwitch); SystemEvents.SessionSwitch += sseh; //=================================================== }
public Form1() { InitializeComponent(); Rectangle workingArea = Screen.GetWorkingArea(this); this.Location = new Point(workingArea.Right - Size.Width, workingArea.Bottom - Size.Height); //Display Date label6.Text = DateTime.Now.Date.ToString("dd/MM/yyyy"); //Display Username label9.Text = Environment.UserName.ToString().ToUpper(); //Display In-Time label10.Text = DateTime.Now.ToString("hh:mm tt"); sseh = new SessionSwitchEventHandler(SysEventsCheck); SystemEvents.SessionSwitch += sseh; try { RegistryKey rk = Registry.CurrentUser.OpenSubKey ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); string ab = rk.GetValue(Application.ProductName).ToString(); if (ab != null) { toolStripMenuItem1.Checked = true; } else { toolStripMenuItem1.Checked = true; } } catch { } stopwatch.Start(); timer1.Start(); }
public HoverWindow() { //detect lock event and save state or restore state _sseh = new SessionSwitchEventHandler(SysEventsCheck); SystemEvents.SessionSwitch += _sseh; //detect sleep mode and save state _powerMode = new PowerModeChangedEventHandler(OnPowerModeChanged); SystemEvents.PowerModeChanged += _powerMode; InitializeComponent(); _baseSearch = ConfigurationManager.AppSettings["BaseSearch"]; _ignoreBaseSearch = bool.Parse(ConfigurationManager.AppSettings["IgnoreBaseSearch"]); //_autoUpdate = new AutoUpdater(ConfigurationManager.AppSettings["AutoUpdateURL"],new TimeSpan(int.Parse(ConfigurationManager.AppSettings["VersionUpdateCheckIntervalHours"]), 0, 0)); loadSettings(); //_autoUpdate.Run(); }
private void startMonitor() { sseh = new SessionSwitchEventHandler(SystemEvents_SessionSwitch); SystemEvents.SessionSwitch += sseh; DataManager.storeStartPresence(DateTime.Now); Configuration c = DataManagerConf.read().FirstOrDefault(); if (c == null) { c = new Configuration(); c.PathToWatch = Directory.GetCurrentDirectory(); } watcher = new FileSystemWatcher(); watcher.Path = c.PathToWatch; watcher.NotifyFilter = NotifyFilters.LastWrite; /* NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName; */ watcher.Filter = "*.*"; watcher.Changed += new FileSystemEventHandler(OnChanged); watcher.EnableRaisingEvents = true; }
public void SignalsSessionSwitch(SessionSwitchReason reason) { bool signaled = false; SessionSwitchEventArgs args = null; SessionSwitchEventHandler switchHandler = (o, e) => { signaled = true; args = e; }; SystemEvents.SessionSwitch += switchHandler; try { SendMessage(reason); Assert.True(signaled); Assert.NotNull(args); Assert.Equal(reason, args.Reason); } finally { SystemEvents.SessionSwitch -= switchHandler; } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); // Get initial settings var appSettings = ConfigurationManager.AppSettings; try { interval = Convert.ToInt32(appSettings["interval"]); FileLogger.Log("Using interval from app.config: " + interval, 1); } catch { interval = 60000; FileLogger.Log("Using default interval of 60000: " + interval, 1); } try { timeServerURL = appSettings["TimeServerURL"]; FileLogger.Log("Using " + timeServerURL + " from App.Config", 1); } catch { timeServerURL = "http://timeserver.tomeofjamin.net:20145"; FileLogger.Log("Issue in App.Config entry for <add key=\"TimeServerURL\" value=\"http://timeserverurl\"/>. Using " + timeServerURL, 1); } try { LogLevel = Convert.ToInt32(appSettings["LogLevel"]); FileLogger.Log("Using LogLevel from app.config: " + LogLevel, 1); } catch { LogLevel = 1; // Default log level FileLogger.Log("Using default log level: " + LogLevel, 1); } try { audioVolumeThreshold = Convert.ToInt32(appSettings["audioVolumeThreshold"]); FileLogger.Log("Using audioVolumeThreshold from app.config: " + audioVolumeThreshold, 1); } catch { audioVolumeThreshold = 0.005f; FileLogger.Log("Using default audioVolumeThreshold: " + audioVolumeThreshold, 1); } httpHandler.setTimeServerUrl(timeServerURL); // Set up a timer that triggers every minute. timer = new System.Timers.Timer(); timer.Interval = interval; timer.Elapsed += OnTimer; timer.Start(); // Register event for when user locks the system sseh = new SessionSwitchEventHandler(SysEventsCheck); SystemEvents.SessionSwitch += sseh; // Use application context so we can exist only in the system tray Application.Run(new MyCustomApplicationContext()); }
public EventMonitoringService(IOutputService outputService, Action<EventMonitoringService> handler) { _eventHandler = handler; _sessionSwitchEventHandler = HandleLock; _outputService = outputService; }
public void Run() { sseh = new SessionSwitchEventHandler(SysEventsCheck); SystemEvents.SessionSwitch += sseh; }
public AdminWindow() { InitializeComponent(); initialiseLoggingFramework(); WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; ssh = new SessionSwitchEventHandler(SysEventsCheck); SystemEvents.SessionSwitch += ssh; initaliseWirelessList(); if (Global.isadmin) initaliseLeftPanel(); else { List<String> l = new List<String>(); l.Add(Global.empName); updateLeftPanelView(l); } /* * A non admin does not need admin privledge . Hence disabling buttons which a non admin should not use . */ if (!Global.isadmin) { bluetooth.IsEnabled = false; wireless.IsEnabled = false; } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Auto-run check AutoRun.AutoRunCheck(); // Check for updates Updater.Check(); // Setup the session handler _ss = new SessionSwitchEventHandler(SessionSwitch); SystemEvents.SessionSwitch += _ss; // Setup the tray icon and context menu ContextMenu cm = new ContextMenu(); MenuItem lob = new MenuItem("Launch on Boot", new EventHandler(LaunchOnBootClick)); lob.Checked = AutoRun.Run; cm.MenuItems.Add(lob); cm.MenuItems.Add(new MenuItem("Quit", new EventHandler(QuitClick))); _trayIcon.Icon = Properties.Resources.MainIcon; _trayIcon.Text = "Spotify Auto Pauser"; _trayIcon.ContextMenu = cm; _trayIcon.Visible = true; _trayIcon.MouseClick += new MouseEventHandler(TrayClick); // Wait until the user exits Application.Run(); }
public MainPage() { sseh = new SessionSwitchEventHandler(SystemEvents_SessionSwitch); SystemEvents.SessionSwitch += sseh; InitializeComponent(); }
public SystemStatusSource(string settings) { this.hSessionSwitch = new SessionSwitchEventHandler(SystemEvents_SessionSwitch); SystemEvents.SessionSwitch += this.hSessionSwitch; }
public void Run() { //LastLockStartTime = DateTime.Now; sseh = new SessionSwitchEventHandler(ComputerLockCheck); SystemEvents.SessionSwitch += sseh; }
public EventMonitoringService(IOutputService outputService, Action <EventMonitoringService> handler) { _eventHandler = handler; _sessionSwitchEventHandler = HandleLock; _outputService = outputService; }
/// <summary> /// Initializes a new instance of the <see cref="SessionMonitor"/> class. /// </summary> /// <param name="ssEvent">Session switch event.</param> public SessionMonitor(SessionSwitchEvent ssEvent) { ssEventHandler = new SessionSwitchEventHandler(ssEvent); }