internal void workTimer(object mainWindow) { DateTime WorkIntervalLeft = MinTime.AddMinutes(workInterval); //00:25:00 MainWindow main = (MainWindow)mainWindow; while (MinTime < WorkIntervalLeft) { WorkIntervalLeft = WorkIntervalLeft.AddSeconds(-1); Application.Current.Dispatcher.BeginInvoke(() => { main.WorkingTimeTxtBlock.Text = WorkIntervalLeft.ToString("T"); }); //wait 1 second Thread.Sleep(1000); } if (MinTime == WorkIntervalLeft) // 0 seconds of work left { main.Dispatcher.BeginInvoke(() => { main.WorkingTimeTxtBlock.Text = $"0:{workInterval}:00"; RestWindow rwin = new RestWindow(); rwin.Owner = (MainWindow)mainWindow; // setting rwin window's owner rwin.Show(); }); } }
private RestWindow GetRestWindow(Screen screen) { var screenWidth = screen.WorkingArea.Width; var screenHeight = screen.WorkingArea.Height; var window = new RestWindow { WindowStartupLocation = WindowStartupLocation.Manual, }; window.Left = screen.WorkingArea.X + (screenWidth - window.Width) / 2; window.Top = screen.WorkingArea.Y + (screenHeight - window.Height) / 2; return(window); }
internal void restTimer(object rwind) //this method must be performed In RESTWINDOW window { RestWindow rwin = rwind as RestWindow; DateTime RestIntervalLeft = MinTime.AddMinutes(restInterval); //00:00:30 //MainWindow main = mainWindow as MainWindow; //RestWindow rwin = new RestWindow(); //rwin.Show(); //rwin.Owner = main; while (MinTime < RestIntervalLeft) { RestIntervalLeft = RestIntervalLeft.AddSeconds(-1); rwin.Dispatcher.BeginInvoke(() => { rwin.RestTextBlock.Text = RestIntervalLeft.ToString("T"); }); Thread.Sleep(1000); //wait 1 second if (MinTime == RestIntervalLeft) // 0 seconds of work left { rwin.Dispatcher.BeginInvoke(() => { rwin.RestTextBlock.FontSize = 40; rwin.RestTextBlock.Text = "Отдых закончен, пора и поработать!"; }); } //actions after 'while': //if button"продолжить работу" pressed, resttime left should be added to the next resttime. window closed. method worktimer runs. } }