From a6cb8a386aa5824d7a1877bef88290df816caa8d Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Wed, 7 Jun 2023 19:44:37 +0200 Subject: [PATCH] NumericPrompt - Hide ValueUpDown control and added setter for min and max --- .../NumericPrompt.Designer.cs | 114 +++++++++--------- .../Forms/Additional-Popups/NumericPrompt.cs | 19 ++- .../Additional-Popups/NumericPrompt.resx | 36 +++--- PCK-Studio/MainForm.cs | 6 +- 4 files changed, 93 insertions(+), 82 deletions(-) diff --git a/PCK-Studio/Forms/Additional-Popups/NumericPrompt.Designer.cs b/PCK-Studio/Forms/Additional-Popups/NumericPrompt.Designer.cs index e25dee84..7bead21f 100644 --- a/PCK-Studio/Forms/Additional-Popups/NumericPrompt.Designer.cs +++ b/PCK-Studio/Forms/Additional-Popups/NumericPrompt.Designer.cs @@ -28,61 +28,61 @@ /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NumericPrompt)); - this.TextLabel = new System.Windows.Forms.Label(); - this.OKButton = new System.Windows.Forms.Button(); - this.ContextLabel = new MetroFramework.Controls.MetroLabel(); - this.ValueUpDown = new System.Windows.Forms.NumericUpDown(); - ((System.ComponentModel.ISupportInitialize)(this.ValueUpDown)).BeginInit(); - this.SuspendLayout(); - // - // TextLabel - // - resources.ApplyResources(this.TextLabel, "TextLabel"); - this.TextLabel.ForeColor = System.Drawing.Color.White; - this.TextLabel.Name = "TextLabel"; - // - // OKButton - // - resources.ApplyResources(this.OKButton, "OKButton"); - this.OKButton.ForeColor = System.Drawing.Color.White; - this.OKButton.Name = "OKButton"; - this.OKButton.UseVisualStyleBackColor = true; - this.OKButton.Click += new System.EventHandler(this.OKBtn_Click); - // - // contextLabel - // - resources.ApplyResources(this.ContextLabel, "contextLabel"); - this.ContextLabel.FontSize = MetroFramework.MetroLabelSize.Small; - this.ContextLabel.Name = "contextLabel"; - this.ContextLabel.Theme = MetroFramework.MetroThemeStyle.Dark; - this.ContextLabel.WrapToLine = true; - // - // valueUpDown - // - resources.ApplyResources(this.ValueUpDown, "valueUpDown"); - this.ValueUpDown.Name = "valueUpDown"; - // - // NumericPrompt - // - this.AcceptButton = this.OKButton; - resources.ApplyResources(this, "$this"); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.ValueUpDown); - this.Controls.Add(this.ContextLabel); - this.Controls.Add(this.OKButton); - this.Controls.Add(this.TextLabel); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "NumericPrompt"; - this.Resizable = false; - this.ShadowType = MetroFramework.Forms.MetroFormShadowType.DropShadow; - this.Style = MetroFramework.MetroColorStyle.Silver; - this.Theme = MetroFramework.MetroThemeStyle.Dark; - this.Load += new System.EventHandler(this.RenamePrompt_Load); - ((System.ComponentModel.ISupportInitialize)(this.ValueUpDown)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NumericPrompt)); + this.TextLabel = new System.Windows.Forms.Label(); + this.OKButton = new System.Windows.Forms.Button(); + this.ContextLabel = new MetroFramework.Controls.MetroLabel(); + this.ValueUpDown = new System.Windows.Forms.NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)(this.ValueUpDown)).BeginInit(); + this.SuspendLayout(); + // + // TextLabel + // + resources.ApplyResources(this.TextLabel, "TextLabel"); + this.TextLabel.ForeColor = System.Drawing.Color.White; + this.TextLabel.Name = "TextLabel"; + // + // OKButton + // + resources.ApplyResources(this.OKButton, "OKButton"); + this.OKButton.ForeColor = System.Drawing.Color.White; + this.OKButton.Name = "OKButton"; + this.OKButton.UseVisualStyleBackColor = true; + this.OKButton.Click += new System.EventHandler(this.OKBtn_Click); + // + // ContextLabel + // + resources.ApplyResources(this.ContextLabel, "ContextLabel"); + this.ContextLabel.FontSize = MetroFramework.MetroLabelSize.Small; + this.ContextLabel.Name = "ContextLabel"; + this.ContextLabel.Theme = MetroFramework.MetroThemeStyle.Dark; + this.ContextLabel.WrapToLine = true; + // + // ValueUpDown + // + resources.ApplyResources(this.ValueUpDown, "ValueUpDown"); + this.ValueUpDown.Name = "ValueUpDown"; + // + // NumericPrompt + // + this.AcceptButton = this.OKButton; + resources.ApplyResources(this, "$this"); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.ValueUpDown); + this.Controls.Add(this.ContextLabel); + this.Controls.Add(this.OKButton); + this.Controls.Add(this.TextLabel); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "NumericPrompt"; + this.Resizable = false; + this.ShadowType = MetroFramework.Forms.MetroFormShadowType.DropShadow; + this.Style = MetroFramework.MetroColorStyle.Silver; + this.Theme = MetroFramework.MetroThemeStyle.Dark; + this.Load += new System.EventHandler(this.RenamePrompt_Load); + ((System.ComponentModel.ISupportInitialize)(this.ValueUpDown)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); } @@ -90,6 +90,6 @@ public System.Windows.Forms.Button OKButton; public System.Windows.Forms.Label TextLabel; public MetroFramework.Controls.MetroLabel ContextLabel; - public System.Windows.Forms.NumericUpDown ValueUpDown; - } + private System.Windows.Forms.NumericUpDown ValueUpDown; + } } \ No newline at end of file diff --git a/PCK-Studio/Forms/Additional-Popups/NumericPrompt.cs b/PCK-Studio/Forms/Additional-Popups/NumericPrompt.cs index 3d600bea..60711c9f 100644 --- a/PCK-Studio/Forms/Additional-Popups/NumericPrompt.cs +++ b/PCK-Studio/Forms/Additional-Popups/NumericPrompt.cs @@ -9,12 +9,23 @@ namespace PckStudio /// /// Text entered only access when DialogResult == DialogResult.OK /// - public int NewValue => (int)ValueUpDown.Value; + public int SelectedValue => (int)ValueUpDown.Value; - public NumericPrompt(int InitialValue) + public int Minimum { set => ValueUpDown.Minimum = value; } + public int Maximum { set => ValueUpDown.Maximum = value; } + + public NumericPrompt(int initialValue) + : this(initialValue, 0, 100) + { + + } + + public NumericPrompt(int initialValue, int minimum, int maximum) { InitializeComponent(); - ValueUpDown.Value = InitialValue; + ValueUpDown.Value = initialValue; + Minimum = minimum; + Maximum = maximum; } private void OKBtn_Click(object sender, EventArgs e) { @@ -23,7 +34,7 @@ namespace PckStudio private void RenamePrompt_Load(object sender, EventArgs e) { - if(String.IsNullOrEmpty(ContextLabel.Text)) + if(string.IsNullOrEmpty(ContextLabel.Text)) { ContextLabel.Visible = false; Size = new System.Drawing.Size(264, 85); diff --git a/PCK-Studio/Forms/Additional-Popups/NumericPrompt.resx b/PCK-Studio/Forms/Additional-Popups/NumericPrompt.resx index f1926f18..5ba1a329 100644 --- a/PCK-Studio/Forms/Additional-Popups/NumericPrompt.resx +++ b/PCK-Studio/Forms/Additional-Popups/NumericPrompt.resx @@ -186,52 +186,52 @@ 2 - + Top - + 28, 39 - + 208, 39 - + 6 - + TopCenter - - contextLabel + + ContextLabel - + MetroFramework.Controls.MetroLabel, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a - + $this - + 1 - + 71, 88 - + 164, 20 - + 7 - - valueUpDown + + ValueUpDown - + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - + 0 diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index acc391ec..708b7e38 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -1949,15 +1949,15 @@ namespace PckStudio if (textureExtension == ".tga") return; using NumericPrompt numericPrompt = new NumericPrompt(0); - numericPrompt.ValueUpDown.Minimum = 1; - numericPrompt.ValueUpDown.Maximum = 4; // 5 is the presumed max MipMap level + numericPrompt.Minimum = 1; + numericPrompt.Maximum = 4; // 5 is the presumed max MipMap level numericPrompt.ContextLabel.Text = "You can enter the amount of MipMap levels that you would like to generate. " + "For example: if you enter 2, MipMapLevel1.png and MipMapLevel2.png will be generated"; numericPrompt.TextLabel.Text = "Levels"; if (numericPrompt.ShowDialog(this) == DialogResult.OK) { - for (int i = 2; i < 2 + numericPrompt.NewValue; i++) + for (int i = 2; i < 2 + numericPrompt.SelectedValue; i++) { string mippedPath = $"{textureDirectory}/{textureName}MipMapLevel{i}{textureExtension}"; Debug.WriteLine(mippedPath);