linear-app-launcher/OptionsForm.cs

280 lines
14 KiB
C#

using FizzyLauncher.Models;
using RyzStudio.Windows.ThemedForms;
using RyzStudio.Windows.ThemedForms.ButtonTextBox;
using RyzStudio.Windows.ThemedForms.PickerBox;
using System;
namespace FizzyLauncher
{
public class OptionsForm : TDialogForm
{
private System.Windows.Forms.Label label1;
private TButton button1;
private TYesNoPickerBox pickerBox2;
private System.Windows.Forms.Label label6;
private TYesNoPickerBox pickerBox3;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private TPickerBox pickerBox1;
private RyzStudio.Windows.Forms.THorizontalSeparator tHorizontalSeparator1;
private TKeyCodeTextBox textBox1;
public OptionsForm(MainForm parent) : base()
{
InitializeComponent();
parentForm = parent;
pickerBox1.ComboBox.Items.Clear();
foreach (string item in Enum.GetNames(typeof(LauncherSession.AutoSaveOption)))
{
pickerBox1.ComboBox.Items.Add(item);
}
if (pickerBox1.ComboBox.Items.Count > 0) pickerBox1.ComboBox.SelectedIndex = 0;
}
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OptionsForm));
TKeyCodeTextBox.Results results1 = new TKeyCodeTextBox.Results();
this.label1 = new System.Windows.Forms.Label();
this.button1 = new TButton();
this.pickerBox2 = new TYesNoPickerBox();
this.label6 = new System.Windows.Forms.Label();
this.pickerBox3 = new TYesNoPickerBox();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.pickerBox1 = new TPickerBox();
this.tHorizontalSeparator1 = new RyzStudio.Windows.Forms.THorizontalSeparator();
this.textBox1 = new TKeyCodeTextBox();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.ForeColor = System.Drawing.SystemColors.ControlText;
this.label1.Location = new System.Drawing.Point(10, 21);
this.label1.Margin = new System.Windows.Forms.Padding(0);
this.label1.Name = "label1";
this.label1.Padding = new System.Windows.Forms.Padding(0, 9, 0, 10);
this.label1.Size = new System.Drawing.Size(107, 34);
this.label1.TabIndex = 153;
this.label1.Text = "Show/Hide Hotkey";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button1.BackColor = System.Drawing.Color.Transparent;
this.button1.IdleImage = null;
this.button1.ActiveImage = null;
this.button1.LabelText = "&Save";
this.button1.Location = new System.Drawing.Point(241, 469);
this.button1.Margin = new System.Windows.Forms.Padding(10);
this.button1.Name = "button1";
this.button1.HoverImage = null;
this.button1.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3);
this.button1.Size = new System.Drawing.Size(128, 32);
this.button1.TabIndex = 173;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// pickerBox2
//
this.pickerBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.pickerBox2.BackColor = System.Drawing.Color.Transparent;
this.pickerBox2.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.pickerBox2.Location = new System.Drawing.Point(285, 103);
this.pickerBox2.Margin = new System.Windows.Forms.Padding(10, 4, 10, 4);
this.pickerBox2.Name = "pickerBox2";
this.pickerBox2.Padding = new System.Windows.Forms.Padding(10, 6, 7, 5);
this.pickerBox2.Size = new System.Drawing.Size(84, 34);
this.pickerBox2.AcceptButton = null;
this.pickerBox2.TabIndex = 183;
this.pickerBox2.Value = true;
//
// label6
//
this.label6.AutoSize = true;
this.label6.BackColor = System.Drawing.Color.Transparent;
this.label6.ForeColor = System.Drawing.SystemColors.ControlText;
this.label6.Location = new System.Drawing.Point(10, 103);
this.label6.Margin = new System.Windows.Forms.Padding(0);
this.label6.Name = "label6";
this.label6.Padding = new System.Windows.Forms.Padding(0, 9, 0, 10);
this.label6.Size = new System.Drawing.Size(83, 34);
this.label6.TabIndex = 182;
this.label6.Text = "Hide On Close";
this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// pickerBox3
//
this.pickerBox3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.pickerBox3.BackColor = System.Drawing.Color.Transparent;
this.pickerBox3.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.pickerBox3.Location = new System.Drawing.Point(285, 144);
this.pickerBox3.Margin = new System.Windows.Forms.Padding(10, 4, 10, 4);
this.pickerBox3.Name = "pickerBox3";
this.pickerBox3.Padding = new System.Windows.Forms.Padding(10, 6, 7, 5);
this.pickerBox3.Size = new System.Drawing.Size(84, 34);
this.pickerBox3.AcceptButton = null;
this.pickerBox3.TabIndex = 185;
this.pickerBox3.Value = true;
//
// label7
//
this.label7.AutoSize = true;
this.label7.BackColor = System.Drawing.Color.Transparent;
this.label7.ForeColor = System.Drawing.SystemColors.ControlText;
this.label7.Location = new System.Drawing.Point(10, 144);
this.label7.Margin = new System.Windows.Forms.Padding(0);
this.label7.Name = "label7";
this.label7.Padding = new System.Windows.Forms.Padding(0, 9, 0, 10);
this.label7.Size = new System.Drawing.Size(95, 34);
this.label7.TabIndex = 184;
this.label7.Text = "Hide On Execute";
this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label8
//
this.label8.AutoSize = true;
this.label8.BackColor = System.Drawing.Color.Transparent;
this.label8.ForeColor = System.Drawing.SystemColors.ControlText;
this.label8.Location = new System.Drawing.Point(10, 62);
this.label8.Margin = new System.Windows.Forms.Padding(0);
this.label8.Name = "label8";
this.label8.Padding = new System.Windows.Forms.Padding(0, 9, 0, 10);
this.label8.Size = new System.Drawing.Size(60, 34);
this.label8.TabIndex = 186;
this.label8.Text = "Auto Save";
this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// pickerBox1
//
this.pickerBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.pickerBox1.BackColor = System.Drawing.Color.Transparent;
this.pickerBox1.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.pickerBox1.Location = new System.Drawing.Point(285, 62);
this.pickerBox1.Margin = new System.Windows.Forms.Padding(10, 4, 10, 4);
this.pickerBox1.Name = "pickerBox1";
this.pickerBox1.Padding = new System.Windows.Forms.Padding(10, 6, 7, 5);
this.pickerBox1.Size = new System.Drawing.Size(84, 34);
this.pickerBox1.AcceptButton = null;
this.pickerBox1.TabIndex = 187;
//
// tHorizontalSeparator1
//
this.tHorizontalSeparator1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tHorizontalSeparator1.AutoScrollMargin = new System.Drawing.Size(0, 0);
this.tHorizontalSeparator1.AutoScrollMinSize = new System.Drawing.Size(0, 0);
this.tHorizontalSeparator1.BackColor = System.Drawing.Color.Transparent;
this.tHorizontalSeparator1.Location = new System.Drawing.Point(10, 437);
this.tHorizontalSeparator1.Margin = new System.Windows.Forms.Padding(10, 0, 10, 0);
this.tHorizontalSeparator1.MaximumSize = new System.Drawing.Size(4920, 2);
this.tHorizontalSeparator1.MinimumSize = new System.Drawing.Size(0, 22);
this.tHorizontalSeparator1.Name = "tHorizontalSeparator1";
this.tHorizontalSeparator1.Padding = new System.Windows.Forms.Padding(0, 10, 0, 10);
this.tHorizontalSeparator1.Size = new System.Drawing.Size(364, 22);
this.tHorizontalSeparator1.TabIndex = 188;
//
// textBox1
//
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox1.BackColor = System.Drawing.Color.Transparent;
this.textBox1.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.textBox1.HighlightImage = ((System.Drawing.Image)(resources.GetObject("textBox1.HighlightImage")));
results1.IsAlt = false;
results1.IsCtrl = false;
results1.IsShift = false;
results1.Key = System.Windows.Forms.Keys.None;
this.textBox1.KeyCodeResults = results1;
this.textBox1.Location = new System.Drawing.Point(192, 20);
this.textBox1.Margin = new System.Windows.Forms.Padding(10, 3, 3, 3);
this.textBox1.Name = "textBox1";
this.textBox1.NormalImage = ((System.Drawing.Image)(resources.GetObject("textBox1.NormalImage")));
this.textBox1.Padding = new System.Windows.Forms.Padding(10, 10, 9, 9);
this.textBox1.Size = new System.Drawing.Size(177, 35);
this.textBox1.AcceptButton = null;
this.textBox1.TabIndex = 189;
this.textBox1.UseSystemPasswordChar = false;
//
// OptionsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(384, 521);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.tHorizontalSeparator1);
this.Controls.Add(this.pickerBox1);
this.Controls.Add(this.label8);
this.Controls.Add(this.pickerBox3);
this.Controls.Add(this.label7);
this.Controls.Add(this.pickerBox2);
this.Controls.Add(this.label6);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.MinimumSize = new System.Drawing.Size(400, 560);
this.Name = "OptionsForm";
this.Text = "Options";
this.ResumeLayout(false);
this.PerformLayout();
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
if (parentForm == null)
{
return;
}
if (parentForm.CurrentSession == null)
{
return;
}
// hotkey
if (parentForm.CurrentSession.HotKey != null)
{
textBox1.UpdateKeyCode(parentForm.CurrentSession.HotKey.IsCtrl, parentForm.CurrentSession.HotKey.IsAlt, parentForm.CurrentSession.HotKey.IsShift, parentForm.CurrentSession.HotKey.KeyCode);
}
pickerBox1.ComboBox.SelectedIndex = (int)parentForm.CurrentSession.AutoSave;
pickerBox2.Value = parentForm.CurrentSession.HideOnClose;
pickerBox3.Value = parentForm.CurrentSession.HideOnClick;
}
public MainForm parentForm { get; set; } = null;
private void button1_Click(object sender, EventArgs e)
{
if (parentForm != null)
{
if (parentForm.CurrentSession == null) parentForm.CurrentSession = new LauncherSession();
if (parentForm.CurrentSession.HotKey == null) parentForm.CurrentSession.HotKey = new LauncherSession.HotKeyOptions();
parentForm.CurrentSession.HotKey.IsCtrl = textBox1.KeyCodeResults.IsCtrl;
parentForm.CurrentSession.HotKey.IsAlt = textBox1.KeyCodeResults.IsAlt;
parentForm.CurrentSession.HotKey.IsShift = textBox1.KeyCodeResults.IsShift;
parentForm.CurrentSession.HotKey.Key = textBox1.KeyCodeResults.KeyCode;
parentForm.CurrentSession.AutoSave = (LauncherSession.AutoSaveOption)pickerBox1.ComboBox.SelectedIndex;
parentForm.CurrentSession.HideOnClose = pickerBox2.Value;
parentForm.CurrentSession.HideOnClick = pickerBox3.Value;
}
this.Close();
}
}
}