WIP: find form

This commit is contained in:
Ray 2021-09-12 15:25:37 +01:00
parent bbbd85380e
commit d2ef12b134
9 changed files with 322 additions and 79 deletions

View File

@ -105,6 +105,9 @@
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DependentUpon>AppResource.resx</DependentUpon> <DependentUpon>AppResource.resx</DependentUpon>
</Compile> </Compile>
<Compile Update="FindForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="PasswordForm.cs"> <Compile Update="PasswordForm.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>

219
FindForm.cs Normal file
View File

@ -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;
}
}
}
}
}

60
FindForm.resx Normal file
View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -25,6 +25,7 @@ namespace FizzyLauncher
protected OptionsForm optionsForm = null; protected OptionsForm optionsForm = null;
protected FindForm findForm = null;
protected AppMode appMode = AppMode.Clear; protected AppMode appMode = AppMode.Clear;
protected string sessionFilename = null; protected string sessionFilename = null;
@ -386,7 +387,13 @@ namespace FizzyLauncher
/// <param name="e"></param> /// <param name="e"></param>
private void findToolStripMenuItem_Click(object sender, EventArgs e) private void findToolStripMenuItem_Click(object sender, EventArgs e)
{ {
//tileContainer1.Add(); if (this.IsBusy)
{
return;
}
if (findForm == null) findForm = new FindForm(this, treeView1);
findForm.Show();
} }

View File

@ -85,7 +85,7 @@ namespace FizzyLauncher
this.button1.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3); this.button1.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3);
this.button1.Size = new System.Drawing.Size(128, 32); this.button1.Size = new System.Drawing.Size(128, 32);
this.button1.TabIndex = 173; 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 // pickerBox1
// //
@ -280,9 +280,7 @@ namespace FizzyLauncher
textBox1.Text = parentForm.CurrentSession.RunCommand ?? string.Empty; textBox1.Text = parentForm.CurrentSession.RunCommand ?? string.Empty;
} }
private void button1_MouseClick(object sender, MouseEventArgs e)
private void button1_Click(object sender, EventArgs e)
{ {
if (parentForm != null) if (parentForm != null)
{ {

View File

@ -61,7 +61,7 @@ namespace FizzyLauncher
this.button1.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3); this.button1.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3);
this.button1.Size = new System.Drawing.Size(128, 32); this.button1.Size = new System.Drawing.Size(128, 32);
this.button1.TabIndex = 173; 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 // tHorizontalSeparator1
// //
@ -121,7 +121,7 @@ namespace FizzyLauncher
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public MainForm ParentForm { get; protected set; } = null; public new MainForm ParentForm { get; protected set; } = null;
[Browsable(false)] [Browsable(false)]
public string Password => textBox1.Text; public string Password => textBox1.Text;
@ -132,7 +132,7 @@ namespace FizzyLauncher
switch (e.KeyCode) switch (e.KeyCode)
{ {
case Keys.Enter: case Keys.Enter:
button1_Click(null, null); button1_MouseClick(sender, new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0));
break; break;
case Keys.Escape: case Keys.Escape:
this.Close(); 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; if (e.Button == MouseButtons.Left)
this.Close(); {
this.DialogResult = DialogResult.OK;
this.Close();
}
} }
} }

View File

@ -56,8 +56,9 @@
}; };
label1.ImageAlign = ContentAlignment.MiddleCenter; label1.ImageAlign = ContentAlignment.MiddleCenter;
label1.Click += delegate { this.OnClick(null); }; label1.Click += label1_Click;
label1.MouseEnter += delegate { this.VisualState = ButtonState.Hover; }; label1.MouseClick += label1_MouseClick;
label1.MouseEnter += delegate { this.VisualState = ButtonState.Hover; };
label1.MouseLeave += delegate { this.VisualState = ButtonState.Idle; }; label1.MouseLeave += delegate { this.VisualState = ButtonState.Idle; };
label1.MouseDown += delegate { this.VisualState = ButtonState.Down; }; label1.MouseDown += delegate { this.VisualState = ButtonState.Down; };
label1.MouseUp += delegate { this.VisualState = ButtonState.Idle; }; label1.MouseUp += delegate { this.VisualState = ButtonState.Idle; };
@ -160,11 +161,22 @@
} }
} }
protected ButtonStyle StyleOver { get; set; } = new ButtonStyle(); protected ButtonStyle StyleOver { get; set; } = new ButtonStyle();
protected ButtonStyle StyleDown { get; set; } = new ButtonStyle(); protected ButtonStyle StyleDown { get; set; } = new ButtonStyle();
protected ButtonStyle StyleDefault { get; set; } = new ButtonStyle(); protected ButtonStyle StyleDefault { get; set; } = new ButtonStyle();
protected ButtonStyle StyleSelected { 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); public void PerformClick() => this.OnClick(null);
} }
} }

View File

@ -37,19 +37,20 @@
this.label1.Location = new System.Drawing.Point(4, 4); this.label1.Location = new System.Drawing.Point(4, 4);
this.label1.Margin = new System.Windows.Forms.Padding(0); this.label1.Margin = new System.Windows.Forms.Padding(0);
this.label1.Name = "label1"; 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.TabIndex = 0;
this.label1.Text = "label1"; this.label1.Text = "label1";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; 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.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.label1); 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.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); this.ResumeLayout(false);
} }

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <root>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">