From 6349357d7af5b5b34489db72af1e2bef55fca117 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Sun, 26 May 2024 23:48:36 +0400 Subject: [PATCH] Send a message at the start --- Form1.cs | 89 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 45 insertions(+), 44 deletions(-) diff --git a/Form1.cs b/Form1.cs index 2a1fe76..5cc5a99 100644 --- a/Form1.cs +++ b/Form1.cs @@ -22,10 +22,10 @@ namespace Process_Auto_Relaunch public enum NotifyLevel { logNone = 0, - logAlways = 1, // ������ ����� - logUpdateStatus = 2, // ������ � ������ ��������� - logHistory = 4, // ������ � ���� ������� ������������ - logDiscord = 8 // ������ � ������� + logAlways = 1, // ïèñàòü âåçäå + logUpdateStatus = 2, // ïèñàòü â ñòðîêå ñîñòîÿíèÿ + logHistory = 4, // ïèñàòü â îêíå èñòîðèè ïåðåçàïóñêîâ + logDiscord = 8 // ïèñàòü â Äèñêîðä } private delegate void UpdateLogDelegate(string text, NotifyLevel level = NotifyLevel.logUpdateStatus); private readonly UpdateLogDelegate updateLogDelegate; @@ -45,8 +45,8 @@ namespace Process_Auto_Relaunch dwhHook.Url = Settings.Default.dwhURL; } else if (Settings.Default.dwhEnabled) { - Debug.WriteLine($"������ � URL ���-���� ({Settings.Default.dwhURL}). ����� � Discord ��������."); - HistoryLog($"������ � URL ���-���� ({Settings.Default.dwhURL}). ����� � Discord ��������."); + Debug.WriteLine($"Îøèáêà â URL âåá-õóêà ({Settings.Default.dwhURL}). Âûâîä â Discord îòêëþ÷åí."); + HistoryLog($"Îøèáêà â URL âåá-õóêà ({Settings.Default.dwhURL}). Âûâîä â Discord îòêëþ÷åí."); Settings.Default.dwhEnabled = false; Settings.Default.Save(); }*/ @@ -54,7 +54,7 @@ namespace Process_Auto_Relaunch } /// - /// ������� ������� ����� + /// Ñîáûòèå çàïóñêà ôîðìû /// /// /// @@ -68,7 +68,7 @@ namespace Process_Auto_Relaunch } /// - /// �������������� �������� + /// Âîññòàíîâëåíèå íàñòðîåê /// private void LoadOldState() { @@ -80,7 +80,7 @@ namespace Process_Auto_Relaunch } /// - /// ����� ��� ������� ���������� + /// Ìåòîä äëÿ ñîáûòèÿ îòêëþ÷åíèÿ /// /// /// @@ -96,12 +96,12 @@ namespace Process_Auto_Relaunch if (myBackgroundWorker.WorkerSupportsCancellation && myBackgroundWorker.IsBusy) { myBackgroundWorker.CancelAsync(); - UpdateStatus("��������...",NotifyLevel.logUpdateStatus); + UpdateStatus("Îòìåíÿåì...",NotifyLevel.logUpdateStatus); } } /// - /// ����� ��� ������� ��������� + /// Ìåòîä äëÿ ñîáûòèÿ âêëþ÷åíèÿ /// /// /// @@ -116,15 +116,15 @@ namespace Process_Auto_Relaunch if (String.IsNullOrEmpty(textBoxProcessName.Text)) { error = true; - MessageBox.Show("��� �������� �� ����� ���� ������!" + - "\n������� ��� ��������", "������", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Èìÿ ïðîöåññà íå ìîæåò áûòü ïóñòûì!" + + "\nÓêàæèòå èìÿ ïðîöåññà", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (String.IsNullOrEmpty(Settings.Default.startProgramPath)) { error = true; - MessageBox.Show("��������� ��� ������� �� �������." + - "\n������� ��������� ��� �������", "������", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Ïðîãðàììà äëÿ çàïóñêà íå óêàçàíà." + + "\nÓêàæèòå ïðîãðàììó äëÿ çàïóñêà", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (error) @@ -137,14 +137,15 @@ namespace Process_Auto_Relaunch if (!myBackgroundWorker.IsBusy) { myBackgroundWorker.RunWorkerAsync(); + Status($"Çàïóñêàåì íàáëþäåíèå...", NotifyLevel.logDiscord); } } /// - /// ���������� ������� � ��������� + /// Îáíîâëåíèå ñòàòóñà â ïðîãðàììå /// - /// ����� ��� �����������/�������� - /// ����� ��� ���������� �������� + /// Òåêñò äëÿ îòîáðàæåíèÿ/îòïðàâêè + /// Ôëàãè äëÿ íàçíà÷åíèÿ îòïðàâêè public void UpdateStatus( string text, NotifyLevel level ) { if (!level.HasFlag(NotifyLevel.logAlways) && !level.HasFlag(NotifyLevel.logUpdateStatus)) return; @@ -152,10 +153,10 @@ namespace Process_Auto_Relaunch } /// - /// ���������� ������ � ������� �������� + /// Äîáàâëåíèå ñòðîêè â Èñòîðèè Çàïóñêîâ /// - /// ����� ��� �����������/�������� - /// ����� ��� ���������� �������� + /// Òåêñò äëÿ îòîáðàæåíèÿ/îòïðàâêè + /// Ôëàãè äëÿ íàçíà÷åíèÿ îòïðàâêè private void HistoryLog( string text, NotifyLevel level ) { if (!level.HasFlag(NotifyLevel.logAlways) && !level.HasFlag(NotifyLevel.logHistory)) return; @@ -163,10 +164,10 @@ namespace Process_Auto_Relaunch } /// - /// �������� ������� � Discord + /// Îòïðàâêà ñòàòóñà â Discord /// - /// ����� ��� �����������/�������� - /// ����� ��� ���������� �������� + /// Òåêñò äëÿ îòîáðàæåíèÿ/îòïðàâêè + /// Ôëàãè äëÿ íàçíà÷åíèÿ îòïðàâêè public void SendDiscordMessage( string text, NotifyLevel level ) { if (!level.HasFlag(NotifyLevel.logAlways) && !level.HasFlag(NotifyLevel.logDiscord)) return; @@ -182,7 +183,7 @@ namespace Process_Auto_Relaunch } catch (Exception ex) { - Status($"������ �������� � �������.",NotifyLevel.logHistory); + Status($"Îøèáêà îòïðàâêè â äèñêîðä.",NotifyLevel.logHistory); Debug.WriteLine($"Discord messaging error: {ex.Message}"); //Settings.Default.dwhEnabled = false; //Settings.Default.Save(); @@ -191,10 +192,10 @@ namespace Process_Auto_Relaunch } /// - /// ���������� ������� � ��������� + /// Îáíîâëåíèå ñòàòóñà â ïðîãðàììå /// - /// ����� ��� �����������/�������� - /// ����� ��� ���������� �������� + /// Òåêñò äëÿ îòîáðàæåíèÿ/îòïðàâêè + /// Ôëàãè äëÿ íàçíà÷åíèÿ îòïðàâêè public void Status(string text, NotifyLevel level = NotifyLevel.logUpdateStatus) { Invoke(updateLogDelegate, text, level); @@ -203,12 +204,12 @@ namespace Process_Auto_Relaunch private void CheckProgramState() { bool watching = radioButtonEnableWathing.Checked; - Debug.WriteLine($"����������: {watching}"); + Debug.WriteLine($"Íàáëþäåíèå: {watching}"); groupBoxProcessName.Enabled = !watching; groupBoxProgramStart.Enabled = !watching; groupBoxActions.Enabled = !watching; - btnShowDiscordSettings.Enabled = !watching; //��������� ������ �������� �������� + btnShowDiscordSettings.Enabled = !watching; //îòêëþ÷àåì êíîïêó íàñòðîåê äèñêîðäà Settings.Default.enableWatching = watching; @@ -216,15 +217,15 @@ namespace Process_Auto_Relaunch } /// - /// ����� ����� ��� ������� + /// Âûáîð ôàéëà äëÿ çàïóñêà /// /// /// private void ButtonSetProgramStart_Click(object sender, EventArgs e) { OpenFileDialog openFile = new OpenFileDialog(); - openFile.Filter = "����������� ����� (*.exe)|*.exe"; - openFile.Title = "������� ��������� �������"; + openFile.Filter = "Èñïîëíÿåìûå ôàéëû (*.exe)|*.exe"; + openFile.Title = "Óêàæèòå ïðîãðàììó çàïóñêà"; if (openFile.ShowDialog() == DialogResult.Cancel) { @@ -240,7 +241,7 @@ namespace Process_Auto_Relaunch } /// - /// ������� ����� ��������� ����� + /// Ñîáûòèå ïåðåä çàêðûòèåì ôîðìû /// /// /// @@ -274,7 +275,7 @@ namespace Process_Auto_Relaunch } } - Status("������� ��� �������.", NotifyLevel.logAlways); + Status("Ïðîöåññ áûë çàïóùåí.", NotifyLevel.logAlways); Process.Start(path, args); } @@ -287,23 +288,23 @@ namespace Process_Auto_Relaunch { if (ProcessByNameIsRuning(textBoxProcessName.Text)) { - Status($"������� ��� �������",NotifyLevel.logUpdateStatus); - if (i < (int)numericUpDown1.Value) SendDiscordMessage($"������� {textBoxProcessName.Text} �������.",NotifyLevel.logDiscord); + Status($"Ïðîöåññ óæå çàïóùåí",NotifyLevel.logUpdateStatus); + if (i < (int)numericUpDown1.Value) SendDiscordMessage($"Ïðîöåññ {textBoxProcessName.Text} çàïóùåí.",NotifyLevel.logDiscord); i = (int)numericUpDown1.Value; } else { if (radioButtonRestartTimer.Checked) { - if (i==(int)numericUpDown1.Value) Status($"������� {textBoxProcessName.Text} �� ������. ������ ����� {i} ���",NotifyLevel.logDiscord); + if (i==(int)numericUpDown1.Value) Status($"Ïðîöåññ {textBoxProcessName.Text} íå íàéäåí. Çàïóñê ÷åðåç {i} ñåê",NotifyLevel.logDiscord); i--; - Status($"������� {textBoxProcessName.Text} �� ������. ������ ����� {i}", NotifyLevel.logUpdateStatus); + Status($"Ïðîöåññ {textBoxProcessName.Text} íå íàéäåí. Çàïóñê ÷åðåç {i}", NotifyLevel.logUpdateStatus); } if (i <= 0 || radioButtonRestartNow.Checked) { i = (int)numericUpDown1.Value; - Status($"��������� {textBoxProcessName.Text}", NotifyLevel.logUpdateStatus|NotifyLevel.logDiscord); + Status($"Çàïóñêàåì {textBoxProcessName.Text}", NotifyLevel.logUpdateStatus|NotifyLevel.logDiscord); ProcessStart(Settings.Default.startProgramPath, textBoxArguments.Text); } } @@ -321,17 +322,17 @@ namespace Process_Auto_Relaunch { if (e.Cancelled) { - Status("���������� ��������.",NotifyLevel.logUpdateStatus|NotifyLevel.logDiscord); + Status("Íàáëþäåíèå îòìåíåíî.",NotifyLevel.logUpdateStatus|NotifyLevel.logDiscord); } else if (e.Error != null) { - Status("��������� ������! ���������� �����������.", NotifyLevel.logUpdateStatus | NotifyLevel.logDiscord); - MessageBox.Show("Error: " + e.Error.Message, "������", MessageBoxButtons.OK, MessageBoxIcon.Stop); + Status("Ïðîèçîøëà îøèáêà! Íàáëþäåíèå îñòàíîâëåíî.", NotifyLevel.logUpdateStatus | NotifyLevel.logDiscord); + MessageBox.Show("Error: " + e.Error.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Stop); radioButtonDisableWathing.Checked = true; } else { - Status("���������� �����������.", NotifyLevel.logUpdateStatus|NotifyLevel.logDiscord); + Status("Íàáëþäåíèå îñòàíîâëåíî.", NotifyLevel.logUpdateStatus|NotifyLevel.logDiscord); } }