Esempio n. 1
0
        public static Locker GetLocker()
        {
            if (_locker == null)
            {
                StreamReader savedDataFile;
                try
                {
                    savedDataFile = new StreamReader("LastSession.dat");
                    DateTime oldDate = DateTime.Parse(savedDataFile.ReadLine());
                    DateTime curreentDate = DateTime.Now;
                    if (curreentDate.Date > oldDate.Date)
                        _locker = new Locker(Properties.Settings.Default.maxAllowedTime,
                                             Properties.Settings.Default.maxAllowedTime);
                    else
                        _locker = new Locker(TimeSpan.Parse(savedDataFile.ReadLine()),
                                             Properties.Settings.Default.maxAllowedTime);
                }
                catch (FileNotFoundException)
                {
                    _locker = new Locker(Properties.Settings.Default.maxAllowedTime,
                                         Properties.Settings.Default.maxAllowedTime);
                }
            }

            return _locker;
        }
Esempio n. 2
0
        public Locktimer(Locker locker)
        {
            _locker = locker;
            _timeController = new RemainingTimeController(LastSessionSynchronizer.GetAllowedTime());

            locker.LockStatusChanged += SessionSwitchEvent;
            locker.SystemShutdown += SaveData;
            _timeController.TimeOut += Lock;
        }