Changed return type of AddProperty to KeyValuePair

This commit is contained in:
miku-666
2023-05-25 14:20:15 +02:00
parent e2ff47684c
commit be69240fea
4 changed files with 91 additions and 83 deletions

View File

@@ -29,61 +29,63 @@
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AddPropertyPrompt));
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
System.Windows.Forms.Label label1;
System.Windows.Forms.Label label2;
this.keyTextBox = new System.Windows.Forms.TextBox();
this.valueTextBox = new System.Windows.Forms.TextBox();
this.saveButton = new System.Windows.Forms.Button();
label1 = new System.Windows.Forms.Label();
label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// textBox1
// keyTextBox
//
this.textBox1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(13)))), ((int)(((byte)(13)))), ((int)(((byte)(13)))));
this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox1.ForeColor = System.Drawing.SystemColors.Window;
resources.ApplyResources(this.textBox1, "textBox1");
this.textBox1.Name = "textBox1";
this.keyTextBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(13)))), ((int)(((byte)(13)))), ((int)(((byte)(13)))));
this.keyTextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.keyTextBox.ForeColor = System.Drawing.SystemColors.Window;
resources.ApplyResources(this.keyTextBox, "keyTextBox");
this.keyTextBox.Name = "keyTextBox";
//
// textBox2
// valueTextBox
//
this.textBox2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(13)))), ((int)(((byte)(13)))), ((int)(((byte)(13)))));
this.textBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox2.ForeColor = System.Drawing.SystemColors.Window;
resources.ApplyResources(this.textBox2, "textBox2");
this.textBox2.Name = "textBox2";
this.valueTextBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(13)))), ((int)(((byte)(13)))), ((int)(((byte)(13)))));
this.valueTextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.valueTextBox.ForeColor = System.Drawing.SystemColors.Window;
resources.ApplyResources(this.valueTextBox, "valueTextBox");
this.valueTextBox.Name = "valueTextBox";
//
// label1
//
resources.ApplyResources(this.label1, "label1");
this.label1.ForeColor = System.Drawing.Color.White;
this.label1.Name = "label1";
resources.ApplyResources(label1, "label1");
label1.ForeColor = System.Drawing.Color.White;
label1.Name = "label1";
//
// label2
//
resources.ApplyResources(this.label2, "label2");
this.label2.ForeColor = System.Drawing.Color.White;
this.label2.Name = "label2";
resources.ApplyResources(label2, "label2");
label2.ForeColor = System.Drawing.Color.White;
label2.Name = "label2";
//
// button1
// saveButton
//
resources.ApplyResources(this.button1, "button1");
this.button1.ForeColor = System.Drawing.Color.White;
this.button1.Name = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
resources.ApplyResources(this.saveButton, "saveButton");
this.saveButton.ForeColor = System.Drawing.Color.White;
this.saveButton.Name = "saveButton";
this.saveButton.UseVisualStyleBackColor = true;
this.saveButton.Click += new System.EventHandler(this.saveButton_Click);
//
// addMeta
// AddPropertyPrompt
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.button1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.saveButton);
this.Controls.Add(label2);
this.Controls.Add(label1);
this.Controls.Add(this.valueTextBox);
this.Controls.Add(this.keyTextBox);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "addMeta";
this.Name = "AddPropertyPrompt";
this.Resizable = false;
this.ShadowType = MetroFramework.Forms.MetroFormShadowType.DropShadow;
this.Style = MetroFramework.MetroColorStyle.Black;
@@ -95,10 +97,8 @@
#endregion
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox keyTextBox;
private System.Windows.Forms.TextBox valueTextBox;
private System.Windows.Forms.Button saveButton;
}
}

View File

@@ -1,18 +1,24 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace PckStudio.Forms.Additional_Popups
{
public partial class AddPropertyPrompt : MetroFramework.Forms.MetroForm
{
public string PropertyName => textBox1.Text;
public string PropertyValue => textBox2.Text;
public KeyValuePair<string, string> Property => new KeyValuePair<string, string>(keyTextBox.Text, valueTextBox.Text);
public AddPropertyPrompt(KeyValuePair<string, string> property)
: this(property.Key, property.Value)
{
}
public AddPropertyPrompt(string name, string value)
{
InitializeComponent();
textBox1.Text = name;
textBox2.Text = value;
keyTextBox.Text = name;
valueTextBox.Text = value;
}
public AddPropertyPrompt()
@@ -20,10 +26,9 @@ namespace PckStudio.Forms.Additional_Popups
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
private void saveButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
Close();
}
}
}

View File

