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); }
private void BtnOk_Click(object sender, EventArgs e) { timeControl.SetTimeLimitPerDay((int)allowedHours.Value, (int)allowedMinutes.Value); timeControl.SetTimeBeforBreak((int)powerOffHours.Value, (int)powerOffMinutes.Value); reg.WriteDayTimeLimit(timeControl.GetTimeLimitPerDayInMinutes()); reg.WriteBreakPeriod(timeControl.GetTimeBeforBreakInMinutes()); HideToSystemArea(); }
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(); }