private void MainWindow_Shown(object sender, EventArgs e) { if (!Config.Validate()) { Close(); return; } Refresh(); Jobs.Load(); Variables.Load(); if (!Jobs.LoadSuccess) { Cursor = Cursors.Default; lblStatus.Text = @"Load failed."; var failMessage = string.IsNullOrWhiteSpace(Jobs.LoadFailedMessage) ? "An unknown error has occured." : Jobs.LoadFailedMessage; var t = new StringBuilder(); t.Append(failMessage); t.AppendLine(); t.AppendLine(); if (!Config.IsAdministrator) { t.Append("The application will close."); t.AppendLine(); t.AppendLine(); t.AppendLine("To be able to edit the job list, start JobRunner as administrator."); } MessageBox.Show(t.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Error); if (!Config.IsAdministrator) { Close(); } } if (Config.IsAdministrator && !string.IsNullOrWhiteSpace(Jobs.LoadFailedMessage)) { MessageDisplayer.Yell(Jobs.LoadFailedMessage, Text); } grid1.Initialize(Jobs); if (Config.IsAdministrator) { Text = @"JobRunner (Administrator)"; lblStatus.Text = @"Done."; } else { Text = @"JobRunner"; lblStatus.Text = @"Done (read only)."; } Cursor = Cursors.Default; if (Config.AutoStart && AutoActionDialog.CheckAutoStart(this)) { runToolStripMenuItem_Click(this, new EventArgs()); } }
private void RunJobsCompletedActions() { lblStatus.Text = CleanExit ? @"Done." : $@"Break. Completed: {Jobs.Completed}, error: {Jobs.Error}, no action: {Jobs.Pending}"; EnableGui(true); grid1.Running = false; grid1.Invalidate(); if (Config.AutoClose && Jobs.RunSuccess && AutoActionDialog.CheckAutoClose(this)) { Close(); } }