|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace CryptPad
{
public partial class Find : Form
{
CryptPad Crypt_Pad;
public Find ()
{
InitializeComponent ();
this.Font = SystemFonts.MessageBoxFont;
}
private void Find_Load (object sender, EventArgs e)
{
Crypt_Pad = (CryptPad) this.Owner;
this.textFind.Text = Crypt_Pad.find_string;
comboBoxPatterns.Tag = textFind;
this.checkBoxRegEx.Checked = null != Crypt_Pad.find_regex;
this.comboBoxPatterns.SelectedIndexChanged += new System.EventHandler (Crypt_Pad.comboBoxPatterns_SelectedIndexChanged);
this.comboBoxPatterns.Click += new System.EventHandler (Crypt_Pad.comboBoxPatterns_Click);
UpdateFindNextButton ();
Crypt_Pad.Position (this);
}
private void Find_FormClosed (object sender, FormClosedEventArgs e)
{
Crypt_Pad.find_Form = null;
}
private void textFind_Enter (object sender, EventArgs e)
{
comboBoxPatterns.Items.Clear ();
comboBoxPatterns.Items.AddRange (Crypt_Pad.combo_search);
comboBoxPatterns.Items.AddRange (Crypt_Pad.combo_base);
if (checkBoxRegEx.Checked)
comboBoxPatterns.Items.AddRange (Crypt_Pad.combo_regex_find);
comboBoxPatterns.Text = (string) comboBoxPatterns.Items[0];
}
private void textFind_TextChanged (object sender, EventArgs e)
{
UpdateFindNextButton ();
}
private void checkBoxRegEx_CheckedChanged (object sender, EventArgs e)
{
((TextBox) comboBoxPatterns.Tag).Focus ();
}
private void UpdateFindNextButton ()
{
buttonFind.Enabled = textFind.Text.Length > 0;
buttonFindPrevious.Enabled = textFind.Text.Length > 0;
}
private void buttonFindPrevious_Click (object sender, EventArgs e)
{
Crypt_Pad.checkBoxMatchCase = this.checkBoxMatchCase.Checked;
if (Crypt_Pad.checkBoxRegEx (this.checkBoxRegEx.Checked, this.textFind.Text))
return;
Crypt_Pad.FindNext (false);
Crypt_Pad.Position (this);
}
private void buttonFind_Click (object sender, EventArgs e)
{
Crypt_Pad.checkBoxMatchCase = this.checkBoxMatchCase.Checked;
if (Crypt_Pad.checkBoxRegEx (this.checkBoxRegEx.Checked, this.textFind.Text))
return;
Crypt_Pad.FindNext (true);
Crypt_Pad.Position (this);
}
private void buttonCancel_Click (object sender, EventArgs e)
{
this.Close ();
}
private void contextMenuStrip_Opening (object sender, CancelEventArgs e)
{
toolStripMenuUndo.Enabled = textFind.CanUndo;
toolStripMenuPaste.Enabled = Clipboard.ContainsText ();
if (0 < textFind.SelectionLength)
{
toolStripMenuCut.Enabled = true;
toolStripMenuCopy.Enabled = true;
toolStripMenuDelete.Enabled = true;
}
else
{
toolStripMenuCut.Enabled = false;
toolStripMenuCopy.Enabled = false;
toolStripMenuDelete.Enabled = false;
}
}
private void toolStripMenuUndo_Click (object sender, EventArgs e)
{
textFind.Undo ();
}
private void toolStripMenuCut_Click (object sender, EventArgs e)
{
string s = textFind.SelectedText;
if (!checkBoxRegEx.Checked)
s = Crypt_Pad.Unescape (s);
Clipboard.SetText (s);
textFind.Paste ("");
}
private void toolStripMenuCopy_Click (object sender, EventArgs e)
{
string s = textFind.SelectedText;
if (!checkBoxRegEx.Checked)
s = Crypt_Pad.Unescape (s);
Clipboard.SetText (s);
}
private void toolStripMenuPaste_Click (object sender, EventArgs e)
{
string s = Clipboard.GetText ();
if (!checkBoxRegEx.Checked)
s = Crypt_Pad.Escape (s);
textFind.Paste (s);
}
private void toolStripMenuDelete_Click (object sender, EventArgs e)
{
if (0 == textFind.SelectionLength)
textFind.SelectionLength = 1;
textFind.Paste ("");
}
private void toolStripMenuSelectAll_Click (object sender, EventArgs e)
{
textFind.SelectAll ();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am a retired Software Systems Design Engineer experienced with IEEE standards and the entire IEEE software development life cycle. Concept Exploration, Requirements, Design, Implementation, Test, Installation and Checkout, Operation and Maintenance. I enjoy working with people and solving customer problems.
I am currently a writer for my personal ministry: IAUA End Time Ministry