@@ -118,49 +118,52 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="textBox1.Location" type="System.Drawing.Point, System.Drawing">
<data name="keyTextBox.Location" type="System.Drawing.Point, System.Drawing">
<value>60, 25</value>
</data>
<data name="textBox1.Size" type="System.Drawing.Size, System.Drawing">
<data name="keyTextBox.Size" type="System.Drawing.Size, System.Drawing">
<value>193, 20</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="textBox1.TabIndex" type="System.Int32, mscorlib">
<data name="keyTextBox.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="&gt;&gt;textBox1.Name" xml:space="preserve">
<value>textBox1</value>
<data name="&gt;&gt;keyTextBox.Name" xml:space="preserve">
<value>keyTextBox</value>
</data>
<data name="&gt;&gt;textBox1.Type" xml:space="preserve">
<data name="&gt;&gt;keyTextBox.Type" xml:space="preserve">
<value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;textBox1.Parent" xml:space="preserve">
<data name="&gt;&gt;keyTextBox.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;textBox1.ZOrder" xml:space="preserve">
<data name="&gt;&gt;keyTextBox.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<data name="textBox2.Location" type="System.Drawing.Point, System.Drawing">
<data name="valueTextBox.Location" type="System.Drawing.Point, System.Drawing">
<value>60, 52</value>
</data>
<data name="textBox2.Size" type="System.Drawing.Size, System.Drawing">
<data name="valueTextBox.Size" type="System.Drawing.Size, System.Drawing">
<value>193, 20</value>
</data>
<data name="textBox2.TabIndex" type="System.Int32, mscorlib">
<data name="valueTextBox.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="&gt;&gt;textBox2.Name" xml:space="preserve">
<value>textBox2</value>
<data name="&gt;&gt;valueTextBox.Name" xml:space="preserve">
<value>valueTextBox</value>
</data>
<data name="&gt;&gt;textBox2.Type" xml:space="preserve">
<data name="&gt;&gt;valueTextBox.Type" xml:space="preserve">
<value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;textBox2.Parent" xml:space="preserve">
<data name="&gt;&gt;valueTextBox.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;textBox2.ZOrder" xml:space="preserve">
<data name="&gt;&gt;valueTextBox.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<metadata name="label1.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<data name="label1.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
@@ -188,6 +191,9 @@
<data name="&gt;&gt;label1.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<metadata name="label2.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<data name="label2.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
@@ -216,31 +222,31 @@
<value>1</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="button1.FlatStyle" type="System.Windows.Forms.FlatStyle, System.Windows.Forms">
<data name="saveButton.FlatStyle" type="System.Windows.Forms.FlatStyle, System.Windows.Forms">
<value>Flat</value>
</data>
<data name="button1.Location" type="System.Drawing.Point, System.Drawing">
<data name="saveButton.Location" type="System.Drawing.Point, System.Drawing">
<value>96, 78</value>
</data>
<data name="button1.Size" type="System.Drawing.Size, System.Drawing">
<data name="saveButton.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
</data>
<data name="button1.TabIndex" type="System.Int32, mscorlib">
<data name="saveButton.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="button1.Text" xml:space="preserve">
<data name="saveButton.Text" xml:space="preserve">
<value>Save</value>
</data>
<data name="&gt;&gt;button1.Name" xml:space="preserve">
<value>button1</value>
<data name="&gt;&gt;saveButton.Name" xml:space="preserve">
<value>saveButton</value>
</data>
<data name="&gt;&gt;button1.Type" xml:space="preserve">
<data name="&gt;&gt;saveButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;button1.Parent" xml:space="preserve">
<data name="&gt;&gt;saveButton.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;button1.ZOrder" xml:space="preserve">
<data name="&gt;&gt;saveButton.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
@@ -2472,9 +2478,6 @@
vbLH9tge22N7bI/tsT22x/bYHttjC+3/B71iqRn22EDpAAAAAElFTkSuQmCC
</value>
</data>
<data name="$this.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="$this.MinimumSize" type="System.Drawing.Size, System.Drawing">
<value>264, 105</value>
</data>
@@ -2482,7 +2485,7 @@
<value>CenterParent</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>addMeta</value>
<value>AddPropertyPrompt</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>MetroFramework.Forms.MetroForm, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a</value>

View File

@@ -1037,11 +1037,11 @@ namespace PckStudio
}
using (AddPropertyPrompt addDialog = new AddPropertyPrompt(property.Key, property.Value))
using (AddPropertyPrompt addProperty = new AddPropertyPrompt(property))
{
if (addDialog.ShowDialog() == DialogResult.OK)
if (addProperty.ShowDialog() == DialogResult.OK)
{
file.Properties[i] = new KeyValuePair<string, string>(addDialog.PropertyName, addDialog.PropertyValue);
file.Properties[i] = addProperty.Property;
if (IsSubPCKNode(treeViewMain.SelectedNode.FullPath))
RebuildSubPCK(treeViewMain.SelectedNode);
ReloadMetaTreeView();
@@ -1124,10 +1124,10 @@ namespace PckStudio
if (treeViewMain.SelectedNode is TreeNode t &&
t.Tag is PckFile.FileData file)
{
using AddPropertyPrompt add = new AddPropertyPrompt();
if (add.ShowDialog() == DialogResult.OK)
using AddPropertyPrompt addProperty = new AddPropertyPrompt();
if (addProperty.ShowDialog() == DialogResult.OK)
{
file.Properties.Add((add.PropertyName, add.PropertyValue));
file.Properties.Add(addProperty.Property);
if (IsSubPCKNode(treeViewMain.SelectedNode.FullPath)) RebuildSubPCK(treeViewMain.SelectedNode);
ReloadMetaTreeView();
wasModified = true;