From e942f0b9e803b534d627bf1344a0b0ffb4a5999a Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Wed, 26 Feb 2025 22:01:57 +0900 Subject: [PATCH] Add the global settings form --- .../GlobalSettingsForm.Designer.cs | 89 +++++++++++++ .../WelsonJS.Launcher/GlobalSettingsForm.cs | 49 +++++++ .../WelsonJS.Launcher/GlobalSettingsForm.resx | 120 ++++++++++++++++++ .../WelsonJS.Launcher/MainForm.Designer.cs | 12 +- .../WelsonJS.Launcher/MainForm.cs | 5 + .../WelsonJS.Launcher.csproj | 9 ++ 6 files changed, 283 insertions(+), 1 deletion(-) create mode 100644 WelsonJS.Toolkit/WelsonJS.Launcher/GlobalSettingsForm.Designer.cs create mode 100644 WelsonJS.Toolkit/WelsonJS.Launcher/GlobalSettingsForm.cs create mode 100644 WelsonJS.Toolkit/WelsonJS.Launcher/GlobalSettingsForm.resx diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/GlobalSettingsForm.Designer.cs b/WelsonJS.Toolkit/WelsonJS.Launcher/GlobalSettingsForm.Designer.cs new file mode 100644 index 0000000..80a5d39 --- /dev/null +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/GlobalSettingsForm.Designer.cs @@ -0,0 +1,89 @@ +namespace WelsonJS.Launcher +{ + partial class GlobalSettingsForm + { + /// + /// 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.groupBox1 = new System.Windows.Forms.GroupBox(); + this.button1 = new System.Windows.Forms.Button(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.groupBox1.SuspendLayout(); + this.SuspendLayout(); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.button1); + this.groupBox1.Controls.Add(this.textBox1); + this.groupBox1.Location = new System.Drawing.Point(12, 12); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(290, 67); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "MaxScriptStatements (GUI only)"; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(218, 30); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(57, 21); + this.button1.TabIndex = 1; + this.button1.Text = "Ok"; + this.button1.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(15, 30); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(197, 21); + this.textBox1.TabIndex = 1; + // + // GlobalSettingsForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(315, 92); + this.Controls.Add(this.groupBox1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Icon = global::WelsonJS.Launcher.Properties.Resources.favicon; + this.MaximizeBox = false; + this.Name = "GlobalSettingsForm"; + this.Text = "Global settings..."; + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.Button button1; + } +} \ No newline at end of file diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/GlobalSettingsForm.cs b/WelsonJS.Toolkit/WelsonJS.Launcher/GlobalSettingsForm.cs new file mode 100644 index 0000000..2c493a5 --- /dev/null +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/GlobalSettingsForm.cs @@ -0,0 +1,49 @@ +using Microsoft.Win32; +using System; +using System.Windows.Forms; + +namespace WelsonJS.Launcher +{ + public partial class GlobalSettingsForm : Form + { + private const string RegistryPath = "Software\\Microsoft\\Internet Explorer\\Styles"; + private const string RegistryKey = "MaxScriptStatements"; + + public GlobalSettingsForm() + { + InitializeComponent(); + LoadRegistryValue(); + } + + private void LoadRegistryValue() + { + using (RegistryKey key = Registry.CurrentUser.OpenSubKey(RegistryPath)) + { + if (key != null) + { + object value = key.GetValue(RegistryKey); + if (value != null && value is int maxStatements) + { + textBox1.Text = maxStatements.ToString(); + } + } + } + } + + private void button1_Click(object sender, EventArgs e) + { + if (uint.TryParse(textBox1.Text, out uint maxStatements)) + { + using (RegistryKey key = Registry.CurrentUser.CreateSubKey(RegistryPath)) + { + key.SetValue(RegistryKey, (int)maxStatements, RegistryValueKind.DWord); + } + MessageBox.Show($"MaxScriptStatements setting has been changed to {maxStatements}.", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + else + { + MessageBox.Show("Please enter a valid number within the DWORD range.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/GlobalSettingsForm.resx b/WelsonJS.Toolkit/WelsonJS.Launcher/GlobalSettingsForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/GlobalSettingsForm.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/WelsonJS.Toolkit/WelsonJS.Launcher/MainForm.Designer.cs b/WelsonJS.Toolkit/WelsonJS.Launcher/MainForm.Designer.cs index 536fc42..b3ffa77 100644 --- a/WelsonJS.Toolkit/WelsonJS.Launcher/MainForm.Designer.cs +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/MainForm.Designer.cs @@ -40,6 +40,7 @@ this.userdefinedVariablesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.instancesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.runAsAdministratorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.globalSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // @@ -131,7 +132,8 @@ this.settingsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.userdefinedVariablesToolStripMenuItem, this.instancesToolStripMenuItem, - this.runAsAdministratorToolStripMenuItem}); + this.runAsAdministratorToolStripMenuItem, + this.globalSettingsToolStripMenuItem}); this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem"; this.settingsToolStripMenuItem.Size = new System.Drawing.Size(62, 20); this.settingsToolStripMenuItem.Text = "Settings"; @@ -157,6 +159,13 @@ this.runAsAdministratorToolStripMenuItem.Text = "Run as Administrator..."; this.runAsAdministratorToolStripMenuItem.Click += new System.EventHandler(this.runAsAdministratorToolStripMenuItem_Click); // + // globalSettingsToolStripMenuItem + // + this.globalSettingsToolStripMenuItem.Name = "globalSettingsToolStripMenuItem"; + this.globalSettingsToolStripMenuItem.Size = new System.Drawing.Size(196, 22); + this.globalSettingsToolStripMenuItem.Text = "Global settings..."; + this.globalSettingsToolStripMenuItem.Click += new System.EventHandler(this.globalSettingsToolStripMenuItem_Click); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); @@ -197,6 +206,7 @@ private System.Windows.Forms.ToolStripMenuItem userdefinedVariablesToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem instancesToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem runAsAdministratorToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem globalSettingsToolStripMenuItem; } } diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/MainForm.cs b/WelsonJS.Toolkit/WelsonJS.Launcher/MainForm.cs index 9a937fa..1624c13 100644 --- a/WelsonJS.Toolkit/WelsonJS.Launcher/MainForm.cs +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/MainForm.cs @@ -205,5 +205,10 @@ namespace WelsonJS.Launcher MessageBox.Show("Already running as Administrator."); } } + + private void globalSettingsToolStripMenuItem_Click(object sender, EventArgs e) + { + (new GlobalSettingsForm()).Show(); + } } } diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/WelsonJS.Launcher.csproj b/WelsonJS.Toolkit/WelsonJS.Launcher/WelsonJS.Launcher.csproj index 58cc6c6..69fc774 100644 --- a/WelsonJS.Toolkit/WelsonJS.Launcher/WelsonJS.Launcher.csproj +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/WelsonJS.Launcher.csproj @@ -90,6 +90,12 @@ + + Form + + + GlobalSettingsForm.cs + EnvForm.cs @@ -104,6 +110,9 @@ Designer Resources.Designer.cs + + GlobalSettingsForm.cs +