using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace DACBuilder
{
public delegate void SearchTextEventHandler(object sender, SearchTextEventArgs e);
/// <summary>
/// Summary description for frmFind.
/// </summary>
public class frmFind : System.Windows.Forms.Form
{
private System.Windows.Forms.Label lblFindWhat;
private System.Windows.Forms.TextBox txtFindWhat;
private System.Windows.Forms.Button btnFindNext;
private System.Windows.Forms.CheckBox chkMatchCase;
private System.Windows.Forms.CheckBox chkMatchWholeWord;
private System.Windows.Forms.CheckBox chkSearchUp;
private System.Windows.Forms.Button btnClose;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public event SearchTextEventHandler SearchText;
public frmFind()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lblFindWhat = new System.Windows.Forms.Label();
this.txtFindWhat = new System.Windows.Forms.TextBox();
this.btnFindNext = new System.Windows.Forms.Button();
this.chkMatchCase = new System.Windows.Forms.CheckBox();
this.chkMatchWholeWord = new System.Windows.Forms.CheckBox();
this.chkSearchUp = new System.Windows.Forms.CheckBox();
this.btnClose = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lblFindWhat
//
this.lblFindWhat.Location = new System.Drawing.Point(8, 8);
this.lblFindWhat.Name = "lblFindWhat";
this.lblFindWhat.Size = new System.Drawing.Size(64, 16);
this.lblFindWhat.TabIndex = 0;
this.lblFindWhat.Text = "Fi&nd what:";
//
// txtFindWhat
//
this.txtFindWhat.Location = new System.Drawing.Point(80, 8);
this.txtFindWhat.Name = "txtFindWhat";
this.txtFindWhat.Size = new System.Drawing.Size(208, 20);
this.txtFindWhat.TabIndex = 1;
this.txtFindWhat.Text = "";
//
// btnFindNext
//
this.btnFindNext.Location = new System.Drawing.Point(296, 8);
this.btnFindNext.Name = "btnFindNext";
this.btnFindNext.TabIndex = 2;
this.btnFindNext.Text = "&Find Next";
this.btnFindNext.Click += new System.EventHandler(this.btnFindNext_Click);
//
// chkMatchCase
//
this.chkMatchCase.Location = new System.Drawing.Point(9, 33);
this.chkMatchCase.Name = "chkMatchCase";
this.chkMatchCase.Size = new System.Drawing.Size(104, 16);
this.chkMatchCase.TabIndex = 3;
this.chkMatchCase.Text = "Match &case";
//
// chkMatchWholeWord
//
this.chkMatchWholeWord.Location = new System.Drawing.Point(9, 56);
this.chkMatchWholeWord.Name = "chkMatchWholeWord";
this.chkMatchWholeWord.Size = new System.Drawing.Size(104, 16);
this.chkMatchWholeWord.TabIndex = 4;
this.chkMatchWholeWord.Text = "Match &whole word";
//
// chkSearchUp
//
this.chkSearchUp.Location = new System.Drawing.Point(9, 80);
this.chkSearchUp.Name = "chkSearchUp";
this.chkSearchUp.Size = new System.Drawing.Size(104, 16);
this.chkSearchUp.TabIndex = 5;
this.chkSearchUp.Text = "Search &up";
//
// btnClose
//
this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnClose.Location = new System.Drawing.Point(296, 40);
this.btnClose.Name = "btnClose";
this.btnClose.TabIndex = 6;
this.btnClose.Text = "Close";
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// frmFind
//
this.AcceptButton = this.btnFindNext;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.CancelButton = this.btnClose;
this.ClientSize = new System.Drawing.Size(378, 112);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.chkSearchUp);
this.Controls.Add(this.chkMatchWholeWord);
this.Controls.Add(this.chkMatchCase);
this.Controls.Add(this.btnFindNext);
this.Controls.Add(this.txtFindWhat);
this.Controls.Add(this.lblFindWhat);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "frmFind";
this.ShowInTaskbar = false;
this.Text = "Find";
this.TopMost = true;
this.ResumeLayout(false);
}
#endregion
private void OnSearchText()
{
SearchTextEventArgs e = new SearchTextEventArgs(txtFindWhat.Text, chkMatchCase.Checked, chkMatchWholeWord.Checked, chkSearchUp.Checked);
if(SearchText != null)
{
SearchText(this, e);
}
}
private void btnFindNext_Click(object sender, System.EventArgs e)
{
if(txtFindWhat.Text.Trim() != string.Empty)
{
OnSearchText();
}
}
private void btnClose_Click(object sender, System.EventArgs e)
{
this.Close();
}
}
public class SearchTextEventArgs : EventArgs
{
private string sFindWhat;
private bool bMatchCase;
private bool bMatchWholeWord;
private bool bSearchUp;
public SearchTextEventArgs(string sFindWhat, bool bMatchCase, bool bMatchWholeWord, bool bSearchUp)
{
this.sFindWhat = sFindWhat;
this.bMatchCase = bMatchCase;
this.bMatchWholeWord = bMatchWholeWord;
this.bSearchUp = bSearchUp;
}
public string FindWhat
{
get
{
return this.sFindWhat;
}
}
public bool MatchCase
{
get
{
return this.bMatchCase;
}
}
public bool MatchWholeWord
{
get
{
return this.bMatchWholeWord;
}
}
public bool SearchUp
{
get
{
return this.bSearchUp;
}
}
}
}