示例#1
0
        /// <summary>Constructor - NotifyIcon initializer</summary>
        /// <param name="notifyIcon"></param>
        public TimeManager(NotifyIcon notifyIcon)
        {
            _notifyIcon = notifyIcon;

            //initialize user state with unlocked since the program started
            _userState = new Dictionary <string, SessionSwitchReason> {
                { StorageFileManager.GetLoginUserName(), SessionSwitchReason.SessionUnlock }
            };

            //Read the configuration
            Config = StorageFileManager.ReadConfig();

            //Clear the log
            StorageFileManager.Clear();

            //create a new timer to go for a number of seconds (1000 milliseconds = 1 second)
            timer = new System.Timers.Timer(Config.PollingIntervalInSeconds * 1000D);
            //have the timer start again when it finishes..  (creates an interval timer)
            timer.AutoReset = true;
            //Define what to do when the timer goes off - call timer_Elapsed
            timer.Elapsed += timer_Elapsed;
            //Start the timer
            timer.Start();

            //capture SystemEvent SessionSwitch
            SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
        }
示例#2
0
        private SessionSwitchReason GetUserState()
        {
            string key = StorageFileManager.GetLoginUserName();
            SessionSwitchReason val;

            if (!_userState.TryGetValue(key, out val))
            {
                _userState.Add(key, SessionSwitchReason.SessionUnlock);
                val = SessionSwitchReason.SessionUnlock;
            }

            return(val);
        }
示例#3
0
        private void SetUserState(SessionSwitchReason newState)
        {
            string key = StorageFileManager.GetLoginUserName();
            SessionSwitchReason val;

            if (_userState.TryGetValue(key, out val))
            {
                _userState[key] = newState;
            }
            else
            {
                _userState.Add(key, newState);
            }
        }