roketto-launch/Forms/EditGroupForm.cs
2026-05-15 22:34:10 +01:00

242 lines
9.5 KiB
C#

using System;
using System.Windows.Forms;
using RokettoLaunch.DTOs.SaveFile;
using RokettoLaunch.Windows.Forms;
using RyzStudio.Windows.Forms;
using RyzStudio.Windows.ThemedForms.ButtonTextBox;
using RyzStudio.Windows.ThemedForms.PickerBox;
namespace RokettoLaunch.Forms
{
public class EditGroupForm : Form
{
private Label label2;
private Label label1;
private ThYesNoPickerBox pickerBox1;
private ThClearableTextBox textBox1;
private RyzStudio.Windows.ThemedForms.Composite.DialogFooter dialogFooter1;
private THorizontalSeparator horizontalSeparator1;
private RyzStudio.Windows.ThemedForms.ThNumericBox numericBox1;
private Label label4;
private RyzStudio.Windows.ThemedForms.ThNumericBox numericBox2;
private Label label3;
private App4Options.Group result = null;
public EditGroupForm(App4Options.Group model = null)
{
InitializeComponent();
UISetup.Dialog(this, true);
this.Text = (result == null) ? "Add Group" : "Edit Group";
result = model;
pickerBox1.Setup([ "No", "Yes" ], 0);
numericBox1.Minimum = TileLayoutPanel.MIN_COLUMNS;
numericBox1.Maximum = 32;
numericBox2.Minimum = 1;
numericBox2.Maximum = 32;
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
textBox1.Text = result?.Title?.Trim() ?? "New Group";
pickerBox1.Value = result?.IsOpen ?? true;
numericBox1.Value = Math.Max(TileLayoutPanel.MIN_COLUMNS, result?.GridSize.Width ?? TileLayoutPanel.MIN_COLUMNS);
numericBox2.Value = Math.Max(1, result?.GridSize.Height ?? 1);
}
private void InitializeComponent()
{
textBox1 = new ThClearableTextBox();
label2 = new Label();
label1 = new Label();
pickerBox1 = new ThYesNoPickerBox();
dialogFooter1 = new RyzStudio.Windows.ThemedForms.Composite.DialogFooter();
horizontalSeparator1 = new THorizontalSeparator();
numericBox1 = new RyzStudio.Windows.ThemedForms.ThNumericBox();
label4 = new Label();
numericBox2 = new RyzStudio.Windows.ThemedForms.ThNumericBox();
label3 = new Label();
SuspendLayout();
//
// textBox1
//
textBox1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
textBox1.BackColor = System.Drawing.Color.Transparent;
textBox1.ClearedValue = "";
textBox1.EnableMovable = false;
textBox1.Icon = "O";
textBox1.IconSize = 13F;
textBox1.Location = new System.Drawing.Point(115, 20);
textBox1.Name = "textBox1";
textBox1.Size = new System.Drawing.Size(260, 32);
textBox1.TabIndex = 152;
textBox1.TabStop = false;
textBox1.UseSystemPasswordChar = false;
//
// label2
//
label2.AutoSize = true;
label2.BackColor = System.Drawing.Color.Transparent;
label2.ForeColor = System.Drawing.SystemColors.ControlText;
label2.Location = new System.Drawing.Point(10, 62);
label2.Margin = new Padding(0);
label2.Name = "label2";
label2.Padding = new Padding(0, 9, 0, 0);
label2.Size = new System.Drawing.Size(91, 24);
label2.TabIndex = 155;
label2.Text = "Show Expanded";
label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label1
//
label1.AutoSize = true;
label1.BackColor = System.Drawing.Color.Transparent;
label1.ForeColor = System.Drawing.SystemColors.ControlText;
label1.Location = new System.Drawing.Point(10, 20);
label1.Margin = new Padding(0);
label1.Name = "label1";
label1.Padding = new Padding(0, 9, 0, 0);
label1.Size = new System.Drawing.Size(29, 24);
label1.TabIndex = 153;
label1.Text = "Title";
label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// pickerBox1
//
pickerBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
pickerBox1.BackColor = System.Drawing.Color.Transparent;
pickerBox1.EnableMovable = false;
pickerBox1.Location = new System.Drawing.Point(295, 62);
pickerBox1.Name = "pickerBox1";
pickerBox1.SelectedIndex = 0;
pickerBox1.Size = new System.Drawing.Size(80, 32);
pickerBox1.TabIndex = 174;
pickerBox1.TabStop = false;
pickerBox1.Value = false;
//
// dialogFooter1
//
dialogFooter1.BackColor = System.Drawing.Color.FromArgb(240, 240, 240);
dialogFooter1.Dock = DockStyle.Bottom;
dialogFooter1.EnableMovable = false;
dialogFooter1.IsBusy = false;
dialogFooter1.Location = new System.Drawing.Point(0, 451);
dialogFooter1.Name = "dialogFooter1";
dialogFooter1.Size = new System.Drawing.Size(384, 70);
dialogFooter1.TabIndex = 0;
dialogFooter1.TabStop = false;
//
// horizontalSeparator1
//
horizontalSeparator1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
horizontalSeparator1.Location = new System.Drawing.Point(5, 99);
horizontalSeparator1.Name = "horizontalSeparator1";
horizontalSeparator1.Size = new System.Drawing.Size(375, 10);
//
// numericBox1
//
numericBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
numericBox1.BackColor = System.Drawing.Color.Transparent;
numericBox1.EnableMovable = false;
numericBox1.Location = new System.Drawing.Point(275, 116);
numericBox1.Maximum = 20;
numericBox1.Minimum = 4;
numericBox1.Name = "numericBox1";
numericBox1.Size = new System.Drawing.Size(100, 32);
numericBox1.TabIndex = 198;
numericBox1.TabStop = false;
numericBox1.Value = 1;
//
// label4
//
label4.AutoSize = true;
label4.BackColor = System.Drawing.Color.Transparent;
label4.ForeColor = System.Drawing.SystemColors.ControlText;
label4.Location = new System.Drawing.Point(10, 116);
label4.Margin = new Padding(0);
label4.Name = "label4";
label4.Padding = new Padding(0, 8, 0, 0);
label4.Size = new System.Drawing.Size(76, 23);
label4.TabIndex = 197;
label4.Text = "Tiles Per Row";
label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// numericBox2
//
numericBox2.Anchor = AnchorStyles.Top | AnchorStyles.Right;
numericBox2.BackColor = System.Drawing.Color.Transparent;
numericBox2.EnableMovable = false;
numericBox2.Location = new System.Drawing.Point(275, 158);
numericBox2.Maximum = 32;
numericBox2.Minimum = 1;
numericBox2.Name = "numericBox2";
numericBox2.Size = new System.Drawing.Size(100, 32);
numericBox2.TabIndex = 200;
numericBox2.TabStop = false;
numericBox2.Value = 1;
//
// label3
//
label3.AutoSize = true;
label3.BackColor = System.Drawing.Color.Transparent;
label3.ForeColor = System.Drawing.SystemColors.ControlText;
label3.Location = new System.Drawing.Point(10, 158);
label3.Margin = new Padding(0);
label3.Name = "label3";
label3.Padding = new Padding(0, 8, 0, 0);
label3.Size = new System.Drawing.Size(96, 23);
label3.TabIndex = 199;
label3.Text = "Number of Rows";
label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// EditGroupForm
//
BackColor = System.Drawing.Color.White;
ClientSize = new System.Drawing.Size(384, 521);
Controls.Add(numericBox2);
Controls.Add(label3);
Controls.Add(numericBox1);
Controls.Add(label4);
Controls.Add(horizontalSeparator1);
Controls.Add(dialogFooter1);
Controls.Add(pickerBox1);
Controls.Add(label2);
Controls.Add(label1);
Controls.Add(textBox1);
MinimumSize = new System.Drawing.Size(400, 560);
Name = "EditGroupForm";
Text = "Edit Section";
ResumeLayout(false);
PerformLayout();
}
public App4Options.Group Result
{
get
{
if (result == null)
{
result = new App4Options.Group();
}
var maxGridSize = result.GetMaxGridSize();
var x = Math.Max(maxGridSize.Width, numericBox1.Value);
var y = Math.Max(maxGridSize.Height, numericBox2.Value);
result.Title = textBox1.Text?.Trim() ?? string.Empty;
result.IsOpen = pickerBox1.Value;
result.GridSize = new System.Drawing.Size(x, y);
return result;
}
}
}
}