mirror of
https://github.com/SlothDpal/Relaunch-Process.git
synced 2026-10-22 06:14:16 +03:00
Tune DiscordSettings
This commit is contained in:
4 files changed
+73
-24
No files matched your search
Generated
+1
-1
@@ -163,7 +163,7 @@
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "AboutBox";
|
||||
this.Padding = new System.Windows.Forms.Padding(9, 9, 9, 9);
|
||||
this.Padding = new System.Windows.Forms.Padding(9);
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
|
||||
Generated
+2
-2
@@ -143,7 +143,7 @@ namespace RelaunchProcess
|
||||
this.chbxDiscordEnabled.TabIndex = 2;
|
||||
this.chbxDiscordEnabled.Text = "Включить отправку сообщений в Discord";
|
||||
this.chbxDiscordEnabled.UseVisualStyleBackColor = true;
|
||||
this.chbxDiscordEnabled.CheckedChanged += new System.EventHandler(this.chbxDiscordEnabled_CheckedChanged);
|
||||
this.chbxDiscordEnabled.Click += new System.EventHandler(this.chbxDiscordEnabled_Click);
|
||||
//
|
||||
// btnClearAvatarUrlField
|
||||
//
|
||||
@@ -183,7 +183,7 @@ namespace RelaunchProcess
|
||||
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(404, 241);
|
||||
this.ClientSize = new System.Drawing.Size(404, 264);
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.chbxDiscordEnabled);
|
||||
this.Controls.Add(this.groupBoxSettingsDiscord);
|
||||
|
||||
+67
-18
@@ -1,16 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Printing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Process_Auto_Relaunch;
|
||||
using RelaunchProcess.Properties;
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace RelaunchProcess
|
||||
{
|
||||
@@ -18,6 +9,29 @@ namespace RelaunchProcess
|
||||
{
|
||||
private MainWindow parent;
|
||||
|
||||
private const int dwhBotNameMaxLength = 32;
|
||||
|
||||
// ссылка должна быть валидной, если она не пустая и имеет правильный формат URL
|
||||
private bool LinkIsValid(string url)
|
||||
{
|
||||
return Uri.TryCreate(url.Trim(), UriKind.Absolute, out var uri) &&
|
||||
(uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps) &&
|
||||
!string.IsNullOrWhiteSpace(uri.Host);
|
||||
}
|
||||
|
||||
// ссылка должна быть валидной, если она пустая или имеет правильный формат URL
|
||||
private bool LinkIsValidOrNull(string url)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(url))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return Uri.TryCreate(url.Trim(), UriKind.Absolute, out var uri) &&
|
||||
(uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps) &&
|
||||
!string.IsNullOrWhiteSpace(uri.Host);
|
||||
}
|
||||
|
||||
public WebhookSettings(MainWindow _parent)
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -27,6 +41,12 @@ namespace RelaunchProcess
|
||||
|
||||
private void RestoreSettings()
|
||||
{
|
||||
if ( (string.IsNullOrWhiteSpace(Settings.Default.dwhBotname) || Settings.Default.dwhBotname.Length > dwhBotNameMaxLength))
|
||||
{
|
||||
// значение по умолчанию
|
||||
Settings.Default.dwhBotname = "Auto Relauncher";
|
||||
Settings.Default.Save();
|
||||
}
|
||||
textDwhBotName.Text = Settings.Default.dwhBotname;
|
||||
textDwhAvatarUrl.Text = Settings.Default.dwhAvatarURL;
|
||||
textDwhURL.Text = Settings.Default.dwhURL;
|
||||
@@ -44,6 +64,8 @@ namespace RelaunchProcess
|
||||
|
||||
public void UpdateUI()
|
||||
{
|
||||
// запрещаем изменять настройки, если Discord включен
|
||||
// или разрешаем, если выключен
|
||||
groupBoxSettingsDiscord.Enabled = !chbxDiscordEnabled.Checked;
|
||||
}
|
||||
|
||||
@@ -59,12 +81,10 @@ namespace RelaunchProcess
|
||||
|
||||
private void BtnOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
if ( (String.IsNullOrEmpty(textDwhURL.Text) ||
|
||||
Uri.IsWellFormedUriString(textDwhURL.Text, UriKind.Absolute)) &&
|
||||
(String.IsNullOrEmpty(textDwhAvatarUrl.Text) ||
|
||||
Uri.IsWellFormedUriString(textDwhAvatarUrl.Text, UriKind.Absolute)) )
|
||||
if ( LinkIsValidOrNull(textDwhURL.Text) && LinkIsValidOrNull(textDwhAvatarUrl.Text) &&
|
||||
(!(string.IsNullOrWhiteSpace(textDwhBotName.Text) || textDwhBotName.Text.Length > dwhBotNameMaxLength)))
|
||||
{
|
||||
if (String.IsNullOrEmpty(textDwhURL.Text))
|
||||
if (String.IsNullOrWhiteSpace(textDwhURL.Text))
|
||||
{
|
||||
chbxDiscordEnabled.Checked = false;
|
||||
}
|
||||
@@ -78,7 +98,18 @@ namespace RelaunchProcess
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Неверный формат URL.\rОчистите или исправьте.", "URL", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
if (!LinkIsValidOrNull(textDwhURL.Text))
|
||||
{
|
||||
MessageBox.Show("Неверный формат URL вебхука.\rОчистите или исправьте.", "URL", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
if (!LinkIsValidOrNull(textDwhAvatarUrl.Text))
|
||||
{
|
||||
MessageBox.Show("Неверный формат URL аватара бота.\rОчистите или исправьте.", "URL", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(textDwhBotName.Text) || textDwhBotName.Text.Length > dwhBotNameMaxLength)
|
||||
{
|
||||
MessageBox.Show($"Имя бота не может быть пустым или длиннее {dwhBotNameMaxLength} символов.", "Запуск невозможен", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,8 +119,26 @@ namespace RelaunchProcess
|
||||
if ( (Button)sender == btnClearAvatarUrlField ) textDwhAvatarUrl.Text = "";
|
||||
}
|
||||
|
||||
private void chbxDiscordEnabled_CheckedChanged(object sender, EventArgs e)
|
||||
private void chbxDiscordEnabled_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (chbxDiscordEnabled.Checked)
|
||||
{
|
||||
if ( !LinkIsValid(textDwhURL.Text) )
|
||||
{
|
||||
chbxDiscordEnabled.Checked = false;
|
||||
MessageBox.Show("Неверный формат URL вебхука.\rИ он не может быть пустым для запуска.\rИсправьте его.", "Запуск невозможен", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
if ( !LinkIsValidOrNull(textDwhAvatarUrl.Text) )
|
||||
{
|
||||
chbxDiscordEnabled.Checked = false;
|
||||
MessageBox.Show("Неверный формат URL аватара бота.\rИсправьте или оставьте пустым.", "Запуск невозможен", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
if ( string.IsNullOrWhiteSpace(textDwhBotName.Text) || textDwhBotName.Text.Length > dwhBotNameMaxLength )
|
||||
{
|
||||
chbxDiscordEnabled.Checked = false;
|
||||
MessageBox.Show($"Имя бота не может быть пустым или длиннее {dwhBotNameMaxLength} символов.", "Запуск невозможен", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
UpdateUI();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ using System.Runtime.InteropServices;
|
||||
// Номер сборки
|
||||
// Редакция
|
||||
//
|
||||
[assembly: AssemblyVersion("1.6.1.8")]
|
||||
[assembly: AssemblyFileVersion("1.6.1.8")]
|
||||
[assembly: AssemblyVersion("1.6.1.0921")]
|
||||
[assembly: AssemblyFileVersion("1.6.1.0921")]
|
||||
|
||||
[assembly: AssemblyInformationalVersion("1.6.1.8")]
|
||||
[assembly: AssemblyInformationalVersion("1.6.15")]
|
||||
Reference in new issue
Block a user