From 54ded842242b17d9220bf1ae0bb3826f017ec183 Mon Sep 17 00:00:00 2001 From: slothdpal <16717792+SlothDpal@users.noreply.github.com> Date: Tue, 21 May 2024 21:31:26 +0300 Subject: [PATCH] DiscordWebHook as updateLogDelegate Add: dwhURL dwhEnabled settings New: status messages --- App.config | 20 ++---- DiscordSettings.Designer.cs | 121 ++++++++++++++++++++++++++++++++ DiscordSettings.cs | 51 ++++++++++++++ DiscordSettings.resx | 120 +++++++++++++++++++++++++++++++ Form1.Designer.cs | 16 +++++ Form1.cs | 68 +++++++++++++++--- Form1.resx | 2 +- Process Auto Relaunch.csproj | 10 +++ Process Auto Relaunch.sln | 34 +-------- Properties/Settings.Designer.cs | 24 +++++++ Properties/Settings.settings | 6 ++ Settings.cs | 28 ++++++++ 12 files changed, 443 insertions(+), 57 deletions(-) create mode 100644 DiscordSettings.Designer.cs create mode 100644 DiscordSettings.cs create mode 100644 DiscordSettings.resx create mode 100644 Settings.cs diff --git a/App.config b/App.config index 18f8bfa..49cf587 100644 --- a/App.config +++ b/App.config @@ -32,21 +32,13 @@ 30 + + + + + False + - - - - - - - - - True - - - True - - diff --git a/DiscordSettings.Designer.cs b/DiscordSettings.Designer.cs new file mode 100644 index 0000000..c90946a --- /dev/null +++ b/DiscordSettings.Designer.cs @@ -0,0 +1,121 @@ +namespace RelaunchProcess +{ + partial class DiscordSettings + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + 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.SuspendLayout(); + // + // btnOk + // + this.btnOk.Location = new System.Drawing.Point(193, 89); + 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.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(274, 89); + 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); + // + // chbxDiscordEnabled + // + this.chbxDiscordEnabled.AutoSize = true; + this.chbxDiscordEnabled.Checked = true; + this.chbxDiscordEnabled.CheckState = System.Windows.Forms.CheckState.Checked; + 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.Location = new System.Drawing.Point(12, 37); + this.textDwhURL.Name = "textDwhURL"; + this.textDwhURL.Size = new System.Drawing.Size(337, 20); + this.textDwhURL.TabIndex = 3; + // + // lblDwhURL + // + this.lblDwhURL.AutoSize = true; + this.lblDwhURL.Location = new System.Drawing.Point(9, 9); + this.lblDwhURL.Name = "lblDwhURL"; + this.lblDwhURL.Size = new System.Drawing.Size(147, 13); + this.lblDwhURL.TabIndex = 4; + this.lblDwhURL.Text = "URL-адрес Discord веб-хука"; + // + // DiscordSettings + // + 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(361, 128); + this.ControlBox = false; + this.Controls.Add(this.lblDwhURL); + this.Controls.Add(this.textDwhURL); + this.Controls.Add(this.chbxDiscordEnabled); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnOk); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "DiscordSettings"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.Text = "Настройки Discord webhook"; + this.Load += new System.EventHandler(this.DiscordSettings_Load); + 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; + } +} \ No newline at end of file diff --git a/DiscordSettings.cs b/DiscordSettings.cs new file mode 100644 index 0000000..9fffdd3 --- /dev/null +++ b/DiscordSettings.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Diagnostics; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using RelaunchProcess.Properties; + +namespace RelaunchProcess +{ + public partial class DiscordSettings : Form + { + public DiscordSettings() + { + InitializeComponent(); + } + + private void DiscordSettings_Load(object sender, EventArgs e) + { + chbxDiscordEnabled.Checked=Settings.Default.dwhEnabled; + textDwhURL.Text=Settings.Default.dwhURL; + } + + private void btnCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void btnOk_Click(object sender, EventArgs e) + { + if (Uri.IsWellFormedUriString(textDwhURL.Text, UriKind.Absolute)) + { + Settings.Default.dwhEnabled = chbxDiscordEnabled.Checked; + Settings.Default.dwhURL = textDwhURL.Text; + Settings.Default.Save(); + DialogResult = DialogResult.OK; + Close(); + } + else + { + //TODO обработать ситуацию с неверным УРЛом + } + + + } + } +} diff --git a/DiscordSettings.resx b/DiscordSettings.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/DiscordSettings.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Form1.Designer.cs b/Form1.Designer.cs index b71d12f..ef18e8f 100644 --- a/Form1.Designer.cs +++ b/Form1.Designer.cs @@ -53,6 +53,7 @@ namespace Process_Auto_Relaunch this.myBackgroundWorker = new System.ComponentModel.BackgroundWorker(); this.groupBoxHistory = new System.Windows.Forms.GroupBox(); this.richTextBoxHistory = new System.Windows.Forms.RichTextBox(); + this.btnShowDiscordSettings = new System.Windows.Forms.Button(); this.groupBoxActions.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); this.groupBoxProgramStart.SuspendLayout(); @@ -248,6 +249,7 @@ namespace Process_Auto_Relaunch this.groupBoxEnabled.Controls.Add(this.checkBoxSaveState); this.groupBoxEnabled.Controls.Add(this.radioButtonEnableWathing); 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.Location = new System.Drawing.Point(13, 345); this.groupBoxEnabled.Margin = new System.Windows.Forms.Padding(4); @@ -354,6 +356,18 @@ namespace Process_Auto_Relaunch this.richTextBoxHistory.TabIndex = 0; this.richTextBoxHistory.Text = ""; // + // 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 = "Discord"; + this.btnShowDiscordSettings.UseVisualStyleBackColor = true; + this.btnShowDiscordSettings.Click += new System.EventHandler(this.btnShowDiscordSettings_Click); + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); @@ -366,6 +380,7 @@ namespace Process_Auto_Relaunch this.Controls.Add(this.groupBoxProgramStart); 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.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Margin = new System.Windows.Forms.Padding(4); this.MaximizeBox = false; @@ -413,5 +428,6 @@ namespace Process_Auto_Relaunch private NumericUpDown numericUpDown1; private GroupBox groupBoxHistory; private RichTextBox richTextBoxHistory; + private Button btnShowDiscordSettings; } } diff --git a/Form1.cs b/Form1.cs index 51f6b67..6cba5b8 100644 --- a/Form1.cs +++ b/Form1.cs @@ -9,23 +9,38 @@ using RelaunchProcess.Properties; 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 { public partial class Form1 : Form { private delegate void UpdateLogDelegate(string text, bool add_history = false); - private UpdateLogDelegate updateLogDelegate = null; - private DiscordWebhook DWHook; - private DiscordMessage DMessage; + private UpdateLogDelegate updateLogDelegate; + private DiscordWebhook dwhHook; + private DiscordMessage dwhMessage; + private DiscordSettings discordSettings; public Form1() { InitializeComponent(); - this.updateLogDelegate = new UpdateLogDelegate(this.UpdateStatus); + this.updateLogDelegate = this.UpdateStatus; + this.updateLogDelegate += this.SendDiscordMessage; myBackgroundWorker.WorkerSupportsCancellation = true; - DWHook = new DiscordWebhook(); - DWHook.Url = "https://discord.com/api/webhooks/1241061556213776405/alNwHEtwe20MvBxFTSDWPKDarPCJpD-0oDUgdcT_5YrLqoybJq7oxNOCOqqmynuVD93p"; + 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(); + } } @@ -125,10 +140,6 @@ namespace Process_Auto_Relaunch { labelStatus.Text = text; - DMessage = new DiscordMessage(); - DMessage.Content = text; - DWHook.Send(DMessage); - if (add_history) { HistoryLog(text); @@ -153,6 +164,7 @@ namespace Process_Auto_Relaunch groupBoxProcessName.Enabled = !watching; groupBoxProgramStart.Enabled = !watching; groupBoxActions.Enabled = !watching; + btnShowDiscordSettings.Enabled = !watching; Settings.Default.enableWatching = watching; @@ -233,12 +245,14 @@ namespace Process_Auto_Relaunch if (ProcessByNameIsRuning(textBoxProcessName.Text)) { Status($" {textBoxProcessName.Text} "); + if (i < (int)numericUpDown1.Value) SendDiscordMessage($" {textBoxProcessName.Text} .",true); i = (int)numericUpDown1.Value; } else { if (radioButtonRestartTimer.Checked) { + if (i==(int)numericUpDown1.Value) SendDiscordMessage($" {textBoxProcessName.Text} . {i}",true); i--; Status($" {textBoxProcessName.Text} . {i}"); } @@ -247,6 +261,7 @@ namespace Process_Auto_Relaunch { i = (int)numericUpDown1.Value; Status("..."); + SendDiscordMessage($" {textBoxProcessName.Text}",true); ProcessStart(Settings.Default.startProgramPath, textBoxArguments.Text); } } @@ -277,5 +292,38 @@ namespace Process_Auto_Relaunch Status(" ."); } } + + /// + /// + /// + /// + public void SendDiscordMessage(string message, bool addToHistory = false) + { + if (Settings.Default.dwhEnabled && addToHistory) + { + dwhHook.Url = Settings.Default.dwhURL; + dwhMessage.Username = "Relaunch process"; + dwhMessage.Content = ":arrows_counterclockwise: " + message; + try + { + dwhHook.Send(dwhMessage); + } + catch (Exception ex) + { + HistoryLog($"Discord messaging error: {ex.Message}"); + Debug.WriteLine($"Discord messaging error: {ex.Message}"); + Settings.Default.dwhEnabled = false; + Settings.Default.Save(); + } + } + + } + + private void btnShowDiscordSettings_Click(object sender, EventArgs e) + { + discordSettings = new DiscordSettings(); + discordSettings.ShowDialog(this); + discordSettings.Dispose(); + } } } diff --git a/Form1.resx b/Form1.resx index a2e57f8..50c97e1 100644 --- a/Form1.resx +++ b/Form1.resx @@ -121,7 +121,7 @@ 17, 17 - 131 + 40 diff --git a/Process Auto Relaunch.csproj b/Process Auto Relaunch.csproj index 0295b27..e265fbb 100644 --- a/Process Auto Relaunch.csproj +++ b/Process Auto Relaunch.csproj @@ -86,7 +86,17 @@ Form1.cs + + Form + + + DiscordSettings.cs + + + + DiscordSettings.cs + Form1.cs Designer diff --git a/Process Auto Relaunch.sln b/Process Auto Relaunch.sln index 0c368e4..7188f0d 100644 --- a/Process Auto Relaunch.sln +++ b/Process Auto Relaunch.sln @@ -14,12 +14,6 @@ Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 - DebugDN|Any CPU = DebugDN|Any CPU - DebugDN|x64 = DebugDN|x64 - DebugDNF|Any CPU = DebugDNF|Any CPU - DebugDNF|x64 = DebugDNF|x64 - DebugDotNetFramework|Any CPU = DebugDotNetFramework|Any CPU - DebugDotNetFramework|x64 = DebugDotNetFramework|x64 DebugFULL|Any CPU = DebugFULL|Any CPU DebugFULL|x64 = DebugFULL|x64 Release|Any CPU = Release|Any CPU @@ -30,18 +24,6 @@ Global {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.Build.0 = Debug|x64 - {B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.DebugDN|Any CPU.ActiveCfg = Debug|Any CPU - {B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.DebugDN|Any CPU.Build.0 = Debug|Any CPU - {B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.DebugDN|x64.ActiveCfg = Debug|x64 - {B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.DebugDN|x64.Build.0 = Debug|x64 - {B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.DebugDNF|Any CPU.ActiveCfg = Debug|Any CPU - {B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.DebugDNF|Any CPU.Build.0 = Debug|Any CPU - {B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.DebugDNF|x64.ActiveCfg = Debug|x64 - {B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.DebugDNF|x64.Build.0 = Debug|x64 - {B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.DebugDotNetFramework|Any CPU.ActiveCfg = Debug|Any CPU - {B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.DebugDotNetFramework|Any CPU.Build.0 = Debug|Any CPU - {B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.DebugDotNetFramework|x64.ActiveCfg = Debug|x64 - {B48F106C-F4E2-4BFB-9BAA-42FC13C03FDD}.DebugDotNetFramework|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 @@ -54,20 +36,8 @@ Global {11C71B78-004A-471F-B29D-C2CBE4673579}.Debug|Any CPU.Build.0 = Debug|Any CPU {11C71B78-004A-471F-B29D-C2CBE4673579}.Debug|x64.ActiveCfg = Debug|Any CPU {11C71B78-004A-471F-B29D-C2CBE4673579}.Debug|x64.Build.0 = Debug|Any CPU - {11C71B78-004A-471F-B29D-C2CBE4673579}.DebugDN|Any CPU.ActiveCfg = DebugDN|Any CPU - {11C71B78-004A-471F-B29D-C2CBE4673579}.DebugDN|Any CPU.Build.0 = DebugDN|Any CPU - {11C71B78-004A-471F-B29D-C2CBE4673579}.DebugDN|x64.ActiveCfg = DebugDN|Any CPU - {11C71B78-004A-471F-B29D-C2CBE4673579}.DebugDN|x64.Build.0 = DebugDN|Any CPU - {11C71B78-004A-471F-B29D-C2CBE4673579}.DebugDNF|Any CPU.ActiveCfg = DebugDNF|Any CPU - {11C71B78-004A-471F-B29D-C2CBE4673579}.DebugDNF|Any CPU.Build.0 = DebugDNF|Any CPU - {11C71B78-004A-471F-B29D-C2CBE4673579}.DebugDNF|x64.ActiveCfg = DebugDNF|Any CPU - {11C71B78-004A-471F-B29D-C2CBE4673579}.DebugDNF|x64.Build.0 = DebugDNF|Any CPU - {11C71B78-004A-471F-B29D-C2CBE4673579}.DebugDotNetFramework|Any CPU.ActiveCfg = DebugDotNetFramework|Any CPU - {11C71B78-004A-471F-B29D-C2CBE4673579}.DebugDotNetFramework|Any CPU.Build.0 = DebugDotNetFramework|Any CPU - {11C71B78-004A-471F-B29D-C2CBE4673579}.DebugDotNetFramework|x64.ActiveCfg = DebugDotNetFramework|Any CPU - {11C71B78-004A-471F-B29D-C2CBE4673579}.DebugDotNetFramework|x64.Build.0 = DebugDotNetFramework|Any CPU - {11C71B78-004A-471F-B29D-C2CBE4673579}.DebugFULL|Any CPU.ActiveCfg = DebugFULL|Any CPU - {11C71B78-004A-471F-B29D-C2CBE4673579}.DebugFULL|Any CPU.Build.0 = DebugFULL|Any CPU + {11C71B78-004A-471F-B29D-C2CBE4673579}.DebugFULL|Any CPU.ActiveCfg = Debug|Any CPU + {11C71B78-004A-471F-B29D-C2CBE4673579}.DebugFULL|Any CPU.Build.0 = Debug|Any CPU {11C71B78-004A-471F-B29D-C2CBE4673579}.DebugFULL|x64.ActiveCfg = DebugFULL|Any CPU {11C71B78-004A-471F-B29D-C2CBE4673579}.DebugFULL|x64.Build.0 = DebugFULL|Any CPU {11C71B78-004A-471F-B29D-C2CBE4673579}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs index c388999..9c4d1e1 100644 --- a/Properties/Settings.Designer.cs +++ b/Properties/Settings.Designer.cs @@ -118,5 +118,29 @@ namespace RelaunchProcess.Properties { 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; + } + } } } diff --git a/Properties/Settings.settings b/Properties/Settings.settings index ad9cd31..3f8eb41 100644 --- a/Properties/Settings.settings +++ b/Properties/Settings.settings @@ -26,5 +26,11 @@ 30 + + + + + False + \ No newline at end of file diff --git a/Settings.cs b/Settings.cs new file mode 100644 index 0000000..9ba1259 --- /dev/null +++ b/Settings.cs @@ -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. + } + } +}