From 81f43f911f86188856838a66d47fc79a72f9af5d Mon Sep 17 00:00:00 2001
From: SlothDpal <16717792+SlothDpal@users.noreply.github.com>
Date: Thu, 23 May 2024 14:09:27 +0300
Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?=
=?UTF-8?q?=D0=BD=D1=8B=20=D0=B0=D0=B2=D0=B0=D1=82=D0=B0=D1=80=20=D0=B8=20?=
=?UTF-8?q?=D0=B8=D0=BC=D1=8F=20=D0=B1=D0=BE=D1=82=D0=B0=20=D0=B2=20Discor?=
=?UTF-8?q?d,=20=D0=BC=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20=D1=84=D0=B8=D0=BA?=
=?UTF-8?q?=D1=81=D1=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
App.config | 6 ++
DiscordSettings.Designer.cs | 123 ++++++++++++++++++++++++--------
DiscordSettings.cs | 16 +++--
Form1.Designer.cs | 2 +-
Form1.cs | 46 ++++++++----
Properties/Settings.Designer.cs | 27 ++++++-
Properties/Settings.settings | 6 ++
7 files changed, 173 insertions(+), 53 deletions(-)
diff --git a/App.config b/App.config
index 49cf587..ac315de 100644
--- a/App.config
+++ b/App.config
@@ -38,6 +38,12 @@
False
+
+ Relauncher
+
+
+ https://distribution.faceit-cdn.net/images/7240adfa-6bda-43a0-abd0-8c599f176686.jpeg
+
diff --git a/DiscordSettings.Designer.cs b/DiscordSettings.Designer.cs
index ba8d3c2..b468ace 100644
--- a/DiscordSettings.Designer.cs
+++ b/DiscordSettings.Designer.cs
@@ -30,15 +30,20 @@
{
this.btnOk = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
- this.chbxDiscordEnabled = new System.Windows.Forms.CheckBox();
- this.textDwhURL = new System.Windows.Forms.TextBox();
this.lblDwhURL = new System.Windows.Forms.Label();
this.btnClearUrlField = new System.Windows.Forms.Button();
+ this.lblDwhBotname = new System.Windows.Forms.Label();
+ this.lblDwhAvatarUrl = new System.Windows.Forms.Label();
+ this.textDwhAvatarUrl = new System.Windows.Forms.TextBox();
+ this.textDwhBotName = new System.Windows.Forms.TextBox();
+ this.textDwhURL = new System.Windows.Forms.TextBox();
+ this.chbxDiscordEnabled = new System.Windows.Forms.CheckBox();
+ this.btnClearAvatarUrlField = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// btnOk
//
- this.btnOk.Location = new System.Drawing.Point(193, 89);
+ this.btnOk.Location = new System.Drawing.Point(215, 155);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(75, 23);
this.btnOk.TabIndex = 0;
@@ -49,7 +54,7 @@
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- this.btnCancel.Location = new System.Drawing.Point(274, 89);
+ this.btnCancel.Location = new System.Drawing.Point(296, 155);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 1;
@@ -57,31 +62,10 @@
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.BtnCancel_Click);
//
- // chbxDiscordEnabled
- //
- this.chbxDiscordEnabled.AutoSize = true;
- this.chbxDiscordEnabled.Checked = global::RelaunchProcess.Properties.Settings.Default.dwhEnabled;
- this.chbxDiscordEnabled.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::RelaunchProcess.Properties.Settings.Default, "dwhEnabled", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
- this.chbxDiscordEnabled.Location = new System.Drawing.Point(12, 63);
- this.chbxDiscordEnabled.Name = "chbxDiscordEnabled";
- this.chbxDiscordEnabled.Size = new System.Drawing.Size(232, 17);
- this.chbxDiscordEnabled.TabIndex = 2;
- this.chbxDiscordEnabled.Text = "Включить отправку сообщений в Discord";
- this.chbxDiscordEnabled.UseVisualStyleBackColor = true;
- //
- // textDwhURL
- //
- this.textDwhURL.DataBindings.Add(new System.Windows.Forms.Binding("Text", global::RelaunchProcess.Properties.Settings.Default, "dwhURL", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
- this.textDwhURL.Location = new System.Drawing.Point(12, 37);
- this.textDwhURL.Name = "textDwhURL";
- this.textDwhURL.Size = new System.Drawing.Size(337, 20);
- this.textDwhURL.TabIndex = 3;
- this.textDwhURL.Text = global::RelaunchProcess.Properties.Settings.Default.dwhURL;
- //
// lblDwhURL
//
this.lblDwhURL.AutoSize = true;
- this.lblDwhURL.Location = new System.Drawing.Point(9, 9);
+ this.lblDwhURL.Location = new System.Drawing.Point(9, 87);
this.lblDwhURL.Name = "lblDwhURL";
this.lblDwhURL.Size = new System.Drawing.Size(147, 13);
this.lblDwhURL.TabIndex = 4;
@@ -90,13 +74,84 @@
// btnClearUrlField
//
this.btnClearUrlField.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
- this.btnClearUrlField.Location = new System.Drawing.Point(351, 38);
+ this.btnClearUrlField.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
+ this.btnClearUrlField.Location = new System.Drawing.Point(352, 103);
this.btnClearUrlField.Name = "btnClearUrlField";
this.btnClearUrlField.Size = new System.Drawing.Size(19, 19);
this.btnClearUrlField.TabIndex = 5;
this.btnClearUrlField.Text = "X";
this.btnClearUrlField.UseVisualStyleBackColor = true;
- this.btnClearUrlField.Click += new System.EventHandler(this.BtnClearUrlField_Click);
+ this.btnClearUrlField.Click += new System.EventHandler(this.ClearUrl);
+ //
+ // lblDwhBotname
+ //
+ this.lblDwhBotname.AutoSize = true;
+ this.lblDwhBotname.Location = new System.Drawing.Point(9, 9);
+ this.lblDwhBotname.Name = "lblDwhBotname";
+ this.lblDwhBotname.Size = new System.Drawing.Size(127, 13);
+ this.lblDwhBotname.TabIndex = 6;
+ this.lblDwhBotname.Text = "Имя бота в сообщении:";
+ //
+ // lblDwhAvatarUrl
+ //
+ this.lblDwhAvatarUrl.AutoSize = true;
+ this.lblDwhAvatarUrl.Location = new System.Drawing.Point(9, 48);
+ this.lblDwhAvatarUrl.Name = "lblDwhAvatarUrl";
+ this.lblDwhAvatarUrl.Size = new System.Drawing.Size(102, 13);
+ this.lblDwhAvatarUrl.TabIndex = 6;
+ this.lblDwhAvatarUrl.Text = "URL аватара бота:";
+ //
+ // textDwhAvatarUrl
+ //
+ this.textDwhAvatarUrl.DataBindings.Add(new System.Windows.Forms.Binding("Text", global::RelaunchProcess.Properties.Settings.Default, "dwhAvatarURL", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
+ this.textDwhAvatarUrl.Location = new System.Drawing.Point(9, 64);
+ this.textDwhAvatarUrl.Name = "textDwhAvatarUrl";
+ this.textDwhAvatarUrl.Size = new System.Drawing.Size(337, 20);
+ this.textDwhAvatarUrl.TabIndex = 7;
+ this.textDwhAvatarUrl.Text = global::RelaunchProcess.Properties.Settings.Default.dwhAvatarURL;
+ //
+ // textDwhBotName
+ //
+ this.textDwhBotName.DataBindings.Add(new System.Windows.Forms.Binding("Text", global::RelaunchProcess.Properties.Settings.Default, "dwhBotname", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
+ this.textDwhBotName.Location = new System.Drawing.Point(9, 25);
+ this.textDwhBotName.MaxLength = 40;
+ this.textDwhBotName.Name = "textDwhBotName";
+ this.textDwhBotName.Size = new System.Drawing.Size(211, 20);
+ this.textDwhBotName.TabIndex = 7;
+ this.textDwhBotName.Text = global::RelaunchProcess.Properties.Settings.Default.dwhBotname;
+ //
+ // textDwhURL
+ //
+ this.textDwhURL.DataBindings.Add(new System.Windows.Forms.Binding("Text", global::RelaunchProcess.Properties.Settings.Default, "dwhURL", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
+ this.textDwhURL.Location = new System.Drawing.Point(9, 103);
+ this.textDwhURL.Name = "textDwhURL";
+ this.textDwhURL.Size = new System.Drawing.Size(337, 20);
+ this.textDwhURL.TabIndex = 3;
+ this.textDwhURL.Text = global::RelaunchProcess.Properties.Settings.Default.dwhURL;
+ //
+ // chbxDiscordEnabled
+ //
+ this.chbxDiscordEnabled.AutoSize = true;
+ this.chbxDiscordEnabled.Checked = global::RelaunchProcess.Properties.Settings.Default.dwhEnabled;
+ this.chbxDiscordEnabled.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::RelaunchProcess.Properties.Settings.Default, "dwhEnabled", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
+ this.chbxDiscordEnabled.Location = new System.Drawing.Point(9, 129);
+ this.chbxDiscordEnabled.Name = "chbxDiscordEnabled";
+ this.chbxDiscordEnabled.Size = new System.Drawing.Size(232, 17);
+ this.chbxDiscordEnabled.TabIndex = 2;
+ this.chbxDiscordEnabled.Text = "Включить отправку сообщений в Discord";
+ this.chbxDiscordEnabled.UseVisualStyleBackColor = true;
+ //
+ // btnClearAvatarUrlField
+ //
+ this.btnClearAvatarUrlField.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
+ this.btnClearAvatarUrlField.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
+ this.btnClearAvatarUrlField.Location = new System.Drawing.Point(352, 65);
+ this.btnClearAvatarUrlField.Name = "btnClearAvatarUrlField";
+ this.btnClearAvatarUrlField.Size = new System.Drawing.Size(19, 19);
+ this.btnClearAvatarUrlField.TabIndex = 5;
+ this.btnClearAvatarUrlField.Text = "X";
+ this.btnClearAvatarUrlField.UseVisualStyleBackColor = true;
+ this.btnClearAvatarUrlField.Click += new System.EventHandler(this.ClearUrl);
//
// DiscordSettings
//
@@ -104,8 +159,13 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
- this.ClientSize = new System.Drawing.Size(375, 128);
+ this.ClientSize = new System.Drawing.Size(387, 188);
this.ControlBox = false;
+ this.Controls.Add(this.textDwhAvatarUrl);
+ this.Controls.Add(this.textDwhBotName);
+ this.Controls.Add(this.lblDwhAvatarUrl);
+ this.Controls.Add(this.lblDwhBotname);
+ this.Controls.Add(this.btnClearAvatarUrlField);
this.Controls.Add(this.btnClearUrlField);
this.Controls.Add(this.lblDwhURL);
this.Controls.Add(this.textDwhURL);
@@ -132,5 +192,10 @@
private System.Windows.Forms.TextBox textDwhURL;
private System.Windows.Forms.Label lblDwhURL;
private System.Windows.Forms.Button btnClearUrlField;
+ private System.Windows.Forms.Label lblDwhBotname;
+ private System.Windows.Forms.TextBox textDwhBotName;
+ private System.Windows.Forms.Label lblDwhAvatarUrl;
+ private System.Windows.Forms.TextBox textDwhAvatarUrl;
+ private System.Windows.Forms.Button btnClearAvatarUrlField;
}
}
\ No newline at end of file
diff --git a/DiscordSettings.cs b/DiscordSettings.cs
index 523a211..624c494 100644
--- a/DiscordSettings.cs
+++ b/DiscordSettings.cs
@@ -26,9 +26,12 @@ namespace RelaunchProcess
private void BtnOk_Click(object sender, EventArgs e)
{
- if (Uri.IsWellFormedUriString(textDwhURL.Text, UriKind.Absolute)||textDwhURL.Text=="")
+ if ( (String.IsNullOrEmpty(textDwhURL.Text) ||
+ Uri.IsWellFormedUriString(textDwhURL.Text, UriKind.Absolute)) &&
+ (String.IsNullOrEmpty(textDwhAvatarUrl.Text) ||
+ Uri.IsWellFormedUriString(textDwhAvatarUrl.Text, UriKind.Absolute)) )
{
- if (textDwhURL.Text=="")
+ if (String.IsNullOrEmpty(textDwhURL.Text))
{
chbxDiscordEnabled.Checked = false;
}
@@ -38,15 +41,14 @@ namespace RelaunchProcess
}
else
{
- //TODO обработать ситуацию с неверным УРЛом
- textDwhURL.Text = "";
- MessageBox.Show("Неверный формат URL.", "URL", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ MessageBox.Show("Неверный формат URL.\rОчистите или исправьте.", "URL", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
- private void BtnClearUrlField_Click(object sender, EventArgs e)
+ private void ClearUrl(object sender, EventArgs e)
{
- textDwhURL.Text = "";
+ if ( (Button)sender == btnClearUrlField ) textDwhURL.Text = "";
+ if ( (Button)sender == btnClearAvatarUrlField ) textDwhAvatarUrl.Text = "";
}
}
}
diff --git a/Form1.Designer.cs b/Form1.Designer.cs
index ef18e8f..0c65f12 100644
--- a/Form1.Designer.cs
+++ b/Form1.Designer.cs
@@ -166,7 +166,7 @@ namespace Process_Auto_Relaunch
this.buttonSetProgramStart.TabIndex = 1;
this.buttonSetProgramStart.Text = "Обзор";
this.buttonSetProgramStart.UseVisualStyleBackColor = true;
- this.buttonSetProgramStart.Click += new System.EventHandler(this.buttonSetProgramStart_Click);
+ this.buttonSetProgramStart.Click += new System.EventHandler(this.ButtonSetProgramStart_Click);
//
// groupBoxProgramStart
//
diff --git a/Form1.cs b/Form1.cs
index 10dd541..61e4881 100644
--- a/Form1.cs
+++ b/Form1.cs
@@ -40,7 +40,7 @@ namespace Process_Auto_Relaunch
this.updateLogDelegate += this.HistoryLog;
myBackgroundWorker.WorkerSupportsCancellation = true;
dwhHook = new DiscordWebhook();
- if ( Uri.IsWellFormedUriString(Settings.Default.dwhURL,UriKind.Absolute) && Settings.Default.dwhEnabled && Settings.Default.dwhURL!="")
+ /*if ( Uri.IsWellFormedUriString(Settings.Default.dwhURL,UriKind.Absolute) && Settings.Default.dwhEnabled && Settings.Default.dwhURL!="")
{
dwhHook.Url = Settings.Default.dwhURL;
}
@@ -49,7 +49,7 @@ namespace Process_Auto_Relaunch
HistoryLog($" URL - ({Settings.Default.dwhURL}). Discord .");
Settings.Default.dwhEnabled = false;
Settings.Default.Save();
- }
+ }*/
}
@@ -143,43 +143,59 @@ namespace Process_Auto_Relaunch
///
///
///
- ///
- ///
+ /// /
+ ///
public void UpdateStatus( string text, NotifyLevel level )
{
if (!level.HasFlag(NotifyLevel.logAlways) && !level.HasFlag(NotifyLevel.logUpdateStatus)) return;
labelStatus.Text = text;
}
- private void HistoryLog( string text, NotifyLevel level = NotifyLevel.logUpdateStatus )
+ ///
+ ///
+ ///
+ /// /
+ ///
+ private void HistoryLog( string text, NotifyLevel level )
{
if (!level.HasFlag(NotifyLevel.logAlways) && !level.HasFlag(NotifyLevel.logHistory)) return;
richTextBoxHistory.Text += DateTime.Now.ToString() + ": " + text + "\n";
}
- public void SendDiscordMessage( string message, NotifyLevel level )
+ ///
+ /// Discord
+ ///
+ /// /
+ ///
+ public void SendDiscordMessage( string text, NotifyLevel level )
{
if (!level.HasFlag(NotifyLevel.logAlways) && !level.HasFlag(NotifyLevel.logDiscord)) return;
if (Settings.Default.dwhEnabled)
{
dwhHook.Url = Settings.Default.dwhURL;
- dwhMessage.Username = "Relaunch process";
- dwhMessage.Content = ":arrows_counterclockwise: " + message;
+ dwhMessage.Username = Settings.Default.dwhBotname;
+ dwhMessage.AvatarUrl = Settings.Default.dwhAvatarURL;
+ dwhMessage.Content = ":arrows_counterclockwise: " + text;
try
{
dwhHook.Send(dwhMessage);
}
catch (Exception ex)
{
- HistoryLog($"Discord messaging error: {ex.Message}");
+ Status($" .",NotifyLevel.logHistory);
Debug.WriteLine($"Discord messaging error: {ex.Message}");
- Settings.Default.dwhEnabled = false;
- Settings.Default.Save();
+ //Settings.Default.dwhEnabled = false;
+ //Settings.Default.Save();
}
}
}
- public void Status(string text, NotifyLevel level)
+ ///
+ ///
+ ///
+ /// /
+ ///
+ public void Status(string text, NotifyLevel level = NotifyLevel.logUpdateStatus)
{
updateLogDelegate.Invoke(text, level);
}
@@ -204,7 +220,7 @@ namespace Process_Auto_Relaunch
///
///
///
- private void buttonSetProgramStart_Click(object sender, EventArgs e)
+ private void ButtonSetProgramStart_Click(object sender, EventArgs e)
{
OpenFileDialog openFile = new OpenFileDialog();
openFile.Filter = " (*.exe)|*.exe";
@@ -305,12 +321,12 @@ namespace Process_Auto_Relaunch
{
if (e.Cancelled)
{
- Status(" .",NotifyLevel.logUpdateStatus);
+ 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);
radioButtonDisableWathing.Checked = true;
}
else
diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs
index 9c4d1e1..a6205d2 100644
--- a/Properties/Settings.Designer.cs
+++ b/Properties/Settings.Designer.cs
@@ -12,7 +12,7 @@ namespace RelaunchProcess.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.9.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.10.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -142,5 +142,30 @@ namespace RelaunchProcess.Properties {
this["dwhEnabled"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("Relauncher")]
+ public string dwhBotname {
+ get {
+ return ((string)(this["dwhBotname"]));
+ }
+ set {
+ this["dwhBotname"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("https://distribution.faceit-cdn.net/images/7240adfa-6bda-43a0-abd0-8c599f176686.j" +
+ "peg")]
+ public string dwhAvatarURL {
+ get {
+ return ((string)(this["dwhAvatarURL"]));
+ }
+ set {
+ this["dwhAvatarURL"] = value;
+ }
+ }
}
}
diff --git a/Properties/Settings.settings b/Properties/Settings.settings
index 3f8eb41..1f40892 100644
--- a/Properties/Settings.settings
+++ b/Properties/Settings.settings
@@ -32,5 +32,11 @@
False
+
+ Relauncher
+
+
+ https://distribution.faceit-cdn.net/images/7240adfa-6bda-43a0-abd0-8c599f176686.jpeg
+
\ No newline at end of file