mirror of
https://github.com/SlothDpal/Relaunch-Process.git
synced 2026-02-22 17:27:38 +03:00
Added history log
This commit is contained in:
39
Form1.Designer.cs
generated
39
Form1.Designer.cs
generated
@@ -51,12 +51,15 @@ namespace Process_Auto_Relaunch
|
|||||||
this.labelProgramStartPath = new System.Windows.Forms.Label();
|
this.labelProgramStartPath = new System.Windows.Forms.Label();
|
||||||
this.checkBoxCheckProcess = new System.Windows.Forms.CheckBox();
|
this.checkBoxCheckProcess = new System.Windows.Forms.CheckBox();
|
||||||
this.radioButtonRestartNow = new System.Windows.Forms.RadioButton();
|
this.radioButtonRestartNow = new System.Windows.Forms.RadioButton();
|
||||||
|
this.groupBoxHistory = new System.Windows.Forms.GroupBox();
|
||||||
|
this.richTextBoxHistory = new System.Windows.Forms.RichTextBox();
|
||||||
this.groupBoxActions.SuspendLayout();
|
this.groupBoxActions.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
|
||||||
this.groupBoxProgramStart.SuspendLayout();
|
this.groupBoxProgramStart.SuspendLayout();
|
||||||
this.groupBoxProcessName.SuspendLayout();
|
this.groupBoxProcessName.SuspendLayout();
|
||||||
this.groupBoxEnabled.SuspendLayout();
|
this.groupBoxEnabled.SuspendLayout();
|
||||||
this.groupBoxStatus.SuspendLayout();
|
this.groupBoxStatus.SuspendLayout();
|
||||||
|
this.groupBoxHistory.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBoxActions
|
// groupBoxActions
|
||||||
@@ -179,7 +182,7 @@ namespace Process_Auto_Relaunch
|
|||||||
this.groupBoxProcessName.Size = new System.Drawing.Size(383, 62);
|
this.groupBoxProcessName.Size = new System.Drawing.Size(383, 62);
|
||||||
this.groupBoxProcessName.TabIndex = 8;
|
this.groupBoxProcessName.TabIndex = 8;
|
||||||
this.groupBoxProcessName.TabStop = false;
|
this.groupBoxProcessName.TabStop = false;
|
||||||
this.groupBoxProcessName.Text = "Название наблюдаемого процесса";
|
this.groupBoxProcessName.Text = "Название наблюдаемого процесса (без расширения)";
|
||||||
//
|
//
|
||||||
// groupBoxEnabled
|
// groupBoxEnabled
|
||||||
//
|
//
|
||||||
@@ -312,9 +315,9 @@ namespace Process_Auto_Relaunch
|
|||||||
this.checkBoxCheckProcess.Location = new System.Drawing.Point(11, 78);
|
this.checkBoxCheckProcess.Location = new System.Drawing.Point(11, 78);
|
||||||
this.checkBoxCheckProcess.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
this.checkBoxCheckProcess.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||||
this.checkBoxCheckProcess.Name = "checkBoxCheckProcess";
|
this.checkBoxCheckProcess.Name = "checkBoxCheckProcess";
|
||||||
this.checkBoxCheckProcess.Size = new System.Drawing.Size(190, 20);
|
this.checkBoxCheckProcess.Size = new System.Drawing.Size(265, 20);
|
||||||
this.checkBoxCheckProcess.TabIndex = 2;
|
this.checkBoxCheckProcess.TabIndex = 2;
|
||||||
this.checkBoxCheckProcess.Text = "Не создавать дубликаты";
|
this.checkBoxCheckProcess.Text = "Проверять наличие перед запуском";
|
||||||
this.checkBoxCheckProcess.UseVisualStyleBackColor = true;
|
this.checkBoxCheckProcess.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// radioButtonRestartNow
|
// radioButtonRestartNow
|
||||||
@@ -330,11 +333,36 @@ namespace Process_Auto_Relaunch
|
|||||||
this.radioButtonRestartNow.Text = "Перезапускать сразу";
|
this.radioButtonRestartNow.Text = "Перезапускать сразу";
|
||||||
this.radioButtonRestartNow.UseVisualStyleBackColor = true;
|
this.radioButtonRestartNow.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
|
// groupBoxHistory
|
||||||
|
//
|
||||||
|
this.groupBoxHistory.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.groupBoxHistory.Controls.Add(this.richTextBoxHistory);
|
||||||
|
this.groupBoxHistory.Location = new System.Drawing.Point(13, 514);
|
||||||
|
this.groupBoxHistory.Name = "groupBoxHistory";
|
||||||
|
this.groupBoxHistory.Size = new System.Drawing.Size(383, 132);
|
||||||
|
this.groupBoxHistory.TabIndex = 11;
|
||||||
|
this.groupBoxHistory.TabStop = false;
|
||||||
|
this.groupBoxHistory.Text = "История запусков";
|
||||||
|
//
|
||||||
|
// richTextBoxHistory
|
||||||
|
//
|
||||||
|
this.richTextBoxHistory.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.richTextBoxHistory.Location = new System.Drawing.Point(0, 21);
|
||||||
|
this.richTextBoxHistory.Name = "richTextBoxHistory";
|
||||||
|
this.richTextBoxHistory.ReadOnly = true;
|
||||||
|
this.richTextBoxHistory.Size = new System.Drawing.Size(383, 111);
|
||||||
|
this.richTextBoxHistory.TabIndex = 0;
|
||||||
|
this.richTextBoxHistory.Text = "";
|
||||||
|
//
|
||||||
// Form1
|
// Form1
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(421, 533);
|
this.ClientSize = new System.Drawing.Size(421, 658);
|
||||||
|
this.Controls.Add(this.groupBoxHistory);
|
||||||
this.Controls.Add(this.groupBoxStatus);
|
this.Controls.Add(this.groupBoxStatus);
|
||||||
this.Controls.Add(this.groupBoxEnabled);
|
this.Controls.Add(this.groupBoxEnabled);
|
||||||
this.Controls.Add(this.groupBoxProcessName);
|
this.Controls.Add(this.groupBoxProcessName);
|
||||||
@@ -359,6 +387,7 @@ namespace Process_Auto_Relaunch
|
|||||||
this.groupBoxEnabled.PerformLayout();
|
this.groupBoxEnabled.PerformLayout();
|
||||||
this.groupBoxStatus.ResumeLayout(false);
|
this.groupBoxStatus.ResumeLayout(false);
|
||||||
this.groupBoxStatus.PerformLayout();
|
this.groupBoxStatus.PerformLayout();
|
||||||
|
this.groupBoxHistory.ResumeLayout(false);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -385,5 +414,7 @@ namespace Process_Auto_Relaunch
|
|||||||
public Label labelStatus;
|
public Label labelStatus;
|
||||||
private System.ComponentModel.BackgroundWorker myBackgroundWorker;
|
private System.ComponentModel.BackgroundWorker myBackgroundWorker;
|
||||||
private NumericUpDown numericUpDown1;
|
private NumericUpDown numericUpDown1;
|
||||||
|
private GroupBox groupBoxHistory;
|
||||||
|
private RichTextBox richTextBoxHistory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
40
Form1.cs
40
Form1.cs
@@ -10,7 +10,7 @@ namespace Process_Auto_Relaunch
|
|||||||
{
|
{
|
||||||
public partial class Form1 : Form
|
public partial class Form1 : Form
|
||||||
{
|
{
|
||||||
private delegate void UpdateLogDelegate(string text);
|
private delegate void UpdateLogDelegate(string text, bool add_history = false);
|
||||||
private UpdateLogDelegate updateLogDelegate = null;
|
private UpdateLogDelegate updateLogDelegate = null;
|
||||||
|
|
||||||
public Form1()
|
public Form1()
|
||||||
@@ -45,6 +45,11 @@ namespace Process_Auto_Relaunch
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ìåòîä äëÿ ñîáûòèÿ îòêëþ÷åíèÿ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
private void radioButtonDisableWathing_CheckedChanged(object sender, EventArgs e)
|
private void radioButtonDisableWathing_CheckedChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
CheckProgramState();
|
CheckProgramState();
|
||||||
@@ -61,7 +66,11 @@ namespace Process_Auto_Relaunch
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ìåòîä äëÿ ñîáûòèÿ âêëþ÷åíèÿ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
private void radioButtonEnableWathing_CheckedChanged(object sender, EventArgs e)
|
private void radioButtonEnableWathing_CheckedChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (!radioButtonEnableWathing.Checked)
|
if (!radioButtonEnableWathing.Checked)
|
||||||
@@ -97,14 +106,29 @@ namespace Process_Auto_Relaunch
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateStatus(string text)
|
/// <summary>
|
||||||
|
/// Îáíîâëåíèå ñòàòóñà â ïðîãðàììå
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text">Òåêñò äëÿ îòîáðàæåíèÿ</param>
|
||||||
|
/// <param name="add_history">Ñîõðàíåíèå òåêñòà â îêíî èñòîðèè</param>
|
||||||
|
public void UpdateStatus(string text, bool add_history = false)
|
||||||
{
|
{
|
||||||
labelStatus.Text = text;
|
labelStatus.Text = text;
|
||||||
|
|
||||||
|
if (add_history)
|
||||||
|
{
|
||||||
|
HistoryLog(text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Status(string text)
|
private void HistoryLog(string text)
|
||||||
{
|
{
|
||||||
Invoke(updateLogDelegate, new[] { text });
|
richTextBoxHistory.Text += DateTime.Now.ToString() + ": " + text + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Status(string text, bool add_history = false)
|
||||||
|
{
|
||||||
|
Invoke(updateLogDelegate, text, add_history);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckProgramState()
|
private void CheckProgramState()
|
||||||
@@ -167,7 +191,8 @@ namespace Process_Auto_Relaunch
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Status("Ïðîöåññ áûë çàïóùåí.", true);
|
||||||
Process.Start(path, args);
|
Process.Start(path, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,6 +218,7 @@ namespace Process_Auto_Relaunch
|
|||||||
|
|
||||||
if (i <= 0 || radioButtonRestartNow.Checked)
|
if (i <= 0 || radioButtonRestartNow.Checked)
|
||||||
{
|
{
|
||||||
|
i = (int)numericUpDown1.Value;
|
||||||
Status("Çàïóñêàåì...");
|
Status("Çàïóñêàåì...");
|
||||||
ProcessStart(Settings.Default.startProgramPath, textBoxArguments.Text);
|
ProcessStart(Settings.Default.startProgramPath, textBoxArguments.Text);
|
||||||
}
|
}
|
||||||
@@ -216,7 +242,7 @@ namespace Process_Auto_Relaunch
|
|||||||
else if (e.Error != null)
|
else if (e.Error != null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Error: " + e.Error.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
MessageBox.Show("Error: " + e.Error.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
||||||
Status("Ïðîèçîøëà îøèáêà. Íàáëþäåíèå îñòàíîâëåíî!");
|
Status("Ïðîèçîøëà îøèáêà! Íàáëþäåíèå îñòàíîâëåíî.", true);
|
||||||
radioButtonDisableWathing.Checked = true;
|
radioButtonDisableWathing.Checked = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user