2017-07-30 11:59:34 +00:00
|
|
|
using System;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
namespace bzit.bomg
|
|
|
|
{
|
|
|
|
public partial class FindForm : Form
|
|
|
|
{
|
|
|
|
private MainForm parentForm = null;
|
|
|
|
private bool findNextNew = false;
|
|
|
|
|
|
|
|
public FindForm(MainForm form)
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
2019-04-22 14:51:03 +00:00
|
|
|
|
|
|
|
textBox1.PreviewKeyDown += textBox1_PreviewKeyDown;
|
|
|
|
textBox1.InnerTextBox.PreviewKeyDown += textBox1_PreviewKeyDown;
|
|
|
|
|
2017-07-30 11:59:34 +00:00
|
|
|
parentForm = form;
|
|
|
|
}
|
|
|
|
|
2019-04-22 14:51:03 +00:00
|
|
|
private void textBox1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
|
|
|
|
{
|
|
|
|
switch (e.KeyCode)
|
|
|
|
{
|
|
|
|
case Keys.Enter:
|
|
|
|
if (findNextNew)
|
|
|
|
{
|
|
|
|
button2_Click(sender, null);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
button1_Click(sender, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case Keys.Escape:
|
|
|
|
this.Close();
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
2017-07-30 11:59:34 +00:00
|
|
|
{
|
|
|
|
if (parentForm == null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-08-28 22:25:49 +00:00
|
|
|
if (string.IsNullOrWhiteSpace(textBox1.Text))
|
2017-07-30 11:59:34 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parentForm.treeView1.Nodes.Count <= 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2019-04-22 14:51:03 +00:00
|
|
|
|
2017-07-30 11:59:34 +00:00
|
|
|
findNextNew = false;
|
2019-04-22 14:51:03 +00:00
|
|
|
parentForm.treeView1.FindTextNode(parentForm.treeView1.Nodes[0], textBox1.Text?.Trim());
|
2017-07-30 11:59:34 +00:00
|
|
|
}
|
|
|
|
|
2019-04-22 14:51:03 +00:00
|
|
|
private void button2_Click(object sender, EventArgs e)
|
2017-07-30 11:59:34 +00:00
|
|
|
{
|
|
|
|
if (parentForm == null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-08-28 22:25:49 +00:00
|
|
|
if (string.IsNullOrWhiteSpace(textBox1.Text))
|
2017-07-30 11:59:34 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parentForm.treeView1.Nodes.Count <= 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parentForm.treeView1.SelectedNode == null)
|
|
|
|
{
|
|
|
|
parentForm.treeView1.SelectedNode = parentForm.treeView1.Nodes[0];
|
|
|
|
}
|
2019-04-22 14:51:03 +00:00
|
|
|
|
2017-07-30 11:59:34 +00:00
|
|
|
findNextNew = false;
|
|
|
|
|
2019-04-22 14:51:03 +00:00
|
|
|
bool rv = parentForm.treeView1.SNode.FindTextNode(textBox1.Text?.Trim());
|
2017-07-30 11:59:34 +00:00
|
|
|
if (!rv)
|
|
|
|
{
|
|
|
|
findNextNew = true;
|
|
|
|
}
|
|
|
|
}
|
2020-08-28 22:05:59 +00:00
|
|
|
|
2017-07-30 11:59:34 +00:00
|
|
|
}
|
|
|
|
}
|