mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-05-22 01:06:35 +00:00
GRF/AddParameter - Add auto complete to param promt and remove combobox option
This commit is contained in:
@@ -77,9 +77,6 @@
|
||||
<setting name="AutoUpdate" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="UseComboBoxForGRFParameter" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
</PckStudio.Properties.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
this.ValueTextBox = new MetroFramework.Controls.MetroTextBox();
|
||||
this.CancelBtn = new MetroFramework.Controls.MetroButton();
|
||||
this.ConfirmBtn = new MetroFramework.Controls.MetroButton();
|
||||
this.availableComboBox = new MetroFramework.Controls.MetroComboBox();
|
||||
metroLabel1 = new MetroFramework.Controls.MetroLabel();
|
||||
metroLabel2 = new MetroFramework.Controls.MetroLabel();
|
||||
this.SuspendLayout();
|
||||
@@ -46,7 +45,7 @@
|
||||
metroLabel1.Location = new System.Drawing.Point(18, 27);
|
||||
metroLabel1.Name = "metroLabel1";
|
||||
metroLabel1.Size = new System.Drawing.Size(48, 19);
|
||||
metroLabel1.TabIndex = 0;
|
||||
metroLabel1.TabIndex = 4;
|
||||
metroLabel1.Text = "Name:";
|
||||
metroLabel1.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
//
|
||||
@@ -56,12 +55,14 @@
|
||||
metroLabel2.Location = new System.Drawing.Point(17, 56);
|
||||
metroLabel2.Name = "metroLabel2";
|
||||
metroLabel2.Size = new System.Drawing.Size(42, 19);
|
||||
metroLabel2.TabIndex = 1;
|
||||
metroLabel2.TabIndex = 5;
|
||||
metroLabel2.Text = "Value:";
|
||||
metroLabel2.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
//
|
||||
// NameTextBox
|
||||
//
|
||||
this.NameTextBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
|
||||
this.NameTextBox.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource;
|
||||
//
|
||||
//
|
||||
//
|
||||
@@ -86,7 +87,7 @@
|
||||
this.NameTextBox.ShortcutsEnabled = true;
|
||||
this.NameTextBox.Size = new System.Drawing.Size(165, 23);
|
||||
this.NameTextBox.Style = MetroFramework.MetroColorStyle.White;
|
||||
this.NameTextBox.TabIndex = 2;
|
||||
this.NameTextBox.TabIndex = 0;
|
||||
this.NameTextBox.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.NameTextBox.UseSelectable = true;
|
||||
this.NameTextBox.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||
@@ -117,8 +118,7 @@
|
||||
this.ValueTextBox.SelectionStart = 0;
|
||||
this.ValueTextBox.ShortcutsEnabled = true;
|
||||
this.ValueTextBox.Size = new System.Drawing.Size(165, 23);
|
||||
this.ValueTextBox.Style = MetroFramework.MetroColorStyle.White;
|
||||
this.ValueTextBox.TabIndex = 3;
|
||||
this.ValueTextBox.TabIndex = 1;
|
||||
this.ValueTextBox.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.ValueTextBox.UseSelectable = true;
|
||||
this.ValueTextBox.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||
@@ -131,7 +131,7 @@
|
||||
this.CancelBtn.Name = "CancelBtn";
|
||||
this.CancelBtn.Size = new System.Drawing.Size(95, 23);
|
||||
this.CancelBtn.Style = MetroFramework.MetroColorStyle.White;
|
||||
this.CancelBtn.TabIndex = 4;
|
||||
this.CancelBtn.TabIndex = 2;
|
||||
this.CancelBtn.Text = "Cancel";
|
||||
this.CancelBtn.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.CancelBtn.UseSelectable = true;
|
||||
@@ -142,33 +142,18 @@
|
||||
this.ConfirmBtn.Name = "ConfirmBtn";
|
||||
this.ConfirmBtn.Size = new System.Drawing.Size(96, 23);
|
||||
this.ConfirmBtn.Style = MetroFramework.MetroColorStyle.White;
|
||||
this.ConfirmBtn.TabIndex = 5;
|
||||
this.ConfirmBtn.TabIndex = 3;
|
||||
this.ConfirmBtn.Text = "Confirm";
|
||||
this.ConfirmBtn.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.ConfirmBtn.UseSelectable = true;
|
||||
this.ConfirmBtn.Click += new System.EventHandler(this.ConfirmButton_Click);
|
||||
//
|
||||
// availableComboBox
|
||||
//
|
||||
this.availableComboBox.FormattingEnabled = true;
|
||||
this.availableComboBox.ItemHeight = 23;
|
||||
this.availableComboBox.Location = new System.Drawing.Point(72, 21);
|
||||
this.availableComboBox.Name = "availableComboBox";
|
||||
this.availableComboBox.Size = new System.Drawing.Size(165, 29);
|
||||
this.availableComboBox.Style = MetroFramework.MetroColorStyle.Silver;
|
||||
this.availableComboBox.TabIndex = 6;
|
||||
this.availableComboBox.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.availableComboBox.UseSelectable = true;
|
||||
this.availableComboBox.Visible = false;
|
||||
this.availableComboBox.SelectedIndexChanged += new System.EventHandler(this.availableComboBox_SelectedIndexChanged);
|
||||
//
|
||||
// AddParameter
|
||||
//
|
||||
this.AcceptButton = this.ConfirmBtn;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(264, 126);
|
||||
this.Controls.Add(this.availableComboBox);
|
||||
this.Controls.Add(this.ConfirmBtn);
|
||||
this.Controls.Add(this.CancelBtn);
|
||||
this.Controls.Add(this.ValueTextBox);
|
||||
@@ -192,6 +177,5 @@
|
||||
private MetroFramework.Controls.MetroButton CancelBtn;
|
||||
private MetroFramework.Controls.MetroButton ConfirmBtn;
|
||||
private MetroFramework.Controls.MetroTextBox NameTextBox;
|
||||
private MetroFramework.Controls.MetroComboBox availableComboBox;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using OMI.Formats.GameRule;
|
||||
using PckStudio.Properties;
|
||||
|
||||
namespace PckStudio.Forms.Additional_Popups.Grf
|
||||
{
|
||||
@@ -10,25 +9,12 @@ namespace PckStudio.Forms.Additional_Popups.Grf
|
||||
public string ParameterName => NameTextBox.Text;
|
||||
public string ParameterValue => ValueTextBox.Text;
|
||||
|
||||
private bool _useComboBox
|
||||
{
|
||||
get
|
||||
{
|
||||
return availableComboBox.Visible && !NameTextBox.Visible;
|
||||
}
|
||||
set
|
||||
{
|
||||
NameTextBox.Visible = !value;
|
||||
availableComboBox.Visible = value;
|
||||
}
|
||||
}
|
||||
|
||||
public AddParameter()
|
||||
{
|
||||
InitializeComponent();
|
||||
availableComboBox.Items.Clear();
|
||||
availableComboBox.Items.AddRange(GameRuleFile.GameRule.ValidParameters);
|
||||
_useComboBox = Settings.Default.UseComboBoxForGRFParameter;
|
||||
NameTextBox.AutoCompleteCustomSource = new AutoCompleteStringCollection();
|
||||
NameTextBox.AutoCompleteCustomSource.AddRange(GameRuleFile.GameRule.ValidParameters);
|
||||
}
|
||||
|
||||
public AddParameter(string parameterName, string parameterValue, bool isKeyReadonly = true) : this()
|
||||
@@ -36,23 +22,16 @@ namespace PckStudio.Forms.Additional_Popups.Grf
|
||||
NameTextBox.Text = parameterName;
|
||||
ValueTextBox.Text = parameterValue;
|
||||
NameTextBox.Enabled = isKeyReadonly;
|
||||
availableComboBox.Enabled = isKeyReadonly;
|
||||
availableComboBox.SelectedItem = parameterName;
|
||||
}
|
||||
|
||||
private void ConfirmButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(ParameterName) || string.IsNullOrWhiteSpace(ParameterValue))
|
||||
{
|
||||
MessageBox.Show(this, "Name and Value need valid values");
|
||||
MessageBox.Show(this, "Name or value can't be empty.", "Empty value", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
|
||||
return;
|
||||
}
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
private void availableComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
NameTextBox.Text = availableComboBox.SelectedItem.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ namespace PckStudio.Forms
|
||||
["AutoUpdate"] = "Auto Update",
|
||||
["LoadSubPcks"] = "Load Sub Pcks",
|
||||
["UsePrerelease"] = "Use Prerelease",
|
||||
["UseComboBoxForGRFParameter"] = "Easy Grf Param",
|
||||
};
|
||||
|
||||
private void CheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
|
||||
14
PCK-Studio/Properties/Settings.Designer.cs
generated
14
PCK-Studio/Properties/Settings.Designer.cs
generated
@@ -12,7 +12,7 @@ namespace PckStudio.Properties {
|
||||
|
||||
|
||||
[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 {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
@@ -104,18 +104,6 @@ namespace PckStudio.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
public bool UseComboBoxForGRFParameter {
|
||||
get {
|
||||
return ((bool)(this["UseComboBoxForGRFParameter"]));
|
||||
}
|
||||
set {
|
||||
this["UseComboBoxForGRFParameter"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
public global::System.Collections.Specialized.StringCollection RecentFiles {
|
||||
|
||||
@@ -23,9 +23,6 @@
|
||||
<Setting Name="AutoUpdate" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="UseComboBoxForGRFParameter" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="RecentFiles" Type="System.Collections.Specialized.StringCollection" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
|
||||
Reference in New Issue
Block a user