Auto formatting

This commit is contained in:
Vladimir
2024-07-28 13:28:31 +04:00
parent 419db64fd8
commit 1a576c50c6

View File

@@ -94,7 +94,7 @@ namespace Process_Auto_Relaunch
if (myBackgroundWorker.WorkerSupportsCancellation && myBackgroundWorker.IsBusy) if (myBackgroundWorker.WorkerSupportsCancellation && myBackgroundWorker.IsBusy)
{ {
myBackgroundWorker.CancelAsync(); myBackgroundWorker.CancelAsync();
UpdateStatus("Отменяем...",NotifyLevel.logUpdateStatus); UpdateStatus("Отменяем...", NotifyLevel.logUpdateStatus);
} }
} }
@@ -144,7 +144,7 @@ namespace Process_Auto_Relaunch
/// </summary> /// </summary>
/// <param name="text">Текст для отображения/отправки </param> /// <param name="text">Текст для отображения/отправки </param>
/// <param name="level">Флаги для назначения отправки</param> /// <param name="level">Флаги для назначения отправки</param>
public void UpdateStatus( string text, NotifyLevel level ) public void UpdateStatus(string text, NotifyLevel level)
{ {
if (!level.HasFlag(NotifyLevel.logAlways) && !level.HasFlag(NotifyLevel.logUpdateStatus)) return; if (!level.HasFlag(NotifyLevel.logAlways) && !level.HasFlag(NotifyLevel.logUpdateStatus)) return;
labelStatus.Text = text; labelStatus.Text = text;
@@ -155,7 +155,7 @@ namespace Process_Auto_Relaunch
/// </summary> /// </summary>
/// <param name="text">Текст для отображения/отправки </param> /// <param name="text">Текст для отображения/отправки </param>
/// <param name="level">Флаги для назначения отправки</param> /// <param name="level">Флаги для назначения отправки</param>
private void HistoryLog( string text, NotifyLevel level ) private void HistoryLog(string text, NotifyLevel level)
{ {
if (!level.HasFlag(NotifyLevel.logAlways) && !level.HasFlag(NotifyLevel.logHistory)) return; if (!level.HasFlag(NotifyLevel.logAlways) && !level.HasFlag(NotifyLevel.logHistory)) return;
richTextBoxHistory.Text += DateTime.Now.ToString() + ": " + text + "\n"; richTextBoxHistory.Text += DateTime.Now.ToString() + ": " + text + "\n";
@@ -166,7 +166,7 @@ namespace Process_Auto_Relaunch
/// </summary> /// </summary>
/// <param name="text">Текст для отображения/отправки </param> /// <param name="text">Текст для отображения/отправки </param>
/// <param name="level">Флаги для назначения отправки</param> /// <param name="level">Флаги для назначения отправки</param>
public void SendDiscordMessage( string text, NotifyLevel level ) public void SendDiscordMessage(string text, NotifyLevel level)
{ {
if (!level.HasFlag(NotifyLevel.logAlways) && !level.HasFlag(NotifyLevel.logDiscord)) return; if (!level.HasFlag(NotifyLevel.logAlways) && !level.HasFlag(NotifyLevel.logDiscord)) return;
if (Settings.Default.dwhEnabled) if (Settings.Default.dwhEnabled)
@@ -181,7 +181,7 @@ namespace Process_Auto_Relaunch
} }
catch (Exception ex) catch (Exception ex)
{ {
Status($"Ошибка отправки в дискорд.",NotifyLevel.logHistory); Status($"Ошибка отправки в дискорд.", NotifyLevel.logHistory);
Debug.WriteLine($"Discord messaging error: {ex.Message}"); Debug.WriteLine($"Discord messaging error: {ex.Message}");
//Settings.Default.dwhEnabled = false; //Settings.Default.dwhEnabled = false;
//Settings.Default.Save(); //Settings.Default.Save();
@@ -232,8 +232,8 @@ namespace Process_Auto_Relaunch
} }
int lastSlash = openFile.FileName.LastIndexOf("\\"); int lastSlash = openFile.FileName.LastIndexOf("\\");
textBoxProcessName.Text = openFile.FileName.Substring(lastSlash+1); textBoxProcessName.Text = openFile.FileName.Substring(lastSlash + 1);
textBoxProcessName.Text = textBoxProcessName.Text.Remove(textBoxProcessName.Text.Length-4); textBoxProcessName.Text = textBoxProcessName.Text.Remove(textBoxProcessName.Text.Length - 4);
Settings.Default.startProgramPath = openFile.FileName; Settings.Default.startProgramPath = openFile.FileName;
Settings.Default.Save(); Settings.Default.Save();
tipProgramStartPath.SetToolTip(this.labelProgramStartPath, Settings.Default.startProgramPath); tipProgramStartPath.SetToolTip(this.labelProgramStartPath, Settings.Default.startProgramPath);
@@ -319,11 +319,13 @@ namespace Process_Auto_Relaunch
{ {
if (ProcessByNameIsRuning(path)) if (ProcessByNameIsRuning(path))
{ {
// Процесс уже запущен
return; return;
} }
} }
WatchedProcess=Process.Start(path, args); // Процесс не запущен
WatchedProcess = Process.Start(path, args);
cpuLastTime = 0; cpuLastTime = 0;
cpuMeasureTimer.Start(); cpuMeasureTimer.Start();
Status($"Процесс {ProcessName} был запущен.", NotifyLevel.logAlways); Status($"Процесс {ProcessName} был запущен.", NotifyLevel.logAlways);
@@ -359,9 +361,9 @@ namespace Process_Auto_Relaunch
cpuMeasureTimer.Reset(); cpuMeasureTimer.Reset();
cpuMeasureTimer.Start(); cpuMeasureTimer.Start();
Status($"Процесс {ProcessName} уже запущен.",NotifyLevel.logUpdateStatus); Status($"Процесс {ProcessName} уже запущен.", NotifyLevel.logUpdateStatus);
processInformationLabel.Text = $"Интерфейс: {ProcessAnswer}. ЦПУ: {cpuPercent:f2}% {cpuTotalTime:f2}мсек"; processInformationLabel.Text = $"Интерфейс: {ProcessAnswer}. ЦПУ: {cpuPercent:f2}% {cpuTotalTime:f2}мсек";
if (i < (int)numericUpDown1.Value) SendDiscordMessage($"Процесс {ProcessName} запущен.",NotifyLevel.logDiscord); if (i < (int)numericUpDown1.Value) SendDiscordMessage($"Процесс {ProcessName} запущен.", NotifyLevel.logDiscord);
i = (int)numericUpDown1.Value; i = (int)numericUpDown1.Value;
} }
else else
@@ -369,7 +371,7 @@ namespace Process_Auto_Relaunch
processInformationLabel.Text = ""; processInformationLabel.Text = "";
if (radioButtonRestartTimer.Checked) if (radioButtonRestartTimer.Checked)
{ {
if (i==(int)numericUpDown1.Value) Status($"Процесс {ProcessName} не найден. Запуск через {i} сек",NotifyLevel.logDiscord); if (i == (int)numericUpDown1.Value) Status($"Процесс {ProcessName} не найден. Запуск через {i} сек", NotifyLevel.logDiscord);
i--; i--;
Status($"Процесс {ProcessName} не найден. Запуск через {i}", NotifyLevel.logUpdateStatus); Status($"Процесс {ProcessName} не найден. Запуск через {i}", NotifyLevel.logUpdateStatus);
} }
@@ -377,7 +379,7 @@ namespace Process_Auto_Relaunch
if (i <= 0 || radioButtonRestartNow.Checked) if (i <= 0 || radioButtonRestartNow.Checked)
{ {
i = (int)numericUpDown1.Value; i = (int)numericUpDown1.Value;
Status($"Запускаем {ProcessName}", NotifyLevel.logUpdateStatus|NotifyLevel.logDiscord); Status($"Запускаем {ProcessName}", NotifyLevel.logUpdateStatus | NotifyLevel.logDiscord);
ProcessStart(Settings.Default.startProgramPath, textBoxArguments.Text); ProcessStart(Settings.Default.startProgramPath, textBoxArguments.Text);
} }
} }
@@ -396,7 +398,7 @@ namespace Process_Auto_Relaunch
{ {
if (e.Cancelled) if (e.Cancelled)
{ {
Status("Наблюдение отменено.",NotifyLevel.logUpdateStatus|NotifyLevel.logDiscord); Status("Наблюдение отменено.", NotifyLevel.logUpdateStatus | NotifyLevel.logDiscord);
} }
else if (e.Error != null) else if (e.Error != null)
{ {
@@ -407,7 +409,7 @@ namespace Process_Auto_Relaunch
} }
else else
{ {
Status("Наблюдение остановлено.", NotifyLevel.logUpdateStatus|NotifyLevel.logDiscord); Status("Наблюдение остановлено.", NotifyLevel.logUpdateStatus | NotifyLevel.logDiscord);
} }
} }