Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Encrypting Editor Notepad Replacement

, 28 Jul 2014
A C# .NET 3.5 (Win7) Windows Forms Application with source code
CryptPad-SourceOnly.zip
CryptPad
CryptPad (read-only).lnk
CryptPad.suo
CryptPad
CryptPad.csproj.user
CryptPad.ico
CryptPad.png
Properties
Settings.settings
hack.safe
Script.CryptPad
SendTo.lnk
Settings.lnk
CryptPad.zip
CryptPad (read-only).lnk
CryptPad.suo
CryptPad.csproj.user
CryptPad.ico
CryptPad.png
Settings.settings
hack.safe
Script.CryptPad
SendTo.lnk
Settings.lnk
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 ();
		}

		private void Find_Load (object sender, EventArgs e)
		{
			Crypt_Pad = (CryptPad) this.Owner;
			this.textFind.Text = Crypt_Pad.find_string;
			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.Tag = textFind;
			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.find_string = this.textFind.Text;
			Crypt_Pad.checkBoxMatchCase = this.checkBoxMatchCase.Checked;
			Crypt_Pad.checkBoxRegEx (this.checkBoxRegEx.Checked);
			Crypt_Pad.FindNext (false);
			Crypt_Pad.Position (this);
		}

		private void buttonFind_Click (object sender, EventArgs e)
		{
			Crypt_Pad.find_string = this.textFind.Text;
			Crypt_Pad.checkBoxMatchCase = this.checkBoxMatchCase.Checked;
			Crypt_Pad.checkBoxRegEx (this.checkBoxRegEx.Checked);
			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)
		{
			if (textFind.CanUndo)
				toolStripMenuUndo.Enabled = true;
			else
				toolStripMenuUndo.Enabled = false;
			if (Clipboard.ContainsText ())
				toolStripMenuPaste.Enabled = true;
			else
				toolStripMenuPaste.Enabled = false;
			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 str = textFind.SelectedText;
			str = Crypt_Pad.Unescape (str);
			Clipboard.SetText (str);
			textFind.Paste ("");
		}

		private void toolStripMenuCopy_Click (object sender, EventArgs e)
		{
			string str = textFind.SelectedText;
			str = Crypt_Pad.Unescape (str);
			Clipboard.SetText (str);
		}

		private void toolStripMenuPaste_Click (object sender, EventArgs e)
		{
			string str = Clipboard.GetText ();
			str = Crypt_Pad.Escape (str);
			textFind.Paste (str);
		}

		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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Frank T. Clark
Systems Engineer Three Angels Broadcasting Network
United States United States
I am a 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 employed as Information Technology Staff in the religious satellite broadcasting industry.

| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 28 Jul 2014
Article Copyright 2013 by Frank T. Clark
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid