bookmark-manager-r4/OptionsForm.cs

311 lines
13 KiB
C#
Raw Normal View History

using System;
2024-07-17 00:56:17 +00:00
using System.Linq;
2021-09-09 21:39:23 +00:00
using System.Windows.Forms;
using FizzyLauncher.Models;
2024-07-17 00:56:17 +00:00
using RyzStudio.Windows.Forms;
2021-09-07 11:32:24 +00:00
using RyzStudio.Windows.ThemedForms;
using RyzStudio.Windows.ThemedForms.PickerBox;
2021-09-07 11:32:24 +00:00
namespace FizzyLauncher
{
2024-07-20 17:09:44 +00:00
public class OptionsForm : Form
2021-09-07 11:32:24 +00:00
{
2024-07-17 00:56:17 +00:00
private FlowLayoutPanel flowLayoutPanel1;
private TTogglePanel panel1;
private TTogglePanel panel3;
private ThYesNoPickerBox yesNoPickerBox1;
2021-10-12 18:55:00 +00:00
private Label label2;
2024-07-17 00:56:17 +00:00
private TTogglePanel panel2;
private ThYesNoPickerBox thYesNoPickerBox1;
private Label label1;
private ThYesNoPickerBox yesNoPickerBox2;
2021-11-15 23:06:55 +00:00
private Label label3;
2024-07-17 00:56:17 +00:00
private RyzStudio.Windows.ThemedForms.ButtonTextBox.ThClearableTextBox textBox1;
2024-07-20 17:09:44 +00:00
private RyzStudio.Windows.ThemedForms.Composite.DialogFooter dialogFooter1;
2024-07-17 00:56:17 +00:00
private AppOptions _appSession = null;
2021-09-07 11:32:24 +00:00
2024-07-17 00:56:17 +00:00
public OptionsForm(AppOptions appSession)
2021-09-07 11:32:24 +00:00
{
InitializeComponent();
2024-07-20 17:09:44 +00:00
UISetup.Dialog(this);
2024-07-17 00:56:17 +00:00
2024-07-20 17:09:44 +00:00
_appSession = appSession;
2021-09-07 11:32:24 +00:00
2024-07-17 00:56:17 +00:00
if (_appSession != null)
2021-09-07 11:32:24 +00:00
{
2024-07-17 00:56:17 +00:00
yesNoPickerBox1.Value = _appSession.RestorePosition;
2021-09-07 11:32:24 +00:00
2024-07-17 00:56:17 +00:00
yesNoPickerBox2.Value = _appSession.AlwaysOnTop;
2021-09-07 11:32:24 +00:00
2024-07-17 00:56:17 +00:00
textBox1.Text = _appSession.RunCommand ?? string.Empty;
}
2021-09-07 11:32:24 +00:00
}
private void InitializeComponent()
{
2024-07-17 00:56:17 +00:00
flowLayoutPanel1 = new FlowLayoutPanel();
panel1 = new TTogglePanel();
yesNoPickerBox1 = new ThYesNoPickerBox();
label2 = new Label();
panel2 = new TTogglePanel();
yesNoPickerBox2 = new ThYesNoPickerBox();
thYesNoPickerBox1 = new ThYesNoPickerBox();
label1 = new Label();
panel3 = new TTogglePanel();
textBox1 = new RyzStudio.Windows.ThemedForms.ButtonTextBox.ThClearableTextBox();
label3 = new Label();
2024-07-20 17:09:44 +00:00
dialogFooter1 = new RyzStudio.Windows.ThemedForms.Composite.DialogFooter();
2024-07-17 00:56:17 +00:00
flowLayoutPanel1.SuspendLayout();
panel1.SuspendLayout();
panel2.SuspendLayout();
panel3.SuspendLayout();
SuspendLayout();
2024-07-20 17:09:44 +00:00
//
2024-07-17 00:56:17 +00:00
// flowLayoutPanel1
2024-07-20 17:09:44 +00:00
//
2024-07-17 00:56:17 +00:00
flowLayoutPanel1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
flowLayoutPanel1.AutoScroll = true;
flowLayoutPanel1.BackColor = System.Drawing.Color.Transparent;
flowLayoutPanel1.Controls.Add(panel1);
flowLayoutPanel1.Controls.Add(panel2);
flowLayoutPanel1.Controls.Add(panel3);
flowLayoutPanel1.FlowDirection = FlowDirection.TopDown;
flowLayoutPanel1.Location = new System.Drawing.Point(8, 12);
flowLayoutPanel1.Name = "flowLayoutPanel1";
flowLayoutPanel1.Size = new System.Drawing.Size(436, 412);
flowLayoutPanel1.TabIndex = 194;
flowLayoutPanel1.WrapContents = false;
flowLayoutPanel1.Resize += flowLayoutPanel1_Resize;
2024-07-20 17:09:44 +00:00
//
2024-07-17 00:56:17 +00:00
// panel1
2024-07-20 17:09:44 +00:00
//
2024-07-17 00:56:17 +00:00
panel1.AutoScrollMargin = new System.Drawing.Size(0, 0);
panel1.AutoScrollMinSize = new System.Drawing.Size(0, 0);
panel1.Controls.Add(yesNoPickerBox1);
panel1.Controls.Add(label2);
panel1.ExpandedHeight = 100;
panel1.ForeColor = System.Drawing.Color.FromArgb(99, 105, 119);
panel1.IsOpen = true;
panel1.Location = new System.Drawing.Point(0, 0);
panel1.Margin = new Padding(0);
panel1.Name = "panel1";
2024-07-20 17:09:44 +00:00
panel1.PaddingBottom = 0;
2024-07-17 00:56:17 +00:00
panel1.PaddingLeft = 4;
panel1.Size = new System.Drawing.Size(401, 77);
panel1.TabIndex = 0;
panel1.Title = "On Start-Up";
panel1.TitleContextMenuStrip = null;
panel1.TitleCursor = Cursors.Default;
2024-07-20 17:09:44 +00:00
//
2024-07-17 00:56:17 +00:00
// yesNoPickerBox1
2024-07-20 17:09:44 +00:00
//
2024-07-17 00:56:17 +00:00
yesNoPickerBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
yesNoPickerBox1.BackColor = System.Drawing.Color.Transparent;
yesNoPickerBox1.EnableReactiveVisual = true;
yesNoPickerBox1.Font = new System.Drawing.Font("Segoe UI", 9F);
yesNoPickerBox1.Location = new System.Drawing.Point(307, 22);
yesNoPickerBox1.Name = "yesNoPickerBox1";
yesNoPickerBox1.SelectedIndex = 1;
yesNoPickerBox1.Size = new System.Drawing.Size(84, 34);
yesNoPickerBox1.TabIndex = 197;
yesNoPickerBox1.TabStop = false;
yesNoPickerBox1.Value = true;
2024-07-20 17:09:44 +00:00
//
2021-10-12 18:55:00 +00:00
// label2
2024-07-20 17:09:44 +00:00
//
2024-07-17 00:56:17 +00:00
label2.AutoSize = true;
label2.BackColor = System.Drawing.Color.Transparent;
label2.ForeColor = System.Drawing.SystemColors.ControlText;
label2.Location = new System.Drawing.Point(1, 22);
label2.Margin = new Padding(0);
label2.Name = "label2";
label2.Padding = new Padding(0, 8, 0, 0);
label2.Size = new System.Drawing.Size(92, 23);
label2.TabIndex = 196;
label2.Text = "Restore Position";
label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
2024-07-20 17:09:44 +00:00
//
2024-07-17 00:56:17 +00:00
// panel2
2024-07-20 17:09:44 +00:00
//
2024-07-17 00:56:17 +00:00
panel2.AutoScrollMargin = new System.Drawing.Size(0, 0);
panel2.AutoScrollMinSize = new System.Drawing.Size(0, 0);
panel2.Controls.Add(yesNoPickerBox2);
panel2.Controls.Add(thYesNoPickerBox1);
panel2.Controls.Add(label1);
panel2.ExpandedHeight = 100;
panel2.ForeColor = System.Drawing.Color.FromArgb(99, 105, 119);
panel2.IsOpen = true;
panel2.Location = new System.Drawing.Point(0, 77);
panel2.Margin = new Padding(0);
panel2.Name = "panel2";
2024-07-20 17:09:44 +00:00
panel2.PaddingBottom = 0;
2024-07-17 00:56:17 +00:00
panel2.PaddingLeft = 4;
panel2.Size = new System.Drawing.Size(401, 77);
panel2.TabIndex = 2;
panel2.Title = "Appearance";
panel2.TitleContextMenuStrip = null;
panel2.TitleCursor = Cursors.Default;
2024-07-20 17:09:44 +00:00
//
2024-07-17 00:56:17 +00:00
// yesNoPickerBox2
2024-07-20 17:09:44 +00:00
//
2024-07-17 00:56:17 +00:00
yesNoPickerBox2.Anchor = AnchorStyles.Top | AnchorStyles.Right;
yesNoPickerBox2.BackColor = System.Drawing.Color.Transparent;
yesNoPickerBox2.EnableReactiveVisual = true;
yesNoPickerBox2.Font = new System.Drawing.Font("Segoe UI", 9F);
yesNoPickerBox2.Location = new System.Drawing.Point(307, 22);
yesNoPickerBox2.Name = "yesNoPickerBox2";
yesNoPickerBox2.SelectedIndex = 1;
yesNoPickerBox2.Size = new System.Drawing.Size(84, 34);
yesNoPickerBox2.TabIndex = 198;
yesNoPickerBox2.TabStop = false;
yesNoPickerBox2.Value = true;
2024-07-20 17:09:44 +00:00
//
2024-07-17 00:56:17 +00:00
// thYesNoPickerBox1
2024-07-20 17:09:44 +00:00
//
2024-07-17 00:56:17 +00:00
thYesNoPickerBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
thYesNoPickerBox1.BackColor = System.Drawing.Color.Transparent;
thYesNoPickerBox1.EnableReactiveVisual = true;
thYesNoPickerBox1.Font = new System.Drawing.Font("Segoe UI", 9F);
thYesNoPickerBox1.Location = new System.Drawing.Point(508, 22);
thYesNoPickerBox1.Name = "thYesNoPickerBox1";
thYesNoPickerBox1.SelectedIndex = 1;
thYesNoPickerBox1.Size = new System.Drawing.Size(84, 34);
thYesNoPickerBox1.TabIndex = 197;
thYesNoPickerBox1.TabStop = false;
thYesNoPickerBox1.Value = true;
2024-07-20 17:09:44 +00:00
//
2024-07-17 00:56:17 +00:00
// label1
2024-07-20 17:09:44 +00:00
//
2024-07-17 00:56:17 +00:00
label1.AutoSize = true;
label1.BackColor = System.Drawing.Color.Transparent;
label1.ForeColor = System.Drawing.SystemColors.ControlText;
label1.Location = new System.Drawing.Point(1, 22);
label1.Margin = new Padding(0);
label1.Name = "label1";
label1.Padding = new Padding(0, 8, 0, 0);
label1.Size = new System.Drawing.Size(85, 23);
label1.TabIndex = 196;
label1.Text = "Always On Top";
label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
2024-07-20 17:09:44 +00:00
//
2024-07-17 00:56:17 +00:00
// panel3
2024-07-20 17:09:44 +00:00
//
2024-07-17 00:56:17 +00:00
panel3.AutoScrollMargin = new System.Drawing.Size(0, 0);
panel3.AutoScrollMinSize = new System.Drawing.Size(0, 0);
panel3.Controls.Add(textBox1);
panel3.Controls.Add(label3);
panel3.ExpandedHeight = 100;
panel3.ForeColor = System.Drawing.Color.FromArgb(99, 105, 119);
panel3.IsOpen = true;
panel3.Location = new System.Drawing.Point(0, 154);
panel3.Margin = new Padding(0);
panel3.Name = "panel3";
2024-07-20 17:09:44 +00:00
panel3.PaddingBottom = 0;
2024-07-17 00:56:17 +00:00
panel3.PaddingLeft = 4;
2024-07-18 22:45:51 +00:00
panel3.Size = new System.Drawing.Size(401, 77);
2024-07-17 00:56:17 +00:00
panel3.TabIndex = 1;
panel3.Title = "Behaviour";
panel3.TitleContextMenuStrip = null;
panel3.TitleCursor = Cursors.Default;
2024-07-20 17:09:44 +00:00
//
2024-07-17 00:56:17 +00:00
// textBox1
2024-07-20 17:09:44 +00:00
//
2024-07-17 00:56:17 +00:00
textBox1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
textBox1.BackColor = System.Drawing.Color.Transparent;
textBox1.ClearedValue = "{0}";
textBox1.EnableReactiveVisual = true;
textBox1.Font = new System.Drawing.Font("Segoe UI", 9F);
textBox1.Icon = "O";
textBox1.IconSize = 13F;
textBox1.Location = new System.Drawing.Point(161, 21);
textBox1.Name = "textBox1";
textBox1.Size = new System.Drawing.Size(230, 32);
textBox1.TabIndex = 203;
textBox1.TabStop = false;
textBox1.UseSystemPasswordChar = false;
2024-07-20 17:09:44 +00:00
//
2021-11-15 23:06:55 +00:00
// label3
2024-07-20 17:09:44 +00:00
//
2024-07-17 00:56:17 +00:00
label3.AutoSize = true;
label3.BackColor = System.Drawing.Color.Transparent;
label3.ForeColor = System.Drawing.SystemColors.ControlText;
label3.Location = new System.Drawing.Point(1, 21);
label3.Margin = new Padding(0);
label3.Name = "label3";
label3.Padding = new Padding(0, 8, 0, 0);
label3.Size = new System.Drawing.Size(88, 23);
label3.TabIndex = 199;
label3.Text = "Run Command";
label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
2024-07-20 17:09:44 +00:00
//
// dialogFooter1
//
dialogFooter1.BackColor = System.Drawing.Color.FromArgb(240, 240, 240);
dialogFooter1.Button1Text = "&Save";
dialogFooter1.Dialog = this;
dialogFooter1.Dock = DockStyle.Bottom;
dialogFooter1.Location = new System.Drawing.Point(0, 437);
dialogFooter1.Name = "dialogFooter1";
dialogFooter1.Size = new System.Drawing.Size(444, 84);
//
2021-09-07 11:32:24 +00:00
// OptionsForm
2024-07-20 17:09:44 +00:00
//
2024-07-17 00:56:17 +00:00
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
2024-07-20 17:09:44 +00:00
BackColor = System.Drawing.Color.White;
2024-07-17 00:56:17 +00:00
ClientSize = new System.Drawing.Size(444, 521);
2024-07-20 17:09:44 +00:00
Controls.Add(dialogFooter1);
2024-07-17 00:56:17 +00:00
Controls.Add(flowLayoutPanel1);
MinimumSize = new System.Drawing.Size(460, 560);
Name = "OptionsForm";
Text = "Options";
flowLayoutPanel1.ResumeLayout(false);
panel1.ResumeLayout(false);
panel1.PerformLayout();
panel2.ResumeLayout(false);
panel2.PerformLayout();
panel3.ResumeLayout(false);
panel3.PerformLayout();
ResumeLayout(false);
2021-09-07 11:32:24 +00:00
}
2024-07-17 00:56:17 +00:00
protected override void OnLoad(EventArgs e)
2021-09-07 11:32:24 +00:00
{
2024-07-17 00:56:17 +00:00
base.OnLoad(e);
2021-09-07 11:32:24 +00:00
2024-07-17 00:56:17 +00:00
flowLayoutPanel1_Resize(null, e);
}
2021-09-07 11:32:24 +00:00
2024-07-17 00:56:17 +00:00
private void flowLayoutPanel1_Resize(object sender, EventArgs e)
{
var width = flowLayoutPanel1.ClientRectangle.Width - SystemInformation.VerticalScrollBarWidth;
foreach (var item in flowLayoutPanel1.Controls.OfType<Control>())
2021-09-07 11:32:24 +00:00
{
2024-07-17 00:56:17 +00:00
item.Width = width;
2021-09-07 11:32:24 +00:00
}
}
2024-07-17 00:56:17 +00:00
public AppOptions Result
2021-09-07 11:32:24 +00:00
{
2024-07-17 00:56:17 +00:00
get
2021-09-07 11:32:24 +00:00
{
2024-07-17 00:56:17 +00:00
if (_appSession == null)
{
_appSession = new AppOptions();
}
2021-09-07 11:32:24 +00:00
2024-07-17 00:56:17 +00:00
_appSession.RestorePosition = yesNoPickerBox1.Value;
_appSession.AlwaysOnTop = yesNoPickerBox2.Value;
2021-09-07 11:32:24 +00:00
2024-07-17 00:56:17 +00:00
_appSession.RunCommand = textBox1.Text ?? string.Empty;
return _appSession;
}
2021-09-07 11:32:24 +00:00
}
}
}