From d2ef12b1342fbdaeab22285db9735f92c02de800 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 12 Sep 2021 15:25:37 +0100 Subject: [PATCH] WIP: find form --- BookmarkManager.csproj | 3 + FindForm.cs | 219 ++++++++++++++++++ FindForm.resx | 60 +++++ MainForm.cs | 9 +- OptionsForm.cs | 6 +- PasswordForm.cs | 15 +- RyzStudio/Windows/ThemedForms/TButton.cs | 16 +- .../Windows/ThemedForms/TButton.designer.cs | 11 +- RyzStudio/Windows/ThemedForms/TButton.resx | 62 +---- 9 files changed, 322 insertions(+), 79 deletions(-) create mode 100644 FindForm.cs create mode 100644 FindForm.resx diff --git a/BookmarkManager.csproj b/BookmarkManager.csproj index 5e58af1..732dcc4 100644 --- a/BookmarkManager.csproj +++ b/BookmarkManager.csproj @@ -105,6 +105,9 @@ True AppResource.resx + + Form + Form diff --git a/FindForm.cs b/FindForm.cs new file mode 100644 index 0000000..efeafd5 --- /dev/null +++ b/FindForm.cs @@ -0,0 +1,219 @@ +using RyzStudio.Windows.Forms; +using RyzStudio.Windows.ThemedForms; +using System; +using System.ComponentModel; +using System.Windows.Forms; + +namespace FizzyLauncher +{ + public class FindForm : TDialogForm + { + private System.Windows.Forms.Label label1; + private TButton button2; + private RyzStudio.Windows.Forms.THorizontalSeparator tHorizontalSeparator1; + private TButton button1; + private TTextBox textBox1; + + + private BookmarkTreeView treeView1 = null; + private bool findNextNew = false; + + + public FindForm(MainForm parent, BookmarkTreeView treeView) + { + InitializeComponent(); + + treeView1 = treeView; + + this.ParentForm = parent; + this.StartPosition = FormStartPosition.WindowsDefaultLocation; + + textBox1.InnerTextBox.PreviewKeyDown += textBox1_PreviewKeyDown; + } + + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.button2 = new RyzStudio.Windows.ThemedForms.TButton(); + this.tHorizontalSeparator1 = new RyzStudio.Windows.Forms.THorizontalSeparator(); + this.textBox1 = new RyzStudio.Windows.ThemedForms.TTextBox(); + this.button1 = new RyzStudio.Windows.ThemedForms.TButton(); + 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(30, 34); + this.label1.TabIndex = 153; + this.label1.Text = "Find"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // button2 + // + this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button2.BackColor = System.Drawing.Color.Transparent; + this.button2.DefaultImage = null; + this.button2.DownImage = null; + this.button2.IsSelected = false; + this.button2.LabelText = "&Next"; + this.button2.Location = new System.Drawing.Point(321, 99); + this.button2.Margin = new System.Windows.Forms.Padding(10); + this.button2.Name = "button2"; + this.button2.OverImage = null; + this.button2.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3); + this.button2.Size = new System.Drawing.Size(128, 32); + this.button2.TabIndex = 173; + this.button2.MouseClick += new System.Windows.Forms.MouseEventHandler(this.button2_MouseClick); + // + // 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, 67); + 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(444, 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.Location = new System.Drawing.Point(121, 20); + 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(328, 35); + this.textBox1.SubmitButton = null; + this.textBox1.TabIndex = 191; + this.textBox1.UseSystemPasswordChar = true; + // + // 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.DefaultImage = null; + this.button1.DownImage = null; + this.button1.IsSelected = false; + this.button1.LabelText = "&First"; + this.button1.Location = new System.Drawing.Point(185, 99); + this.button1.Margin = new System.Windows.Forms.Padding(10); + 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 = 192; + this.button1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.button1_MouseClick); + // + // FindForm + // + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.ClientSize = new System.Drawing.Size(464, 151); + this.Controls.Add(this.button1); + this.Controls.Add(this.textBox1); + this.Controls.Add(this.tHorizontalSeparator1); + this.Controls.Add(this.button2); + this.Controls.Add(this.label1); + this.MinimumSize = new System.Drawing.Size(480, 190); + this.Name = "FindForm"; + this.Text = "Find"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + protected override void OnShown(EventArgs e) + { + base.OnShown(e); + + this.DialogResult = System.Windows.Forms.DialogResult.None; + + textBox1.InnerTextBox.Focus(); + } + + protected override void OnClosing(CancelEventArgs e) + { + base.OnClosing(e); + + e.Cancel = true; + + this.Hide(); + } + + + [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public new MainForm ParentForm { get; protected set; } = null; + + [Browsable(false)] + public string Password => textBox1.Text; + + + private void textBox1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) + { + switch (e.KeyCode) + { + case Keys.Enter: + if (findNextNew) + { + button1_MouseClick(sender, new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); + } + else + { + button2_MouseClick(sender, new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); + } + + break; + case Keys.Escape: + this.Close(); + break; + default: break; + } + } + + private void button1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (string.IsNullOrWhiteSpace(textBox1.Text)) return; + if (treeView1.Nodes.Count <= 0) return; + + findNextNew = false; + treeView1.FindTextNode(treeView1.Nodes[0], textBox1.Text?.Trim()); + } + } + + private void button2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (string.IsNullOrWhiteSpace(textBox1.Text)) return; + if (treeView1.Nodes.Count <= 0) return; + + if (treeView1.SelectedNode == null) treeView1.SelectedNode = treeView1.Nodes[0]; + + findNextNew = false; + + bool rv = treeView1.FindTextNode(treeView1.SelectedNode, textBox1.Text?.Trim()); + if (!rv) + { + findNextNew = true; + } + } + } + + } +} \ No newline at end of file diff --git a/FindForm.resx b/FindForm.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/FindForm.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/MainForm.cs b/MainForm.cs index 56d7912..c025d26 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -25,6 +25,7 @@ namespace FizzyLauncher protected OptionsForm optionsForm = null; + protected FindForm findForm = null; protected AppMode appMode = AppMode.Clear; protected string sessionFilename = null; @@ -386,7 +387,13 @@ namespace FizzyLauncher /// private void findToolStripMenuItem_Click(object sender, EventArgs e) { - //tileContainer1.Add(); + if (this.IsBusy) + { + return; + } + + if (findForm == null) findForm = new FindForm(this, treeView1); + findForm.Show(); } diff --git a/OptionsForm.cs b/OptionsForm.cs index fdd7997..c0f1f1d 100644 --- a/OptionsForm.cs +++ b/OptionsForm.cs @@ -85,7 +85,7 @@ namespace FizzyLauncher 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); + this.button1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.button1_MouseClick); // // pickerBox1 // @@ -280,9 +280,7 @@ namespace FizzyLauncher textBox1.Text = parentForm.CurrentSession.RunCommand ?? string.Empty; } - - - private void button1_Click(object sender, EventArgs e) + private void button1_MouseClick(object sender, MouseEventArgs e) { if (parentForm != null) { diff --git a/PasswordForm.cs b/PasswordForm.cs index 096d1ba..70c01a2 100644 --- a/PasswordForm.cs +++ b/PasswordForm.cs @@ -61,7 +61,7 @@ namespace FizzyLauncher 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); + this.button1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.button1_MouseClick); // // tHorizontalSeparator1 // @@ -121,7 +121,7 @@ namespace FizzyLauncher [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public MainForm ParentForm { get; protected set; } = null; + public new MainForm ParentForm { get; protected set; } = null; [Browsable(false)] public string Password => textBox1.Text; @@ -132,7 +132,7 @@ namespace FizzyLauncher switch (e.KeyCode) { case Keys.Enter: - button1_Click(null, null); + button1_MouseClick(sender, new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); break; case Keys.Escape: this.Close(); @@ -141,10 +141,13 @@ namespace FizzyLauncher } } - private void button1_Click(object sender, EventArgs e) + private void button1_MouseClick(object sender, MouseEventArgs e) { - this.DialogResult = DialogResult.OK; - this.Close(); + if (e.Button == MouseButtons.Left) + { + this.DialogResult = DialogResult.OK; + this.Close(); + } } } diff --git a/RyzStudio/Windows/ThemedForms/TButton.cs b/RyzStudio/Windows/ThemedForms/TButton.cs index 74803bb..e2ce5f0 100644 --- a/RyzStudio/Windows/ThemedForms/TButton.cs +++ b/RyzStudio/Windows/ThemedForms/TButton.cs @@ -56,8 +56,9 @@ }; label1.ImageAlign = ContentAlignment.MiddleCenter; - label1.Click += delegate { this.OnClick(null); }; - label1.MouseEnter += delegate { this.VisualState = ButtonState.Hover; }; + label1.Click += label1_Click; + label1.MouseClick += label1_MouseClick; + label1.MouseEnter += delegate { this.VisualState = ButtonState.Hover; }; label1.MouseLeave += delegate { this.VisualState = ButtonState.Idle; }; label1.MouseDown += delegate { this.VisualState = ButtonState.Down; }; label1.MouseUp += delegate { this.VisualState = ButtonState.Idle; }; @@ -160,11 +161,22 @@ } } + protected ButtonStyle StyleOver { get; set; } = new ButtonStyle(); + protected ButtonStyle StyleDown { get; set; } = new ButtonStyle(); + protected ButtonStyle StyleDefault { get; set; } = new ButtonStyle(); + protected ButtonStyle StyleSelected { get; set; } = new ButtonStyle(); + + private void label1_MouseClick(object sender, MouseEventArgs e) => this.OnMouseClick(e); + + private void label1_Click(object sender, EventArgs e) => this.OnClick(e); + + public void PerformClick() => this.OnClick(null); + } } \ No newline at end of file diff --git a/RyzStudio/Windows/ThemedForms/TButton.designer.cs b/RyzStudio/Windows/ThemedForms/TButton.designer.cs index 5bf79d6..687d7a0 100644 --- a/RyzStudio/Windows/ThemedForms/TButton.designer.cs +++ b/RyzStudio/Windows/ThemedForms/TButton.designer.cs @@ -37,19 +37,20 @@ this.label1.Location = new System.Drawing.Point(4, 4); this.label1.Margin = new System.Windows.Forms.Padding(0); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(121, 25); + this.label1.Size = new System.Drawing.Size(142, 30); this.label1.TabIndex = 0; this.label1.Text = "label1"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // Button + // TButton // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.label1); - this.Name = "Button"; + this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.Name = "TButton"; this.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3); - this.Size = new System.Drawing.Size(128, 32); + this.Size = new System.Drawing.Size(149, 37); this.ResumeLayout(false); } diff --git a/RyzStudio/Windows/ThemedForms/TButton.resx b/RyzStudio/Windows/ThemedForms/TButton.resx index 1af7de1..f298a7b 100644 --- a/RyzStudio/Windows/ThemedForms/TButton.resx +++ b/RyzStudio/Windows/ThemedForms/TButton.resx @@ -1,64 +1,4 @@ - - - +