Ejemplo n.º 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;
        }
Ejemplo n.º 2
0
        /// <summary>Handle the event to log</summary>
        /// <param name="source"></param>
        /// <param name="state"></param>
        /// <param name="includeInformationModel"></param>
        private void HandleEvent(string source, SessionSwitchReason state, bool includeInformationModel)
        {
            //make and Write the log entry
            string line = string.Format("{0} ({1}) - Git:{2}", state, source, GitRepositoryCurrentBranch());

            if (includeInformationModel)
            {
                line += " " + JsonConvert.SerializeObject(new InformationModel());
            }
            StorageFileManager.Write(line);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
            }
        }