using AppLauncher.Models; using RyzStudio.Windows.ThemedForms; using System; using System.Drawing; using System.Text; namespace AppLauncher.Windows.Forms { public class OptionsForm : TDialogForm { private System.Windows.Forms.Label label1; private TButton button1; private TTextBox textBox1; public MainForm parentForm { get; set; } = null; protected Point hotKey = new Point(-1, -1); public OptionsForm(MainForm parent) : base() { InitializeComponent(); parentForm = parent; textBox1.InnerTextBox.ReadOnly = true; textBox1.InnerTextBox.BackColor = Color.White; textBox1.InnerTextBox.KeyUp += textBox1_KeyUp; } private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OptionsForm)); this.textBox1 = new RyzStudio.Windows.ThemedForms.TTextBox(); this.label1 = new System.Windows.Forms.Label(); this.button1 = new RyzStudio.Windows.ThemedForms.TButton(); ((System.ComponentModel.ISupportInitialize)(this.imgbxClose)).BeginInit(); this.SuspendLayout(); // // imgbxClose // this.imgbxClose.Image = ((System.Drawing.Image)(resources.GetObject("imgbxClose.Image"))); this.imgbxClose.Location = new System.Drawing.Point(367, 5); // // panel1 // this.panel1.Location = new System.Drawing.Point(394, 474); // // area1 // this.area1.Location = new System.Drawing.Point(1, 474); this.area1.Size = new System.Drawing.Size(392, 5); // // 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("Microsoft Sans Serif", 8.25F); this.textBox1.Location = new System.Drawing.Point(159, 50); this.textBox1.Margin = new System.Windows.Forms.Padding(10, 6, 10, 6); this.textBox1.Name = "textBox1"; this.textBox1.Padding = new System.Windows.Forms.Padding(10, 10, 9, 9); this.textBox1.Size = new System.Drawing.Size(220, 32); this.textBox1.SubmitButton = null; this.textBox1.TabIndex = 152; this.textBox1.UseSystemPasswordChar = false; // // label1 // this.label1.BackColor = System.Drawing.Color.Transparent; this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(95)))), ((int)(((byte)(99)))), ((int)(((byte)(104))))); this.label1.Location = new System.Drawing.Point(18, 50); this.label1.Margin = new System.Windows.Forms.Padding(0); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(131, 32); this.label1.TabIndex = 153; this.label1.Text = "Hotkey"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // button1 // this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.button1.BackColor = System.Drawing.Color.Transparent; this.button1.DefaultImage = null; this.button1.DownImage = null; this.button1.IsSelected = false; this.button1.LabelText = "&Save"; this.button1.Location = new System.Drawing.Point(251, 427); this.button1.Name = "button1"; this.button1.OverImage = 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); // // OptionsForm // this.ClientSize = new System.Drawing.Size(400, 480); this.Controls.Add(this.button1); this.Controls.Add(this.label1); this.Controls.Add(this.textBox1); this.Name = "OptionsForm"; this.Title = "Options"; this.Controls.SetChildIndex(this.imgbxClose, 0); this.Controls.SetChildIndex(this.panel1, 0); this.Controls.SetChildIndex(this.area1, 0); this.Controls.SetChildIndex(this.textBox1, 0); this.Controls.SetChildIndex(this.label1, 0); this.Controls.SetChildIndex(this.button1, 0); ((System.ComponentModel.ISupportInitialize)(this.imgbxClose)).EndInit(); this.ResumeLayout(false); } protected override void OnShown(EventArgs e) { base.OnShown(e); if (parentForm != null) { bool control = false; bool alt = false; bool shift = false; int hotKeyCode = parentForm.GlobalHotKey.X; if (hotKeyCode >= 4) { shift = true; hotKeyCode -= 4; } if (hotKeyCode >= 2) { control = true; hotKeyCode -= 2; } if (hotKeyCode >= 1) { alt = true; hotKeyCode -= 1; } StringBuilder sb = new StringBuilder(); if (control) sb = sb.Append("Ctrl + "); if (alt) sb = sb.Append("Alt + "); if (shift) sb = sb.Append("Shift + "); sb = sb.Append(((System.Windows.Forms.Keys)parentForm.GlobalHotKey.Y).ToString()); textBox1.Text = sb.ToString(); } } private void button1_Click(object sender, EventArgs e) { if (parentForm != null) { parentForm.SetHotKey(hotKey); } this.Close(); } private void textBox1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { if (e.KeyCode == System.Windows.Forms.Keys.ControlKey) return; if (e.KeyCode == System.Windows.Forms.Keys.ShiftKey) return; if (e.KeyCode == System.Windows.Forms.Keys.Menu) return; StringBuilder sb = new StringBuilder(); if (e.Control) sb = sb.Append("Ctrl + "); if (e.Alt) sb = sb.Append("Alt + "); if (e.Shift) sb = sb.Append("Shift + "); int keyModifier = 0; if (e.Alt) keyModifier += 1; if (e.Control) keyModifier += 2; if (e.Shift) keyModifier += 4; sb = sb.Append(e.KeyCode.ToString()); textBox1.Text = sb.ToString(); hotKey = new Point(keyModifier, (int)e.KeyCode); } } }