mirror of
https://github.com/SlothDpal/Relaunch-Process.git
synced 2026-02-22 17:27:38 +03:00
5
.gitignore
vendored
5
.gitignore
vendored
@@ -360,4 +360,7 @@ MigrationBackup/
|
|||||||
.ionide/
|
.ionide/
|
||||||
|
|
||||||
# Fody - auto-generated XML schema
|
# Fody - auto-generated XML schema
|
||||||
FodyWeavers.xsd
|
FodyWeavers.xsd
|
||||||
|
/CSharpDiscordWebhook.dll
|
||||||
|
/Newtonsoft.Json.dll
|
||||||
|
/Newtonsoft.Json.xml
|
||||||
|
|||||||
26
App.config
26
App.config
@@ -32,21 +32,19 @@
|
|||||||
<setting name="timer" serializeAs="String">
|
<setting name="timer" serializeAs="String">
|
||||||
<value>30</value>
|
<value>30</value>
|
||||||
</setting>
|
</setting>
|
||||||
|
<setting name="dwhURL" serializeAs="String">
|
||||||
|
<value />
|
||||||
|
</setting>
|
||||||
|
<setting name="dwhEnabled" serializeAs="String">
|
||||||
|
<value>False</value>
|
||||||
|
</setting>
|
||||||
|
<setting name="dwhBotname" serializeAs="String">
|
||||||
|
<value>Relauncher</value>
|
||||||
|
</setting>
|
||||||
|
<setting name="dwhAvatarURL" serializeAs="String">
|
||||||
|
<value>https://distribution.faceit-cdn.net/images/7240adfa-6bda-43a0-abd0-8c599f176686.jpeg</value>
|
||||||
|
</setting>
|
||||||
</RelaunchProcess.Properties.Settings>
|
</RelaunchProcess.Properties.Settings>
|
||||||
<Process_Auto_Relaunch.Properties.Settings>
|
|
||||||
<setting name="startProgramPath" serializeAs="String">
|
|
||||||
<value/>
|
|
||||||
</setting>
|
|
||||||
<setting name="arguments" serializeAs="String">
|
|
||||||
<value/>
|
|
||||||
</setting>
|
|
||||||
<setting name="disableWathing" serializeAs="String">
|
|
||||||
<value>True</value>
|
|
||||||
</setting>
|
|
||||||
<setting name="saveOldState" serializeAs="String">
|
|
||||||
<value>True</value>
|
|
||||||
</setting>
|
|
||||||
</Process_Auto_Relaunch.Properties.Settings>
|
|
||||||
</userSettings>
|
</userSettings>
|
||||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup>
|
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
104
Discord/DiscordWebHook.cs
Normal file
104
Discord/DiscordWebHook.cs
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Discord.Webhook
|
||||||
|
{
|
||||||
|
public class DiscordWebhook
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Webhook url
|
||||||
|
/// </summary>
|
||||||
|
public string Url { get; set; }
|
||||||
|
|
||||||
|
private void AddField(MemoryStream stream, string bound, string cDisposition, string cType, byte[] data)
|
||||||
|
{
|
||||||
|
string prefix = stream.Length > 0 ? "\r\n--" : "--";
|
||||||
|
string fBegin = $"{prefix}{bound}\r\n";
|
||||||
|
|
||||||
|
byte[] fBeginBuffer = Utils.Encode(fBegin);
|
||||||
|
byte[] cDispositionBuffer = Utils.Encode(cDisposition);
|
||||||
|
byte[] cTypeBuffer = Utils.Encode(cType);
|
||||||
|
|
||||||
|
stream.Write(fBeginBuffer, 0, fBeginBuffer.Length);
|
||||||
|
stream.Write(cDispositionBuffer, 0, cDispositionBuffer.Length);
|
||||||
|
stream.Write(cTypeBuffer, 0, cTypeBuffer.Length);
|
||||||
|
stream.Write(data, 0, data.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetJsonPayload(MemoryStream stream, string bound, string json)
|
||||||
|
{
|
||||||
|
string cDisposition = "Content-Disposition: form-data; name=\"payload_json\"\r\n";
|
||||||
|
string cType = "Content-Type: application/octet-stream\r\n\r\n";
|
||||||
|
AddField(stream, bound, cDisposition, cType, Utils.Encode(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetFile(MemoryStream stream, string bound, int index, FileInfo file)
|
||||||
|
{
|
||||||
|
string cDisposition = $"Content-Disposition: form-data; name=\"file_{index}\"; filename=\"{file.Name}\"\r\n";
|
||||||
|
string cType = "Content-Type: application/octet-stream\r\n\r\n";
|
||||||
|
AddField(stream, bound, cDisposition, cType, File.ReadAllBytes(file.FullName));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Send webhook message
|
||||||
|
/// </summary>
|
||||||
|
public void Send(DiscordMessage message, params FileInfo[] files)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(Url))
|
||||||
|
throw new ArgumentNullException("Invalid Webhook URL.");
|
||||||
|
|
||||||
|
string bound = "------------------------" + DateTime.Now.Ticks.ToString("x");
|
||||||
|
WebClient webhookRequest = new WebClient();
|
||||||
|
webhookRequest.Headers.Add("Content-Type", "multipart/form-data; boundary=" + bound);
|
||||||
|
|
||||||
|
MemoryStream stream = new MemoryStream();
|
||||||
|
for (int i = 0; i < files.Length; i++)
|
||||||
|
SetFile(stream, bound, i, files[i]);
|
||||||
|
|
||||||
|
string json = message.ToString();
|
||||||
|
SetJsonPayload(stream, bound, json);
|
||||||
|
|
||||||
|
byte[] bodyEnd = Utils.Encode($"\r\n--{bound}--");
|
||||||
|
stream.Write(bodyEnd, 0, bodyEnd.Length);
|
||||||
|
|
||||||
|
//byte[] beginBodyBuffer = Encoding.UTF8.GetBytes("--" + bound + "\r\n");
|
||||||
|
//stream.Write(beginBodyBuffer, 0, beginBodyBuffer.Length);
|
||||||
|
//bool flag = file != null && file.Exists;
|
||||||
|
//if (flag)
|
||||||
|
//{
|
||||||
|
// string fileBody = "Content-Disposition: form-data; name=\"file\"; filename=\"" + file.Name + "\"\r\nContent-Type: application/octet-stream\r\n\r\n";
|
||||||
|
// byte[] fileBodyBuffer = Encoding.UTF8.GetBytes(fileBody);
|
||||||
|
// stream.Write(fileBodyBuffer, 0, fileBodyBuffer.Length);
|
||||||
|
// byte[] fileBuffer = File.ReadAllBytes(file.FullName);
|
||||||
|
// stream.Write(fileBuffer, 0, fileBuffer.Length);
|
||||||
|
// string fileBodyEnd = "\r\n--" + bound + "\r\n";
|
||||||
|
// byte[] fileBodyEndBuffer = Encoding.UTF8.GetBytes(fileBodyEnd);
|
||||||
|
// stream.Write(fileBodyEndBuffer, 0, fileBodyEndBuffer.Length);
|
||||||
|
//}
|
||||||
|
//string jsonBody = string.Concat(new string[]
|
||||||
|
//{
|
||||||
|
// "Content-Disposition: form-data; name=\"payload_json\"\r\nContent-Type: application/json\r\n\r\n",
|
||||||
|
// string.Format("{0}\r\n", message),
|
||||||
|
// "--",
|
||||||
|
// bound,
|
||||||
|
// "--"
|
||||||
|
//});
|
||||||
|
//byte[] jsonBodyBuffer = Encoding.UTF8.GetBytes(jsonBody);
|
||||||
|
//stream.Write(jsonBodyBuffer, 0, jsonBodyBuffer.Length);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Uri uri = new Uri(this.Url);
|
||||||
|
webhookRequest.UploadData(uri, stream.ToArray());
|
||||||
|
}
|
||||||
|
catch (WebException ex)
|
||||||
|
{
|
||||||
|
throw new WebException(Utils.Decode(ex.Response.GetResponseStream()));
|
||||||
|
}
|
||||||
|
|
||||||
|
stream.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
229
Discord/Structs.cs
Normal file
229
Discord/Structs.cs
Normal file
@@ -0,0 +1,229 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
|
namespace Discord
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Discord message data object
|
||||||
|
/// </summary>
|
||||||
|
public struct DiscordMessage
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Message content
|
||||||
|
/// </summary>
|
||||||
|
public string Content;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Read message to everyone on the channel
|
||||||
|
/// </summary>
|
||||||
|
public bool TTS;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Webhook profile username to be shown
|
||||||
|
/// </summary>
|
||||||
|
public string Username;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Webhook profile avater to be shown
|
||||||
|
/// </summary>
|
||||||
|
public string AvatarUrl;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of embeds
|
||||||
|
/// </summary>
|
||||||
|
public List<DiscordEmbed> Embeds;
|
||||||
|
|
||||||
|
public override string ToString() => Utils.StructToJson(this).ToString(Formatting.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Discord embed data object
|
||||||
|
/// </summary>
|
||||||
|
public struct DiscordEmbed
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Embed title
|
||||||
|
/// </summary>
|
||||||
|
public string Title;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Embed description
|
||||||
|
/// </summary>
|
||||||
|
public string Description;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Embed url
|
||||||
|
/// </summary>
|
||||||
|
public string Url;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Embed timestamp
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? Timestamp;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Embed color
|
||||||
|
/// </summary>
|
||||||
|
public Color? Color;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Embed footer
|
||||||
|
/// </summary>
|
||||||
|
public EmbedFooter? Footer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Embed image
|
||||||
|
/// </summary>
|
||||||
|
public EmbedMedia? Image;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Embed thumbnail
|
||||||
|
/// </summary>
|
||||||
|
public EmbedMedia? Thumbnail;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Embed video
|
||||||
|
/// </summary>
|
||||||
|
public EmbedMedia? Video;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Embed provider
|
||||||
|
/// </summary>
|
||||||
|
public EmbedProvider? Provider;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Embed author
|
||||||
|
/// </summary>
|
||||||
|
public EmbedAuthor? Author;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Embed fields list
|
||||||
|
/// </summary>
|
||||||
|
public List<EmbedField> Fields;
|
||||||
|
|
||||||
|
public override string ToString() => Utils.StructToJson(this).ToString(Formatting.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Discord embed footer data object
|
||||||
|
/// </summary>
|
||||||
|
public struct EmbedFooter
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Footer text
|
||||||
|
/// </summary>
|
||||||
|
public string Text;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Footer icon
|
||||||
|
/// </summary>
|
||||||
|
public string IconUrl;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Footer icon proxy
|
||||||
|
/// </summary>
|
||||||
|
public string ProxyIconUrl;
|
||||||
|
|
||||||
|
public override string ToString() => Utils.StructToJson(this).ToString(Formatting.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Discord embed media data object (images/thumbs/videos)
|
||||||
|
/// </summary>
|
||||||
|
public struct EmbedMedia
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Media url
|
||||||
|
/// </summary>
|
||||||
|
public string Url;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Media proxy url
|
||||||
|
/// </summary>
|
||||||
|
public string ProxyUrl;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Media height
|
||||||
|
/// </summary>
|
||||||
|
public int? Height;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Media width
|
||||||
|
/// </summary>
|
||||||
|
public int? Width;
|
||||||
|
|
||||||
|
public override string ToString() => Utils.StructToJson(this).ToString(Formatting.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Discord embed provider data object
|
||||||
|
/// </summary>
|
||||||
|
public struct EmbedProvider
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provider name
|
||||||
|
/// </summary>
|
||||||
|
public string Name;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provider url
|
||||||
|
/// </summary>
|
||||||
|
public string Url;
|
||||||
|
|
||||||
|
public override string ToString() => Utils.StructToJson(this).ToString(Formatting.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Discord embed author data object
|
||||||
|
/// </summary>
|
||||||
|
public struct EmbedAuthor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Author name
|
||||||
|
/// </summary>
|
||||||
|
public string Name;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Author url
|
||||||
|
/// </summary>
|
||||||
|
public string Url;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Author icon
|
||||||
|
/// </summary>
|
||||||
|
public string IconUrl;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Author icon proxy
|
||||||
|
/// </summary>
|
||||||
|
public string ProxyIconUrl;
|
||||||
|
|
||||||
|
public override string ToString() => Utils.StructToJson(this).ToString(Formatting.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Discord embed field data object
|
||||||
|
/// </summary>
|
||||||
|
public struct EmbedField
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Field name
|
||||||
|
/// </summary>
|
||||||
|
public string Name;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Field value
|
||||||
|
/// </summary>
|
||||||
|
public string Value;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Field align
|
||||||
|
/// </summary>
|
||||||
|
public bool InLine;
|
||||||
|
|
||||||
|
public override string ToString() => Utils.StructToJson(this).ToString(Formatting.None);
|
||||||
|
}
|
||||||
|
}
|
||||||
108
Discord/Utils.cs
Normal file
108
Discord/Utils.cs
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Discord
|
||||||
|
{
|
||||||
|
public static class Utils
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Convert Color object into hex integer
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="color">Color to be converted</param>
|
||||||
|
/// <returns>Converted hex integer</returns>
|
||||||
|
public static int ColorToHex(Color color)
|
||||||
|
{
|
||||||
|
string HS =
|
||||||
|
color.R.ToString("X2") +
|
||||||
|
color.G.ToString("X2") +
|
||||||
|
color.B.ToString("X2");
|
||||||
|
|
||||||
|
return int.Parse(HS, System.Globalization.NumberStyles.HexNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static JObject StructToJson(object @struct)
|
||||||
|
{
|
||||||
|
Type type = @struct.GetType();
|
||||||
|
JObject json = new JObject();
|
||||||
|
|
||||||
|
FieldInfo[] fields = type.GetFields();
|
||||||
|
foreach (FieldInfo field in fields)
|
||||||
|
{
|
||||||
|
string name = FieldNameToJsonName(field.Name);
|
||||||
|
object value = field.GetValue(@struct);
|
||||||
|
if (value == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (value is bool)
|
||||||
|
json.Add(name, (bool)value);
|
||||||
|
else if (value is int)
|
||||||
|
json.Add(name, (int)value);
|
||||||
|
else if (value is Color)
|
||||||
|
json.Add(name, ColorToHex((Color)value));
|
||||||
|
else if (value is string)
|
||||||
|
json.Add(name, value as string);
|
||||||
|
else if (value is DateTime)
|
||||||
|
json.Add(name, ((DateTime)value).ToString("yyyy-MM-ddTHH\\:mm\\:ss.fffffffzzz"));
|
||||||
|
else if (value is IList && value.GetType().IsGenericType)
|
||||||
|
{
|
||||||
|
JArray array = new JArray();
|
||||||
|
foreach (object obj in value as IList)
|
||||||
|
array.Add(StructToJson(obj));
|
||||||
|
json.Add(name, array);
|
||||||
|
}
|
||||||
|
else json.Add(name, StructToJson(value));
|
||||||
|
}
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
static string[] ignore = { "InLine" };
|
||||||
|
internal static string FieldNameToJsonName(string name)
|
||||||
|
{
|
||||||
|
if (ignore.ToList().Contains(name))
|
||||||
|
return name.ToLower();
|
||||||
|
|
||||||
|
List<char> result = new List<char>();
|
||||||
|
|
||||||
|
if (IsFullUpper(name))
|
||||||
|
result.AddRange(name.ToLower().ToCharArray());
|
||||||
|
else
|
||||||
|
for (int i = 0; i < name.Length; i++)
|
||||||
|
{
|
||||||
|
if (i > 0 && char.IsUpper(name[i]))
|
||||||
|
result.AddRange(new[] { '_', char.ToLower(name[i]) });
|
||||||
|
else result.Add(char.ToLower(name[i]));
|
||||||
|
}
|
||||||
|
return string.Join("", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static bool IsFullUpper(string str)
|
||||||
|
{
|
||||||
|
bool upper = true;
|
||||||
|
for (int i = 0; i < str.Length; i++)
|
||||||
|
{
|
||||||
|
if (!char.IsUpper(str[i]))
|
||||||
|
{
|
||||||
|
upper = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return upper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Decode(Stream source)
|
||||||
|
{
|
||||||
|
using (StreamReader reader = new StreamReader(source))
|
||||||
|
return reader.ReadToEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] Encode(string source, string encoding = "utf-8")
|
||||||
|
=> Encoding.GetEncoding(encoding).GetBytes(source);
|
||||||
|
}
|
||||||
|
}
|
||||||
222
DiscordSettings.Designer.cs
generated
Normal file
222
DiscordSettings.Designer.cs
generated
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
namespace RelaunchProcess
|
||||||
|
{
|
||||||
|
partial class WebhookSettings
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.btnOk = new System.Windows.Forms.Button();
|
||||||
|
this.btnCancel = new System.Windows.Forms.Button();
|
||||||
|
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.groupBoxSettingsDiscord = new System.Windows.Forms.GroupBox();
|
||||||
|
this.groupBoxSettingsDiscord.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// btnOk
|
||||||
|
//
|
||||||
|
this.btnOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.btnOk.Location = new System.Drawing.Point(236, 206);
|
||||||
|
this.btnOk.Name = "btnOk";
|
||||||
|
this.btnOk.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.btnOk.TabIndex = 0;
|
||||||
|
this.btnOk.Text = "Сохранить";
|
||||||
|
this.btnOk.UseVisualStyleBackColor = true;
|
||||||
|
this.btnOk.Click += new System.EventHandler(this.BtnOk_Click);
|
||||||
|
//
|
||||||
|
// btnCancel
|
||||||
|
//
|
||||||
|
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||||
|
this.btnCancel.Location = new System.Drawing.Point(317, 206);
|
||||||
|
this.btnCancel.Name = "btnCancel";
|
||||||
|
this.btnCancel.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.btnCancel.TabIndex = 1;
|
||||||
|
this.btnCancel.Text = "Отменить";
|
||||||
|
this.btnCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.btnCancel.Click += new System.EventHandler(this.BtnCancel_Click);
|
||||||
|
//
|
||||||
|
// lblDwhURL
|
||||||
|
//
|
||||||
|
this.lblDwhURL.AutoSize = true;
|
||||||
|
this.lblDwhURL.Location = new System.Drawing.Point(6, 103);
|
||||||
|
this.lblDwhURL.Name = "lblDwhURL";
|
||||||
|
this.lblDwhURL.Size = new System.Drawing.Size(147, 13);
|
||||||
|
this.lblDwhURL.TabIndex = 4;
|
||||||
|
this.lblDwhURL.Text = "URL-адрес Discord веб-хука";
|
||||||
|
//
|
||||||
|
// btnClearUrlField
|
||||||
|
//
|
||||||
|
this.btnClearUrlField.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.btnClearUrlField.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||||
|
this.btnClearUrlField.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
|
||||||
|
this.btnClearUrlField.Location = new System.Drawing.Point(350, 119);
|
||||||
|
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.ClearUrl);
|
||||||
|
//
|
||||||
|
// lblDwhBotname
|
||||||
|
//
|
||||||
|
this.lblDwhBotname.AutoSize = true;
|
||||||
|
this.lblDwhBotname.Location = new System.Drawing.Point(6, 25);
|
||||||
|
this.lblDwhBotname.Name = "lblDwhBotname";
|
||||||
|
this.lblDwhBotname.Size = new System.Drawing.Size(124, 13);
|
||||||
|
this.lblDwhBotname.TabIndex = 6;
|
||||||
|
this.lblDwhBotname.Text = "Имя бота в сообщении";
|
||||||
|
//
|
||||||
|
// lblDwhAvatarUrl
|
||||||
|
//
|
||||||
|
this.lblDwhAvatarUrl.AutoSize = true;
|
||||||
|
this.lblDwhAvatarUrl.Location = new System.Drawing.Point(6, 64);
|
||||||
|
this.lblDwhAvatarUrl.Name = "lblDwhAvatarUrl";
|
||||||
|
this.lblDwhAvatarUrl.Size = new System.Drawing.Size(132, 13);
|
||||||
|
this.lblDwhAvatarUrl.TabIndex = 6;
|
||||||
|
this.lblDwhAvatarUrl.Text = "URL-адрес аватара бота";
|
||||||
|
//
|
||||||
|
// textDwhAvatarUrl
|
||||||
|
//
|
||||||
|
this.textDwhAvatarUrl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.textDwhAvatarUrl.Location = new System.Drawing.Point(6, 80);
|
||||||
|
this.textDwhAvatarUrl.Name = "textDwhAvatarUrl";
|
||||||
|
this.textDwhAvatarUrl.Size = new System.Drawing.Size(338, 20);
|
||||||
|
this.textDwhAvatarUrl.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// textDwhBotName
|
||||||
|
//
|
||||||
|
this.textDwhBotName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.textDwhBotName.Location = new System.Drawing.Point(6, 41);
|
||||||
|
this.textDwhBotName.MaxLength = 40;
|
||||||
|
this.textDwhBotName.Name = "textDwhBotName";
|
||||||
|
this.textDwhBotName.Size = new System.Drawing.Size(212, 20);
|
||||||
|
this.textDwhBotName.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// textDwhURL
|
||||||
|
//
|
||||||
|
this.textDwhURL.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.textDwhURL.Location = new System.Drawing.Point(6, 119);
|
||||||
|
this.textDwhURL.Name = "textDwhURL";
|
||||||
|
this.textDwhURL.Size = new System.Drawing.Size(338, 20);
|
||||||
|
this.textDwhURL.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// chbxDiscordEnabled
|
||||||
|
//
|
||||||
|
this.chbxDiscordEnabled.AutoSize = true;
|
||||||
|
this.chbxDiscordEnabled.Location = new System.Drawing.Point(12, 173);
|
||||||
|
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;
|
||||||
|
this.chbxDiscordEnabled.CheckedChanged += new System.EventHandler(this.chbxDiscordEnabled_CheckedChanged);
|
||||||
|
//
|
||||||
|
// btnClearAvatarUrlField
|
||||||
|
//
|
||||||
|
this.btnClearAvatarUrlField.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
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(350, 81);
|
||||||
|
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);
|
||||||
|
//
|
||||||
|
// groupBoxSettingsDiscord
|
||||||
|
//
|
||||||
|
this.groupBoxSettingsDiscord.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.groupBoxSettingsDiscord.Controls.Add(this.lblDwhBotname);
|
||||||
|
this.groupBoxSettingsDiscord.Controls.Add(this.textDwhURL);
|
||||||
|
this.groupBoxSettingsDiscord.Controls.Add(this.textDwhAvatarUrl);
|
||||||
|
this.groupBoxSettingsDiscord.Controls.Add(this.lblDwhURL);
|
||||||
|
this.groupBoxSettingsDiscord.Controls.Add(this.textDwhBotName);
|
||||||
|
this.groupBoxSettingsDiscord.Controls.Add(this.btnClearUrlField);
|
||||||
|
this.groupBoxSettingsDiscord.Controls.Add(this.lblDwhAvatarUrl);
|
||||||
|
this.groupBoxSettingsDiscord.Controls.Add(this.btnClearAvatarUrlField);
|
||||||
|
this.groupBoxSettingsDiscord.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.groupBoxSettingsDiscord.Name = "groupBoxSettingsDiscord";
|
||||||
|
this.groupBoxSettingsDiscord.Size = new System.Drawing.Size(379, 155);
|
||||||
|
this.groupBoxSettingsDiscord.TabIndex = 8;
|
||||||
|
this.groupBoxSettingsDiscord.TabStop = false;
|
||||||
|
this.groupBoxSettingsDiscord.Text = "Discord";
|
||||||
|
//
|
||||||
|
// WebhookSettings
|
||||||
|
//
|
||||||
|
this.AcceptButton = this.btnOk;
|
||||||
|
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.ControlBox = false;
|
||||||
|
this.Controls.Add(this.chbxDiscordEnabled);
|
||||||
|
this.Controls.Add(this.groupBoxSettingsDiscord);
|
||||||
|
this.Controls.Add(this.btnCancel);
|
||||||
|
this.Controls.Add(this.btnOk);
|
||||||
|
this.MaximizeBox = false;
|
||||||
|
this.MinimizeBox = false;
|
||||||
|
this.MinimumSize = new System.Drawing.Size(420, 280);
|
||||||
|
this.Name = "WebhookSettings";
|
||||||
|
this.ShowIcon = false;
|
||||||
|
this.ShowInTaskbar = false;
|
||||||
|
this.Text = "Настройки webhook";
|
||||||
|
this.Load += new System.EventHandler(this.WebhookSettings_FormLoad);
|
||||||
|
this.groupBoxSettingsDiscord.ResumeLayout(false);
|
||||||
|
this.groupBoxSettingsDiscord.PerformLayout();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Button btnOk;
|
||||||
|
private System.Windows.Forms.Button btnCancel;
|
||||||
|
private System.Windows.Forms.CheckBox chbxDiscordEnabled;
|
||||||
|
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;
|
||||||
|
private System.Windows.Forms.GroupBox groupBoxSettingsDiscord;
|
||||||
|
}
|
||||||
|
}
|
||||||
88
DiscordSettings.cs
Normal file
88
DiscordSettings.cs
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
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 RelaunchProcess.Properties;
|
||||||
|
|
||||||
|
namespace RelaunchProcess
|
||||||
|
{
|
||||||
|
public partial class WebhookSettings : Form
|
||||||
|
{
|
||||||
|
public WebhookSettings()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
RestoreSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RestoreSettings()
|
||||||
|
{
|
||||||
|
textDwhBotName.Text = Settings.Default.dwhBotname;
|
||||||
|
textDwhAvatarUrl.Text = Settings.Default.dwhAvatarURL;
|
||||||
|
textDwhURL.Text = Settings.Default.dwhURL;
|
||||||
|
chbxDiscordEnabled.Checked = Settings.Default.dwhEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveSettings()
|
||||||
|
{
|
||||||
|
Settings.Default.dwhBotname = textDwhBotName.Text;
|
||||||
|
Settings.Default.dwhAvatarURL = textDwhAvatarUrl.Text;
|
||||||
|
Settings.Default.dwhURL = textDwhURL.Text;
|
||||||
|
Settings.Default.dwhEnabled = chbxDiscordEnabled.Checked;
|
||||||
|
Settings.Default.Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateUI()
|
||||||
|
{
|
||||||
|
groupBoxSettingsDiscord.Enabled = !chbxDiscordEnabled.Checked;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WebhookSettings_FormLoad(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
UpdateUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BtnCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 (String.IsNullOrEmpty(textDwhURL.Text))
|
||||||
|
{
|
||||||
|
chbxDiscordEnabled.Checked = false;
|
||||||
|
}
|
||||||
|
SaveSettings();
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Неверный формат URL.\rОчистите или исправьте.", "URL", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ClearUrl(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if ( (Button)sender == btnClearUrlField ) textDwhURL.Text = "";
|
||||||
|
if ( (Button)sender == btnClearAvatarUrlField ) textDwhAvatarUrl.Text = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void chbxDiscordEnabled_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
UpdateUI();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
120
DiscordSettings.resx
Normal file
120
DiscordSettings.resx
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
18
Form1.Designer.cs
generated
18
Form1.Designer.cs
generated
@@ -48,6 +48,7 @@ namespace Process_Auto_Relaunch
|
|||||||
this.checkBoxSaveState = new System.Windows.Forms.CheckBox();
|
this.checkBoxSaveState = new System.Windows.Forms.CheckBox();
|
||||||
this.radioButtonEnableWathing = new System.Windows.Forms.RadioButton();
|
this.radioButtonEnableWathing = new System.Windows.Forms.RadioButton();
|
||||||
this.radioButtonDisableWathing = new System.Windows.Forms.RadioButton();
|
this.radioButtonDisableWathing = new System.Windows.Forms.RadioButton();
|
||||||
|
this.btnShowDiscordSettings = new System.Windows.Forms.Button();
|
||||||
this.groupBoxStatus = new System.Windows.Forms.GroupBox();
|
this.groupBoxStatus = new System.Windows.Forms.GroupBox();
|
||||||
this.labelStatus = new System.Windows.Forms.Label();
|
this.labelStatus = new System.Windows.Forms.Label();
|
||||||
this.myBackgroundWorker = new System.ComponentModel.BackgroundWorker();
|
this.myBackgroundWorker = new System.ComponentModel.BackgroundWorker();
|
||||||
@@ -165,7 +166,7 @@ namespace Process_Auto_Relaunch
|
|||||||
this.buttonSetProgramStart.TabIndex = 1;
|
this.buttonSetProgramStart.TabIndex = 1;
|
||||||
this.buttonSetProgramStart.Text = "Обзор";
|
this.buttonSetProgramStart.Text = "Обзор";
|
||||||
this.buttonSetProgramStart.UseVisualStyleBackColor = true;
|
this.buttonSetProgramStart.UseVisualStyleBackColor = true;
|
||||||
this.buttonSetProgramStart.Click += new System.EventHandler(this.buttonSetProgramStart_Click);
|
this.buttonSetProgramStart.Click += new System.EventHandler(this.ButtonSetProgramStart_Click);
|
||||||
//
|
//
|
||||||
// groupBoxProgramStart
|
// groupBoxProgramStart
|
||||||
//
|
//
|
||||||
@@ -248,6 +249,7 @@ namespace Process_Auto_Relaunch
|
|||||||
this.groupBoxEnabled.Controls.Add(this.checkBoxSaveState);
|
this.groupBoxEnabled.Controls.Add(this.checkBoxSaveState);
|
||||||
this.groupBoxEnabled.Controls.Add(this.radioButtonEnableWathing);
|
this.groupBoxEnabled.Controls.Add(this.radioButtonEnableWathing);
|
||||||
this.groupBoxEnabled.Controls.Add(this.radioButtonDisableWathing);
|
this.groupBoxEnabled.Controls.Add(this.radioButtonDisableWathing);
|
||||||
|
this.groupBoxEnabled.Controls.Add(this.btnShowDiscordSettings);
|
||||||
this.groupBoxEnabled.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
this.groupBoxEnabled.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||||
this.groupBoxEnabled.Location = new System.Drawing.Point(13, 345);
|
this.groupBoxEnabled.Location = new System.Drawing.Point(13, 345);
|
||||||
this.groupBoxEnabled.Margin = new System.Windows.Forms.Padding(4);
|
this.groupBoxEnabled.Margin = new System.Windows.Forms.Padding(4);
|
||||||
@@ -301,6 +303,18 @@ namespace Process_Auto_Relaunch
|
|||||||
this.radioButtonDisableWathing.UseVisualStyleBackColor = true;
|
this.radioButtonDisableWathing.UseVisualStyleBackColor = true;
|
||||||
this.radioButtonDisableWathing.CheckedChanged += new System.EventHandler(this.radioButtonDisableWathing_CheckedChanged);
|
this.radioButtonDisableWathing.CheckedChanged += new System.EventHandler(this.radioButtonDisableWathing_CheckedChanged);
|
||||||
//
|
//
|
||||||
|
// btnShowDiscordSettings
|
||||||
|
//
|
||||||
|
this.btnShowDiscordSettings.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||||
|
this.btnShowDiscordSettings.Location = new System.Drawing.Point(282, 16);
|
||||||
|
this.btnShowDiscordSettings.Margin = new System.Windows.Forms.Padding(4);
|
||||||
|
this.btnShowDiscordSettings.Name = "btnShowDiscordSettings";
|
||||||
|
this.btnShowDiscordSettings.Size = new System.Drawing.Size(89, 34);
|
||||||
|
this.btnShowDiscordSettings.TabIndex = 1;
|
||||||
|
this.btnShowDiscordSettings.Text = "Webhook";
|
||||||
|
this.btnShowDiscordSettings.UseVisualStyleBackColor = true;
|
||||||
|
this.btnShowDiscordSettings.Click += new System.EventHandler(this.btnShowDiscordSettings_Click);
|
||||||
|
//
|
||||||
// groupBoxStatus
|
// groupBoxStatus
|
||||||
//
|
//
|
||||||
this.groupBoxStatus.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
this.groupBoxStatus.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
@@ -366,6 +380,7 @@ namespace Process_Auto_Relaunch
|
|||||||
this.Controls.Add(this.groupBoxProgramStart);
|
this.Controls.Add(this.groupBoxProgramStart);
|
||||||
this.Controls.Add(this.groupBoxActions);
|
this.Controls.Add(this.groupBoxActions);
|
||||||
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||||
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
this.Margin = new System.Windows.Forms.Padding(4);
|
this.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
@@ -413,5 +428,6 @@ namespace Process_Auto_Relaunch
|
|||||||
private NumericUpDown numericUpDown1;
|
private NumericUpDown numericUpDown1;
|
||||||
private GroupBox groupBoxHistory;
|
private GroupBox groupBoxHistory;
|
||||||
private RichTextBox richTextBoxHistory;
|
private RichTextBox richTextBoxHistory;
|
||||||
|
private Button btnShowDiscordSettings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
124
Form1.cs
124
Form1.cs
@@ -7,19 +7,50 @@ using System.Threading;
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using RelaunchProcess.Properties;
|
using RelaunchProcess.Properties;
|
||||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||||
|
using Discord;
|
||||||
|
using Discord.Webhook;
|
||||||
|
using System.Data;
|
||||||
|
using static System.Net.Mime.MediaTypeNames;
|
||||||
|
using RelaunchProcess;
|
||||||
|
|
||||||
|
|
||||||
namespace Process_Auto_Relaunch
|
namespace Process_Auto_Relaunch
|
||||||
{
|
{
|
||||||
public partial class Form1 : Form
|
public partial class Form1 : Form
|
||||||
{
|
{
|
||||||
private delegate void UpdateLogDelegate(string text, bool add_history = false);
|
[Flags]
|
||||||
private UpdateLogDelegate updateLogDelegate = null;
|
public enum NotifyLevel
|
||||||
|
{
|
||||||
|
logNone = 0,
|
||||||
|
logAlways = 1, // ïèñàòü âåçäå
|
||||||
|
logUpdateStatus = 2, // ïèñàòü â ñòðîêå ñîñòîÿíèÿ
|
||||||
|
logHistory = 4, // ïèñàòü â îêíå èñòîðèè ïåðåçàïóñêîâ
|
||||||
|
logDiscord = 8 // ïèñàòü â Äèñêîðä
|
||||||
|
}
|
||||||
|
private delegate void UpdateLogDelegate(string text, NotifyLevel level = NotifyLevel.logUpdateStatus);
|
||||||
|
private readonly UpdateLogDelegate updateLogDelegate;
|
||||||
|
private DiscordWebhook dwhHook;
|
||||||
|
private DiscordMessage dwhMessage;
|
||||||
|
|
||||||
public Form1()
|
public Form1()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.updateLogDelegate = new UpdateLogDelegate(this.UpdateStatus);
|
this.updateLogDelegate = this.UpdateStatus;
|
||||||
|
this.updateLogDelegate += this.SendDiscordMessage;
|
||||||
|
this.updateLogDelegate += this.HistoryLog;
|
||||||
myBackgroundWorker.WorkerSupportsCancellation = true;
|
myBackgroundWorker.WorkerSupportsCancellation = true;
|
||||||
|
dwhHook = new DiscordWebhook();
|
||||||
|
/*if ( Uri.IsWellFormedUriString(Settings.Default.dwhURL,UriKind.Absolute) && Settings.Default.dwhEnabled && Settings.Default.dwhURL!="")
|
||||||
|
{
|
||||||
|
dwhHook.Url = Settings.Default.dwhURL;
|
||||||
|
}
|
||||||
|
else if (Settings.Default.dwhEnabled) {
|
||||||
|
Debug.WriteLine($"Îøèáêà â URL âåá-õóêà ({Settings.Default.dwhURL}). Âûâîä â Discord îòêëþ÷åí.");
|
||||||
|
HistoryLog($"Îøèáêà â URL âåá-õóêà ({Settings.Default.dwhURL}). Âûâîä â Discord îòêëþ÷åí.");
|
||||||
|
Settings.Default.dwhEnabled = false;
|
||||||
|
Settings.Default.Save();
|
||||||
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -65,7 +96,7 @@ namespace Process_Auto_Relaunch
|
|||||||
if (myBackgroundWorker.WorkerSupportsCancellation && myBackgroundWorker.IsBusy)
|
if (myBackgroundWorker.WorkerSupportsCancellation && myBackgroundWorker.IsBusy)
|
||||||
{
|
{
|
||||||
myBackgroundWorker.CancelAsync();
|
myBackgroundWorker.CancelAsync();
|
||||||
UpdateStatus("Îòìåíÿåì...");
|
UpdateStatus("Îòìåíÿåì...",NotifyLevel.logUpdateStatus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,26 +143,61 @@ namespace Process_Auto_Relaunch
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Îáíîâëåíèå ñòàòóñà â ïðîãðàììå
|
/// Îáíîâëåíèå ñòàòóñà â ïðîãðàììå
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="text">Òåêñò äëÿ îòîáðàæåíèÿ</param>
|
/// <param name="text">Òåêñò äëÿ îòîáðàæåíèÿ/îòïðàâêè </param>
|
||||||
/// <param name="add_history">Ñîõðàíåíèå òåêñòà â îêíî èñòîðèè</param>
|
/// <param name="level">Ôëàãè äëÿ íàçíà÷åíèÿ îòïðàâêè</param>
|
||||||
public void UpdateStatus(string text, bool add_history = false)
|
public void UpdateStatus( string text, NotifyLevel level )
|
||||||
{
|
{
|
||||||
|
if (!level.HasFlag(NotifyLevel.logAlways) && !level.HasFlag(NotifyLevel.logUpdateStatus)) return;
|
||||||
labelStatus.Text = text;
|
labelStatus.Text = text;
|
||||||
|
|
||||||
if (add_history)
|
|
||||||
{
|
|
||||||
HistoryLog(text);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HistoryLog(string text)
|
/// <summary>
|
||||||
|
/// Äîáàâëåíèå ñòðîêè â Èñòîðèè Çàïóñêîâ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text">Òåêñò äëÿ îòîáðàæåíèÿ/îòïðàâêè </param>
|
||||||
|
/// <param name="level">Ôëàãè äëÿ íàçíà÷åíèÿ îòïðàâêè</param>
|
||||||
|
private void HistoryLog( string text, NotifyLevel level )
|
||||||
{
|
{
|
||||||
|
if (!level.HasFlag(NotifyLevel.logAlways) && !level.HasFlag(NotifyLevel.logHistory)) return;
|
||||||
richTextBoxHistory.Text += DateTime.Now.ToString() + ": " + text + "\n";
|
richTextBoxHistory.Text += DateTime.Now.ToString() + ": " + text + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Status(string text, bool add_history = false)
|
/// <summary>
|
||||||
|
/// Îòïðàâêà ñòàòóñà â Discord
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text">Òåêñò äëÿ îòîáðàæåíèÿ/îòïðàâêè </param>
|
||||||
|
/// <param name="level">Ôëàãè äëÿ íàçíà÷åíèÿ îòïðàâêè</param>
|
||||||
|
public void SendDiscordMessage( string text, NotifyLevel level )
|
||||||
{
|
{
|
||||||
Invoke(updateLogDelegate, text, add_history);
|
if (!level.HasFlag(NotifyLevel.logAlways) && !level.HasFlag(NotifyLevel.logDiscord)) return;
|
||||||
|
if (Settings.Default.dwhEnabled)
|
||||||
|
{
|
||||||
|
dwhHook.Url = Settings.Default.dwhURL;
|
||||||
|
dwhMessage.Username = Settings.Default.dwhBotname;
|
||||||
|
dwhMessage.AvatarUrl = Settings.Default.dwhAvatarURL;
|
||||||
|
dwhMessage.Content = ":arrows_counterclockwise: " + text;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
dwhHook.Send(dwhMessage);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Status($"Îøèáêà îòïðàâêè â äèñêîðä.",NotifyLevel.logHistory);
|
||||||
|
Debug.WriteLine($"Discord messaging error: {ex.Message}");
|
||||||
|
//Settings.Default.dwhEnabled = false;
|
||||||
|
//Settings.Default.Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Îáíîâëåíèå ñòàòóñà â ïðîãðàììå
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text">Òåêñò äëÿ îòîáðàæåíèÿ/îòïðàâêè </param>
|
||||||
|
/// <param name="level">Ôëàãè äëÿ íàçíà÷åíèÿ îòïðàâêè</param>
|
||||||
|
public void Status(string text, NotifyLevel level = NotifyLevel.logUpdateStatus)
|
||||||
|
{
|
||||||
|
updateLogDelegate.Invoke(text, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckProgramState()
|
private void CheckProgramState()
|
||||||
@@ -142,6 +208,7 @@ namespace Process_Auto_Relaunch
|
|||||||
groupBoxProcessName.Enabled = !watching;
|
groupBoxProcessName.Enabled = !watching;
|
||||||
groupBoxProgramStart.Enabled = !watching;
|
groupBoxProgramStart.Enabled = !watching;
|
||||||
groupBoxActions.Enabled = !watching;
|
groupBoxActions.Enabled = !watching;
|
||||||
|
btnShowDiscordSettings.Enabled = !watching; //îòêëþ÷àåì êíîïêó íàñòðîåê äèñêîðäà
|
||||||
|
|
||||||
Settings.Default.enableWatching = watching;
|
Settings.Default.enableWatching = watching;
|
||||||
|
|
||||||
@@ -153,7 +220,7 @@ namespace Process_Auto_Relaunch
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void buttonSetProgramStart_Click(object sender, EventArgs e)
|
private void ButtonSetProgramStart_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
OpenFileDialog openFile = new OpenFileDialog();
|
OpenFileDialog openFile = new OpenFileDialog();
|
||||||
openFile.Filter = "Èñïîëíÿåìûå ôàéëû (*.exe)|*.exe";
|
openFile.Filter = "Èñïîëíÿåìûå ôàéëû (*.exe)|*.exe";
|
||||||
@@ -169,7 +236,6 @@ namespace Process_Auto_Relaunch
|
|||||||
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();
|
||||||
|
|
||||||
openFile.Dispose();
|
openFile.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,7 +274,7 @@ namespace Process_Auto_Relaunch
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Status("Ïðîöåññ áûë çàïóùåí.", true);
|
Status("Ïðîöåññ áûë çàïóùåí.", NotifyLevel.logAlways);
|
||||||
Process.Start(path, args);
|
Process.Start(path, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,21 +287,23 @@ namespace Process_Auto_Relaunch
|
|||||||
{
|
{
|
||||||
if (ProcessByNameIsRuning(textBoxProcessName.Text))
|
if (ProcessByNameIsRuning(textBoxProcessName.Text))
|
||||||
{
|
{
|
||||||
Status($"Ïðîöåññ {textBoxProcessName.Text} óæå çàïóùåí");
|
Status($"Ïðîöåññ óæå çàïóùåí",NotifyLevel.logUpdateStatus);
|
||||||
|
if (i < (int)numericUpDown1.Value) SendDiscordMessage($"Ïðîöåññ {textBoxProcessName.Text} çàïóùåí.",NotifyLevel.logDiscord);
|
||||||
i = (int)numericUpDown1.Value;
|
i = (int)numericUpDown1.Value;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (radioButtonRestartTimer.Checked)
|
if (radioButtonRestartTimer.Checked)
|
||||||
{
|
{
|
||||||
|
if (i==(int)numericUpDown1.Value) Status($"Ïðîöåññ {textBoxProcessName.Text} íå íàéäåí. Çàïóñê ÷åðåç {i} ñåê",NotifyLevel.logDiscord);
|
||||||
i--;
|
i--;
|
||||||
Status($"Ïðîöåññ {textBoxProcessName.Text} íå íàéäåí. Çàïóñê ÷åðåç {i}");
|
Status($"Ïðîöåññ {textBoxProcessName.Text} íå íàéäåí. Çàïóñê ÷åðåç {i}", NotifyLevel.logUpdateStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i <= 0 || radioButtonRestartNow.Checked)
|
if (i <= 0 || radioButtonRestartNow.Checked)
|
||||||
{
|
{
|
||||||
i = (int)numericUpDown1.Value;
|
i = (int)numericUpDown1.Value;
|
||||||
Status("Çàïóñêàåì...");
|
Status($"Çàïóñêàåì {textBoxProcessName.Text}", NotifyLevel.logUpdateStatus|NotifyLevel.logDiscord);
|
||||||
ProcessStart(Settings.Default.startProgramPath, textBoxArguments.Text);
|
ProcessStart(Settings.Default.startProgramPath, textBoxArguments.Text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -253,18 +321,26 @@ namespace Process_Auto_Relaunch
|
|||||||
{
|
{
|
||||||
if (e.Cancelled)
|
if (e.Cancelled)
|
||||||
{
|
{
|
||||||
Status("Íàáëþäåíèå îòìåíåíî.");
|
Status("Íàáëþäåíèå îòìåíåíî.",NotifyLevel.logUpdateStatus|NotifyLevel.logDiscord);
|
||||||
}
|
}
|
||||||
else if (e.Error != null)
|
else if (e.Error != null)
|
||||||
{
|
{
|
||||||
|
Status("Ïðîèçîøëà îøèáêà! Íàáëþäåíèå îñòàíîâëåíî.", NotifyLevel.logUpdateStatus | NotifyLevel.logDiscord);
|
||||||
MessageBox.Show("Error: " + e.Error.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
MessageBox.Show("Error: " + e.Error.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
||||||
Status("Ïðîèçîøëà îøèáêà! Íàáëþäåíèå îñòàíîâëåíî.", true);
|
|
||||||
radioButtonDisableWathing.Checked = true;
|
radioButtonDisableWathing.Checked = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Status("Íàáëþäåíèå îñòàíîâëåíî.");
|
Status("Íàáëþäåíèå îñòàíîâëåíî.", NotifyLevel.logUpdateStatus|NotifyLevel.logDiscord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void btnShowDiscordSettings_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
WebhookSettings discordSettings;
|
||||||
|
discordSettings = new WebhookSettings();
|
||||||
|
discordSettings.ShowDialog(this);
|
||||||
|
discordSettings.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@
|
|||||||
<value>17, 17</value>
|
<value>17, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>131</value>
|
<value>40</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
|||||||
@@ -63,6 +63,13 @@
|
|||||||
<OutputPath>bin\x64\Release\</OutputPath>
|
<OutputPath>bin\x64\Release\</OutputPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="CSharpDiscordWebhook, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>.\CSharpDiscordWebhook.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
@@ -76,13 +83,26 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Discord\DiscordWebHook.cs" />
|
||||||
|
<Compile Include="Discord\Structs.cs" />
|
||||||
|
<Compile Include="Discord\Utils.cs" />
|
||||||
<Compile Include="Form1.cs">
|
<Compile Include="Form1.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Form1.Designer.cs">
|
<Compile Include="Form1.Designer.cs">
|
||||||
<DependentUpon>Form1.cs</DependentUpon>
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="DiscordSettings.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="DiscordSettings.Designer.cs">
|
||||||
|
<DependentUpon>DiscordSettings.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Settings.cs" />
|
||||||
|
<EmbeddedResource Include="DiscordSettings.resx">
|
||||||
|
<DependentUpon>DiscordSettings.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Form1.resx">
|
<EmbeddedResource Include="Form1.resx">
|
||||||
<DependentUpon>Form1.cs</DependentUpon>
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
@@ -98,6 +118,7 @@
|
|||||||
<DependentUpon>Resources.resx</DependentUpon>
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<None Include="packages.config" />
|
||||||
<None Include="Properties\Settings.settings">
|
<None Include="Properties\Settings.settings">
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
@@ -127,4 +148,8 @@
|
|||||||
</BootstrapperPackage>
|
</BootstrapperPackage>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<PreBuildEvent>rem copy $(ProjectDir)\CSharpDiscordWebhook\CSharpDiscordWebhook\$(OutDir)\* $(TargetDir)
|
||||||
|
rem copy $(ProjectDir)\CSharpDiscordWebhook\CSharpDiscordWebhook\$(OutDir)\* $(ProjectDir)</PreBuildEvent>
|
||||||
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -9,6 +9,8 @@ Global
|
|||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
Debug|x64 = Debug|x64
|
Debug|x64 = Debug|x64
|
||||||
|
DebugFULL|Any CPU = DebugFULL|Any CPU
|
||||||
|
DebugFULL|x64 = DebugFULL|x64
|
||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
Release|x64 = Release|x64
|
Release|x64 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
@@ -17,6 +19,10 @@ Global
|
|||||||
{B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.Debug|x64.ActiveCfg = Debug|x64
|
{B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.Debug|x64.Build.0 = Debug|x64
|
{B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.DebugFULL|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.DebugFULL|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.DebugFULL|x64.ActiveCfg = Debug|x64
|
||||||
|
{B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.DebugFULL|x64.Build.0 = Debug|x64
|
||||||
{B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.Release|Any CPU.Build.0 = Release|Any CPU
|
{B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.Release|x64.ActiveCfg = Release|x64
|
{B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
|||||||
51
Properties/Settings.Designer.cs
generated
51
Properties/Settings.Designer.cs
generated
@@ -12,7 +12,7 @@ namespace RelaunchProcess.Properties {
|
|||||||
|
|
||||||
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[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 {
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
|
|
||||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
@@ -118,5 +118,54 @@ namespace RelaunchProcess.Properties {
|
|||||||
this["timer"] = value;
|
this["timer"] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||||
|
public string dwhURL {
|
||||||
|
get {
|
||||||
|
return ((string)(this["dwhURL"]));
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this["dwhURL"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||||
|
public bool dwhEnabled {
|
||||||
|
get {
|
||||||
|
return ((bool)(this["dwhEnabled"]));
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,5 +26,17 @@
|
|||||||
<Setting Name="timer" Type="System.Decimal" Scope="User">
|
<Setting Name="timer" Type="System.Decimal" Scope="User">
|
||||||
<Value Profile="(Default)">30</Value>
|
<Value Profile="(Default)">30</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
|
<Setting Name="dwhURL" Type="System.String" Scope="User">
|
||||||
|
<Value Profile="(Default)" />
|
||||||
|
</Setting>
|
||||||
|
<Setting Name="dwhEnabled" Type="System.Boolean" Scope="User">
|
||||||
|
<Value Profile="(Default)">False</Value>
|
||||||
|
</Setting>
|
||||||
|
<Setting Name="dwhBotname" Type="System.String" Scope="User">
|
||||||
|
<Value Profile="(Default)">Relauncher</Value>
|
||||||
|
</Setting>
|
||||||
|
<Setting Name="dwhAvatarURL" Type="System.String" Scope="User">
|
||||||
|
<Value Profile="(Default)">https://distribution.faceit-cdn.net/images/7240adfa-6bda-43a0-abd0-8c599f176686.jpeg</Value>
|
||||||
|
</Setting>
|
||||||
</Settings>
|
</Settings>
|
||||||
</SettingsFile>
|
</SettingsFile>
|
||||||
28
Settings.cs
Normal file
28
Settings.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
namespace RelaunchProcess.Properties {
|
||||||
|
|
||||||
|
|
||||||
|
// Этот класс позволяет обрабатывать определенные события в классе параметров:
|
||||||
|
// Событие SettingChanging возникает перед изменением значения параметра.
|
||||||
|
// Событие PropertyChanged возникает после изменения значения параметра.
|
||||||
|
// Событие SettingsLoaded возникает после загрузки значений параметров.
|
||||||
|
// Событие SettingsSaving возникает перед сохранением значений параметров.
|
||||||
|
internal sealed partial class Settings {
|
||||||
|
|
||||||
|
public Settings() {
|
||||||
|
// // Для добавления обработчиков событий для сохранения и изменения параметров раскомментируйте приведенные ниже строки:
|
||||||
|
//
|
||||||
|
// this.SettingChanging += this.SettingChangingEventHandler;
|
||||||
|
//
|
||||||
|
// this.SettingsSaving += this.SettingsSavingEventHandler;
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
|
||||||
|
// Добавьте здесь код для обработки события SettingChangingEvent.
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
|
||||||
|
// Добавьте здесь код для обработки события SettingsSaving.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
4
packages.config
Normal file
4
packages.config
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
|
||||||
|
</packages>
|
||||||
Reference in New Issue
Block a user