Ejemplo n.º 1
0
        public void TimerTick(object sender, EventArgs e)
        {
            //определить сколько часов осталось до достижения лимита работы в сутки
            //определить сколько минут осталось до достижения лимита работы в сутки
            //определить сколько секудн осталось до достижения лимита работы в сутки
            //how much time the computer has already worked for today

            timeBefoBreakInSeconds--;

            string min = string.Format("{0}", timeBefoBreakInSeconds / 60);
            string sec = string.Format("{0}", timeBefoBreakInSeconds % 60);

            if (timeBefoBreakInSeconds % 60 < 10)
            {
                sec = "0" + sec;
            }

            if (timeBefoBreakInSeconds <= 0)
            {
                TimeParameters tp = new TimeParameters();
                timeBefoBreakInSeconds = (tp.GetTimeBeforBreakInMinutes() * 60) + (tp.GetPauseTimeInMilisecons() / 1000);
            }

            labelBeforBlockLeft.Text = string.Format("{0}:{1}", min, sec);
        }
Ejemplo n.º 2
0
        public CheckOut()
        {
            reg        = new Register();
            timeParams = new TimeParameters();

            timeParams.SetTimeLimitPerDayInMinutes(reg.ReadDayTimeLimit());

            //DateTime.Now
            timeParams.SetComputerStartDateTime(reg.ReadPcStartDateTime());
            timeParams.SetTimeBeforBreak(reg.ReadBreakPeriod());

            timeOutTimer = new System.Timers.Timer();

            Debug.WriteLine("Allowed time of work - {0}, PowerOff hours - {1}, power off min - {2}",
                            timeParams.GetTimeLimitPerDayInMinutes(),
                            timeParams.GetTimeBeforBreakHours(),
                            timeParams.GetTimeLimitPerDayMinutes());
        }
Ejemplo n.º 3
0
        public MainForm()
        {
            InitializeComponent();

            //Register.DeleteKey();

            reg         = new Register();
            timeControl = new TimeParameters();

            //retrive from reg nesessary values
            timeControl.SetTimeLimitPerDayInMinutes(reg.ReadDayTimeLimit());
            timeControl.SetComputerStartDateTime(DateTime.Now);
            timeControl.SetTimeBeforBreak(reg.ReadBreakPeriod());
            timeControl.SetPauseTimeInMilisecons(1 * 60 * 1000); //5 minutes

            Debug.WriteLine("Allowed time of work - {0}, PowerOff hours - {1}, power off min - {2}",
                            timeControl.GetTimeLimitPerDayInMinutes(),
                            timeControl.GetTimeBeforBreakHours(),
                            timeControl.GetTimeLimitPerDayMinutes());

            /*shows the values in controls*/
            allowedHours.Value   = timeControl.GetTimeLimitPerDayHours();
            allowedMinutes.Value = timeControl.GetTimeLimitPerDayMinutes();

            powerOffHours.Value   = timeControl.GetTimeBeforBreakHours();
            powerOffMinutes.Value = timeControl.GetTimeBeforBreakMinutes();

            WindowState   = FormWindowState.Minimized;
            ShowInTaskbar = false;

            TimeParameters tp = new TimeParameters();

            timeBefoBreakInSeconds = (tp.GetTimeBeforBreakInMinutes() * 60) + (tp.GetPauseTimeInMilisecons() / 1000);

            StartTimeControl();
        }