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

313 lines
12 KiB
C#

using System;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
using RokettoLaunch.DTOs.SaveFile;
using RyzStudio.Windows.Forms;
using RyzStudio.Windows.ThemedForms;
using RyzStudio.Windows.ThemedForms.ButtonTextBox;
using RyzStudio.Windows.ThemedForms.PickerBox;
namespace RokettoLaunch.Forms
{
public class EditTileForm : Form
{
private Label label6;
private Label label7;
private Label label4;
private Label label3;
private Label label2;
private Label label1;
private ThPathTextBox textBox2;
private ThClearableTextBox textBox3;
private ThPathTextBox textBox4;
private ThPickerBox pickerBox1;
private ThYesNoPickerBox pickerBox2;
private THorizontalSeparator horizontalSeparator1;
private ThClearableTextBox textBox1;
private RyzStudio.Windows.ThemedForms.Composite.DialogFooter dialogFooter1;
private App4Options.Item result = null;
public EditTileForm(App4Options.Item model = null)
{
InitializeComponent();
UISetup.Dialog(this, true);
this.Text = (result == null) ? "Add Tile" : "Edit Tile";
result = model;
pickerBox1.Setup([ "Normal", "Hidden", "Minimized", "Maximized" ], 0);
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
textBox1.Text = result?.Title ?? "New Tile";
textBox2.Text = result?.TargetPath ?? string.Empty;
textBox3.Text = result?.Argument ?? string.Empty;
textBox4.Text = result?.ResolvedStartPath ?? string.Empty;
pickerBox1.Value = (int)(result?.WindowStyle ?? ProcessWindowStyle.Normal);
pickerBox2.Value = result?.RunAsAdmin ?? false;
}
private void InitializeComponent()
{
textBox1 = new ThClearableTextBox();
label6 = new Label();
label7 = new Label();
label4 = new Label();
label3 = new Label();
label2 = new Label();
label1 = new Label();
textBox2 = new ThPathTextBox();
textBox3 = new ThClearableTextBox();
textBox4 = new ThPathTextBox();
pickerBox1 = new ThPickerBox();
pickerBox2 = new ThYesNoPickerBox();
horizontalSeparator1 = new THorizontalSeparator();
dialogFooter1 = new RyzStudio.Windows.ThemedForms.Composite.DialogFooter();
SuspendLayout();
//
// textBox1
//
textBox1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
textBox1.BackColor = Color.Transparent;
textBox1.ClearedValue = "";
textBox1.EnableMovable = false;
textBox1.Icon = "O";
textBox1.IconSize = 13F;
textBox1.Location = new Point(95, 20);
textBox1.Name = "textBox1";
textBox1.Size = new Size(280, 32);
textBox1.TabIndex = 152;
textBox1.TabStop = false;
textBox1.UseSystemPasswordChar = false;
//
// label6
//
label6.AutoSize = true;
label6.BackColor = Color.Transparent;
label6.ForeColor = SystemColors.ControlText;
label6.Location = new Point(10, 242);
label6.Margin = new Padding(0);
label6.Name = "label6";
label6.Padding = new Padding(0, 9, 0, 0);
label6.Size = new Size(83, 24);
label6.TabIndex = 163;
label6.Text = "Run As Admin";
label6.TextAlign = ContentAlignment.MiddleLeft;
//
// label7
//
label7.AutoSize = true;
label7.BackColor = Color.Transparent;
label7.ForeColor = SystemColors.ControlText;
label7.Location = new Point(10, 200);
label7.Margin = new Padding(0);
label7.Name = "label7";
label7.Padding = new Padding(0, 9, 0, 0);
label7.Size = new Size(79, 24);
label7.TabIndex = 161;
label7.Text = "Window Style";
label7.TextAlign = ContentAlignment.MiddleLeft;
//
// label4
//
label4.AutoSize = true;
label4.BackColor = Color.Transparent;
label4.ForeColor = SystemColors.ControlText;
label4.Location = new Point(10, 146);
label4.Margin = new Padding(0);
label4.Name = "label4";
label4.Padding = new Padding(0, 9, 0, 0);
label4.Size = new Size(82, 24);
label4.TabIndex = 159;
label4.Text = "Start Directory";
label4.TextAlign = ContentAlignment.MiddleLeft;
//
// label3
//
label3.AutoSize = true;
label3.BackColor = Color.Transparent;
label3.ForeColor = SystemColors.ControlText;
label3.Location = new Point(10, 104);
label3.Margin = new Padding(0);
label3.Name = "label3";
label3.Padding = new Padding(0, 9, 0, 0);
label3.Size = new Size(61, 24);
label3.TabIndex = 157;
label3.Text = "Argument";
label3.TextAlign = ContentAlignment.MiddleLeft;
//
// label2
//
label2.AutoSize = true;
label2.BackColor = Color.Transparent;
label2.ForeColor = SystemColors.ControlText;
label2.Location = new Point(10, 62);
label2.Margin = new Padding(0);
label2.Name = "label2";
label2.Padding = new Padding(0, 9, 0, 0);
label2.Size = new Size(55, 24);
label2.TabIndex = 155;
label2.Text = "Filename";
label2.TextAlign = ContentAlignment.MiddleLeft;
//
// label1
//
label1.AutoSize = true;
label1.BackColor = Color.Transparent;
label1.ForeColor = SystemColors.ControlText;
label1.Location = new Point(10, 20);
label1.Margin = new Padding(0);
label1.Name = "label1";
label1.Padding = new Padding(0, 9, 0, 0);
label1.Size = new Size(29, 24);
label1.TabIndex = 153;
label1.Text = "Title";
label1.TextAlign = ContentAlignment.MiddleLeft;
//
// textBox2
//
textBox2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
textBox2.BackColor = Color.Transparent;
textBox2.DialogMode = ThPathTextBox.DialogType.OpenFile;
textBox2.EnableMovable = false;
textBox2.FolderBrowserDialog = null;
textBox2.Icon = "D";
textBox2.IconSize = 13F;
textBox2.Location = new Point(115, 62);
textBox2.Name = "textBox2";
textBox2.Size = new Size(260, 32);
textBox2.TabIndex = 170;
textBox2.TabStop = false;
textBox2.UseSystemPasswordChar = false;
//
// textBox3
//
textBox3.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
textBox3.BackColor = Color.Transparent;
textBox3.ClearedValue = "";
textBox3.EnableMovable = false;
textBox3.Icon = "O";
textBox3.IconSize = 13F;
textBox3.Location = new Point(135, 104);
textBox3.Name = "textBox3";
textBox3.Size = new Size(240, 32);
textBox3.TabIndex = 171;
textBox3.TabStop = false;
textBox3.UseSystemPasswordChar = false;
//
// textBox4
//
textBox4.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
textBox4.BackColor = Color.Transparent;
textBox4.DialogMode = ThPathTextBox.DialogType.FolderBrowser;
textBox4.EnableMovable = false;
textBox4.FolderBrowserDialog = null;
textBox4.Icon = "D";
textBox4.IconSize = 13F;
textBox4.Location = new Point(135, 146);
textBox4.Name = "textBox4";
textBox4.Size = new Size(240, 32);
textBox4.TabIndex = 172;
textBox4.TabStop = false;
textBox4.UseSystemPasswordChar = false;
//
// pickerBox1
//
pickerBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
pickerBox1.BackColor = Color.Transparent;
pickerBox1.EnableMovable = false;
pickerBox1.Location = new Point(255, 200);
pickerBox1.Name = "pickerBox1";
pickerBox1.SelectedIndex = -1;
pickerBox1.Size = new Size(120, 32);
pickerBox1.TabIndex = 174;
pickerBox1.TabStop = false;
//
// pickerBox2
//
pickerBox2.Anchor = AnchorStyles.Top | AnchorStyles.Right;
pickerBox2.BackColor = Color.Transparent;
pickerBox2.EnableMovable = false;
pickerBox2.Location = new Point(295, 242);
pickerBox2.Name = "pickerBox2";
pickerBox2.SelectedIndex = 0;
pickerBox2.Size = new Size(80, 32);
pickerBox2.TabIndex = 175;
pickerBox2.TabStop = false;
pickerBox2.Value = false;
//
// horizontalSeparator1
//
horizontalSeparator1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
horizontalSeparator1.Location = new Point(5, 183);
horizontalSeparator1.Name = "horizontalSeparator1";
horizontalSeparator1.Size = new Size(375, 10);
//
// dialogFooter1
//
dialogFooter1.BackColor = Color.FromArgb(240, 240, 240);
dialogFooter1.Dock = DockStyle.Bottom;
dialogFooter1.EnableMovable = false;
dialogFooter1.IsBusy = false;
dialogFooter1.Location = new Point(0, 451);
dialogFooter1.Name = "dialogFooter1";
dialogFooter1.Size = new Size(384, 70);
dialogFooter1.TabIndex = 0;
dialogFooter1.TabStop = false;
//
// EditTileForm
//
BackColor = Color.White;
ClientSize = new Size(384, 521);
Controls.Add(dialogFooter1);
Controls.Add(horizontalSeparator1);
Controls.Add(pickerBox2);
Controls.Add(pickerBox1);
Controls.Add(textBox4);
Controls.Add(textBox3);
Controls.Add(textBox2);
Controls.Add(label6);
Controls.Add(label7);
Controls.Add(label4);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(label1);
Controls.Add(textBox1);
MinimumSize = new Size(400, 560);
Name = "EditTileForm";
Text = "Add Tile";
ResumeLayout(false);
PerformLayout();
}
public App4Options.Item Result
{
get
{
if (result == null)
{
result = new App4Options.Item();
}
result.Title = textBox1.Text?.Trim() ?? string.Empty;
result.TargetPath = textBox2.Text?.Trim() ?? string.Empty;
result.Argument = textBox3.Text?.Trim() ?? string.Empty;
result.StartPath = textBox4.Text?.Trim();
result.WindowStyle = (ProcessWindowStyle)pickerBox1.ComboBox.SelectedIndex;
result.RunAsAdmin = pickerBox2.Value;
return result;
}
}
}
}