diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/EnvForm.Designer.cs b/WelsonJS.Toolkit/WelsonJS.Launcher/EnvForm.Designer.cs index af380e1..02ed05d 100644 --- a/WelsonJS.Toolkit/WelsonJS.Launcher/EnvForm.Designer.cs +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/EnvForm.Designer.cs @@ -28,6 +28,7 @@ /// private void InitializeComponent() { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EnvForm)); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.listView1 = new System.Windows.Forms.ListView(); this.groupBox2 = new System.Windows.Forms.GroupBox(); @@ -39,6 +40,8 @@ this.textSetName = new System.Windows.Forms.TextBox(); this.labelSetValue = new System.Windows.Forms.Label(); this.labelSetName = new System.Windows.Forms.Label(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.SuspendLayout(); @@ -55,12 +58,16 @@ // // listView1 // + this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1, + this.columnHeader2}); this.listView1.HideSelection = false; this.listView1.Location = new System.Drawing.Point(16, 26); this.listView1.Name = "listView1"; this.listView1.Size = new System.Drawing.Size(386, 285); this.listView1.TabIndex = 0; this.listView1.UseCompatibleStateImageBehavior = false; + this.listView1.SelectedIndexChanged += new System.EventHandler(this.ListView1_SelectedIndexChanged); // // groupBox2 // @@ -91,30 +98,39 @@ // // btnOk // + this.btnOk.Image = global::WelsonJS.Launcher.Properties.Resources.icon_check_32; this.btnOk.Location = new System.Drawing.Point(303, 123); this.btnOk.Name = "btnOk"; this.btnOk.Size = new System.Drawing.Size(86, 86); this.btnOk.TabIndex = 6; this.btnOk.Text = "Ok"; + this.btnOk.TextAlign = System.Drawing.ContentAlignment.BottomCenter; this.btnOk.UseVisualStyleBackColor = true; + this.btnOk.Click += new System.EventHandler(this.btnOk_Click); // // btnOpenFile // + this.btnOpenFile.Image = global::WelsonJS.Launcher.Properties.Resources.icon_file_32; + this.btnOpenFile.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.btnOpenFile.Location = new System.Drawing.Point(31, 169); this.btnOpenFile.Name = "btnOpenFile"; this.btnOpenFile.Size = new System.Drawing.Size(201, 40); this.btnOpenFile.TabIndex = 5; this.btnOpenFile.Text = "Open the file..."; this.btnOpenFile.UseVisualStyleBackColor = true; + this.btnOpenFile.Click += new System.EventHandler(this.btnOpenFile_Click); // // btnOpenDirectory // + this.btnOpenDirectory.Image = ((System.Drawing.Image)(resources.GetObject("btnOpenDirectory.Image"))); + this.btnOpenDirectory.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.btnOpenDirectory.Location = new System.Drawing.Point(31, 123); this.btnOpenDirectory.Name = "btnOpenDirectory"; this.btnOpenDirectory.Size = new System.Drawing.Size(201, 40); this.btnOpenDirectory.TabIndex = 4; this.btnOpenDirectory.Text = "Open the directory..."; this.btnOpenDirectory.UseVisualStyleBackColor = true; + this.btnOpenDirectory.Click += new System.EventHandler(this.btnOpenDirectory_Click); // // textSetValue // @@ -148,6 +164,14 @@ this.labelSetName.TabIndex = 0; this.labelSetName.Text = "Set name:"; // + // columnHeader1 + // + this.columnHeader1.Text = "Name"; + // + // columnHeader2 + // + this.columnHeader2.Text = "Value"; + // // EnvForm // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); @@ -180,5 +204,7 @@ private System.Windows.Forms.Button btnOpenDirectory; private System.Windows.Forms.CheckBox checkDeleteVariable; private System.Windows.Forms.ListView listView1; + private System.Windows.Forms.ColumnHeader columnHeader1; + private System.Windows.Forms.ColumnHeader columnHeader2; } } \ No newline at end of file diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/EnvForm.cs b/WelsonJS.Toolkit/WelsonJS.Launcher/EnvForm.cs index c2dad04..6953796 100644 --- a/WelsonJS.Toolkit/WelsonJS.Launcher/EnvForm.cs +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/EnvForm.cs @@ -1,20 +1,175 @@ using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using System.Windows.Forms; namespace WelsonJS.Launcher { public partial class EnvForm : Form { + private Dictionary userVariables = new Dictionary(); + private string tempFilePath; + public EnvForm() { InitializeComponent(); + InitializeListView(); + // Set the variable file path in the temporary folder + tempFilePath = Path.Combine(Path.GetTempPath(), "WelsonJS.UserVariables.txt"); + LoadUserVariables(); // Load variables + } + + // Initialize ListView + private void InitializeListView() + { + listView1.View = View.Details; + listView1.FullRowSelect = true; + listView1.Columns[0].Width = 150; + listView1.Columns[1].Width = 220; + listView1.SelectedIndexChanged += ListView1_SelectedIndexChanged; + } + + // Load user-defined variables from the temporary folder (text format) + private void LoadUserVariables() + { + if (File.Exists(tempFilePath)) + { + try + { + string fileContent = File.ReadAllText(tempFilePath); + string[] keyValuePairs = fileContent.Split(new[] { " --" }, StringSplitOptions.RemoveEmptyEntries); + + userVariables = new Dictionary(); + + foreach (string pair in keyValuePairs) + { + string[] keyValue = pair.Split(new[] { '=' }, 2); + if (keyValue.Length == 2) + { + string key = keyValue[0].TrimStart('-'); + string value = keyValue[1]; + userVariables[key] = value; + } + } + } + catch (Exception ex) + { + MessageBox.Show($"Error loading variable file: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + userVariables = new Dictionary(); + } + } + else + { + userVariables = new Dictionary(); + } + UpdateListView(); + } + + // Update ListView with current variables + private void UpdateListView() + { + listView1.Items.Clear(); + foreach (var variable in userVariables) + { + var item = new ListViewItem(variable.Key); + item.SubItems.Add(variable.Value); + listView1.Items.Add(item); + } + } + + // Handle ListView selection change + private void ListView1_SelectedIndexChanged(object sender, EventArgs e) + { + if (listView1.SelectedItems.Count > 0) + { + var selectedItem = listView1.SelectedItems[0]; + textSetName.Text = selectedItem.Text; + textSetValue.Text = selectedItem.SubItems[1].Text; + checkDeleteVariable.Checked = false; + } + } + + // Handle OK button click + private void btnOk_Click(object sender, EventArgs e) + { + var name = textSetName.Text.Trim(); + var value = textSetValue.Text.Trim(); + + if (string.IsNullOrEmpty(name)) + { + MessageBox.Show("Please enter a variable name.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + if (checkDeleteVariable.Checked) + { + if (userVariables.ContainsKey(name)) + { + userVariables.Remove(name); + MessageBox.Show("Variable deleted.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + else + { + MessageBox.Show("Variable not found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + else + { + userVariables[name] = value; + MessageBox.Show("Variable saved.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + + UpdateListView(); + SaveUserVariables(); // Save variables + ClearInputFields(); + } + + // Save user-defined variables to the temporary folder (text format) + private void SaveUserVariables() + { + try + { + List keyValuePairs = new List(); + foreach (var variable in userVariables) + { + keyValuePairs.Add($"--{variable.Key}={variable.Value}"); + } + + string content = string.Join(" ", keyValuePairs); + File.WriteAllText(tempFilePath, content); + } + catch (Exception ex) + { + MessageBox.Show($"Error saving variable file: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + // Clear input fields + private void ClearInputFields() + { + textSetName.Clear(); + textSetValue.Clear(); + checkDeleteVariable.Checked = false; + } + + // Handle "Open Directory" button click + private void btnOpenDirectory_Click(object sender, EventArgs e) + { + var folderDialog = new FolderBrowserDialog(); + if (folderDialog.ShowDialog() == DialogResult.OK) + { + textSetValue.Text = folderDialog.SelectedPath; + } + } + + // Handle "Open File" button click + private void btnOpenFile_Click(object sender, EventArgs e) + { + var fileDialog = new OpenFileDialog(); + if (fileDialog.ShowDialog() == DialogResult.OK) + { + textSetValue.Text = fileDialog.FileName; + } } } -} +} \ No newline at end of file diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/EnvForm.resx b/WelsonJS.Toolkit/WelsonJS.Launcher/EnvForm.resx index 1af7de1..e933e3e 100644 --- a/WelsonJS.Toolkit/WelsonJS.Launcher/EnvForm.resx +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/EnvForm.resx @@ -117,4 +117,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAB9SURBVFhH7Y7BCYBADATzEkkT1mNF9mQPQvSwA1vxHTnJ + SwJ3GNSHO7Cvu+wOAZBR4VVn1urk/xs1dh7HHSlFeLDzOO5AKcK7Tm1nFTHcgbqMVhHDKa6PcG8193GL + n0+y+c8E1OYhAAEIQAACEIAABE6BdH18IYvNg19DdABs4v1eWM0+nQAAAABJRU5ErkJggg== + + \ No newline at end of file diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/Properties/Resources.Designer.cs b/WelsonJS.Toolkit/WelsonJS.Launcher/Properties/Resources.Designer.cs index 6c9fbed..ccc6d0a 100644 --- a/WelsonJS.Toolkit/WelsonJS.Launcher/Properties/Resources.Designer.cs +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/Properties/Resources.Designer.cs @@ -70,6 +70,36 @@ namespace WelsonJS.Launcher.Properties { } } + /// + /// System.Drawing.Bitmap 형식의 지역화된 리소스를 찾습니다. + /// + internal static System.Drawing.Bitmap icon_check_32 { + get { + object obj = ResourceManager.GetObject("icon_check_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// System.Drawing.Bitmap 형식의 지역화된 리소스를 찾습니다. + /// + internal static System.Drawing.Bitmap icon_directory_32 { + get { + object obj = ResourceManager.GetObject("icon_directory_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// System.Drawing.Bitmap 형식의 지역화된 리소스를 찾습니다. + /// + internal static System.Drawing.Bitmap icon_file_32 { + get { + object obj = ResourceManager.GetObject("icon_file_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// System.Drawing.Bitmap 형식의 지역화된 리소스를 찾습니다. /// diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/Properties/Resources.resx b/WelsonJS.Toolkit/WelsonJS.Launcher/Properties/Resources.resx index 80ed962..dd7b44a 100644 --- a/WelsonJS.Toolkit/WelsonJS.Launcher/Properties/Resources.resx +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/Properties/Resources.resx @@ -127,4 +127,13 @@ ..\Resources\favicon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icon_directory_32.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\icon_file_32.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\icon_check_32.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/Resources/icon_check_32.png b/WelsonJS.Toolkit/WelsonJS.Launcher/Resources/icon_check_32.png new file mode 100644 index 0000000..b110dbe Binary files /dev/null and b/WelsonJS.Toolkit/WelsonJS.Launcher/Resources/icon_check_32.png differ diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/Resources/icon_delete_32.png b/WelsonJS.Toolkit/WelsonJS.Launcher/Resources/icon_delete_32.png new file mode 100644 index 0000000..0b348db Binary files /dev/null and b/WelsonJS.Toolkit/WelsonJS.Launcher/Resources/icon_delete_32.png differ diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/Resources/icon_directory_32.png b/WelsonJS.Toolkit/WelsonJS.Launcher/Resources/icon_directory_32.png new file mode 100644 index 0000000..21c069e Binary files /dev/null and b/WelsonJS.Toolkit/WelsonJS.Launcher/Resources/icon_directory_32.png differ diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/Resources/icon_file_32.png b/WelsonJS.Toolkit/WelsonJS.Launcher/Resources/icon_file_32.png new file mode 100644 index 0000000..68fa8f9 Binary files /dev/null and b/WelsonJS.Toolkit/WelsonJS.Launcher/Resources/icon_file_32.png differ diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/WelsonJS.Launcher.csproj b/WelsonJS.Toolkit/WelsonJS.Launcher/WelsonJS.Launcher.csproj index 0af6858..3ea35dd 100644 --- a/WelsonJS.Toolkit/WelsonJS.Launcher/WelsonJS.Launcher.csproj +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/WelsonJS.Launcher.csproj @@ -92,20 +92,20 @@ ResXFileCodeGenerator - Resources.Designer.cs Designer + Resources.Designer.cs - - True - Resources.resx - True - SettingsSingleFileGenerator Settings.Designer.cs + + True + True + Resources.resx + True Settings.settings