private void ChangeStatus(bool flag) { string StS = ""; if ((GetToDo(LeavingToDoFlag) == "") || ((GetToDo(LeavingToDoFlag) == "何もしない"))) { StS = "通知します"; } else { StS = GetToDo(LeavingToDoFlag) + "を実行します"; } EnabledFlag = flag; BackedTime = DateTimeOffset.Now; if (EnabledFlag == true) { ControlButton.Text = "無効にする"; TickingTimer1.Start(); StatusLabel.Text = "離席時間 " + GetTimeString(LeaveDetectTime_H, LeaveDetectTime_M, LeaveDetectTime_S) + "後に" + StS; } else { ControlButton.Text = "有効にする"; TickingTimer1.Stop(); StatusLabel.Text = "タイマーは無効です"; } }
private void TickingTimer1_Tick(object sender, EventArgs e) { if (EnabledFlag == true) { Backx = x; Backy = y; x = Cursor.Position.X; y = Cursor.Position.Y; if ((x != Backx) || (y != Backy)) { //LeavingCount = 0; BackedTime = DateTimeOffset.Now; LeaveCheck(); } else { //LeavingCount++; LeaveCheck(); } TickingTimer1.Stop(); TickingTimer1.Start(); } else { LeavingTimeLabel.Text = "--:--:--"; } }
private void Form1_Load(object sender, EventArgs e) { TickingTimer1.Start(); }