ch_text.Focused) search_text.Text=SEARCH_BOX_DEFTEXT;
out_richText.Clear ();
XMLPATH= raquo ;;
this.Text=MAINFORM_HEAD_TEXT;
allNodes_toolStripDropDownButton.Enabled=false;
}
//********************************************* *****************************
#endregion
private void search_button_Click (object sender, EventArgs e)
{
if (HASH.ContainsKey (search_text.Text))
{
out_richText.Rtf=new StringModificator ((string) HASH [search_text.Text]). Modify ();
}
}
private void out_richText_LinkClicked (object sender, LinkClickedEventArgs e)
{
Process.Start (e.LinkText);
}
private void search_text_TextChanged (object sender, EventArgs e)
{
if (HASH.Count == 0) return;
listbox.Items.Clear ();
if (search_text.Text!= amp; amp; search_text.Text!=SEARCH_BOX_DEFTEXT)
{
int height=0, count=0;
foreach (object O in HASH.Keys)
{
if (O.ToString (). ToLower (). IndexOf (search_text.Text.ToLower ()) gt;=0)
{
if (++ count gt; 5) break;
listbox.Items.Add (O);
height +=25;
}
}
listbox.Size=new Size (listbox.Size.Width, height);
if (listbox.Items.Count gt; 0)
{
listbox_panel.Show ();
listbox.SelectedItem=listbox.Items [0];
}
else
{
listbox_panel.Hide ();
}
}
else
{
listbox_panel.Hide ();
}
}
private void search_text_SizeChanged (object sender, EventArgs e)
{
listbox.Size=new Size (search_text.Size.Width, listbox.Size.Height);
}
private void search_text_Enter (object sender, EventArgs e)
{
if (search_text.Text == SEARCH_BOX_DEFTEXT)
{
search_text.Text= raquo ;;
}
search_text.ForeColor=Color.Black;
}
private void search_text_Leave (object sender, EventArgs e)
{
if (search_text.Text == )
{
search_text.Text=SEARCH_BOX_DEFTEXT;
}
search_text.ForeColor=Color.Gray;
}
private void search_text_KeyDown (object sender, KeyEventArgs e)
{
if (HASH.Count == 0 || listbox.Items.Count == 0) return;
if (e.KeyCode == Keys.Down)
{
if (listbox.SelectedIndex lt; listbox.Items.Count - 1)
listbox.SelectedIndex=listbox.SelectedIndex + 1;
}
if (e.KeyCode == Keys.Up)
{
if (listbox.SelectedIndex!=0)
listbox.SelectedIndex=listbox.SelectedIndex - 1;
}
if (e.KeyCode == Keys.Enter)
{
search_text.Text=listbox.SelectedItem.ToString ();
search_button_Click (sender, e);
out_richText.Focus ();
listbox_panel.Hide ();
}
if (e.KeyCode == Keys.Escape)
{
listbox_panel.Hide ();
}
}
private void listbox_MouseClick (object sender, MouseEventArgs e)
{
if (HASH.Count == 0 || listbox.Items.Count == 0) return;
search_text.Text=listbox.SelectedItem.ToString ();
search_button_Click (sender, e);
out_richText.Focus ();
listbox_panel.Hide ();
}
private void allNodes_toolStripDropDownButton_DropDownItemClicked (object sender, ToolStripItemClickedEventArgs e)
{
if (HASH.ContainsKey (e.ClickedItem.Text))
out_richText.Rtf=new StringModificator ((string) HASH [e.ClickedItem.Text]). Modify ();
}
}
}
Файл add_form.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace HashSearchEngine
{
public partial class add_form: Form
{
public add_form ()
{
InitializeComponent ();
}
private void save_button_Click (object sender, EventArgs e)
{
main_form.AddXMLNode (key_text.Text, value_text.Text);
}
private void plus_button_Click (object sender, EventArgs e)
{
main_form.AddXMLNode (key_text.Text, value_text.Text);
key_text.Clear ();
value_text.Clear ();
toolTip1.Show (
Стаття успішно додана ,
this,
new Point (this.Size.Width/2 + 50, this.Size.Height/2),
...