Click here to Skip to main content
15,891,184 members
Articles / Programming Languages / C#

Check Help Links Tool

Rate me:
Please Sign up or sign in to vote.
4.97/5 (13 votes)
6 Oct 2005CPOL6 min read 85.9K   17.3K   34  
A tool to check links across merged help (CHM) files.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace CheckHelpLinks
{
	/// <summary>
	/// Summary description for DlgFind.
	/// </summary>
	public class DlgFind : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.CheckBox _FindState;
		private System.Windows.Forms.CheckBox _FindStateUnknown;
		private System.Windows.Forms.CheckBox _FindStateHttp;
		private System.Windows.Forms.CheckBox _FindStateGood;
		private System.Windows.Forms.CheckBox _FindStateBroken;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.Button _FindNext;
		private System.Windows.Forms.Button _FindPrev;
		private System.Windows.Forms.Button _Cancel;
		private System.Windows.Forms.GroupBox groupBox2;
		private System.Windows.Forms.CheckBox _FindStringLink;
		private System.Windows.Forms.CheckBox _FindStringNot;
		private System.Windows.Forms.TextBox _FindStringExpression;
		private System.Windows.Forms.CheckBox _FindStringIgnoreCase;
		private System.Windows.Forms.GroupBox groupBox3;
		private System.Windows.Forms.CheckBox _FindClass;
		private System.Windows.Forms.CheckBox _FindClassTOC;
		private System.Windows.Forms.CheckBox _FindClassIndex;
		private System.Windows.Forms.CheckBox _FindClassChm;
		private System.Windows.Forms.CheckBox _FindClassHtml;
		private System.Windows.Forms.CheckBox _FindClassLink;
		private System.Windows.Forms.CheckBox _FindClassAnchor;
		private System.Windows.Forms.Label _FindStringRegexLabel;
		private System.Windows.Forms.CheckBox _FindStateScript;

		private FindParameters _Parameters = null;

		private FindDirection _Direction = FindDirection.Next;

		public FindDirection Direction { get { return _Direction; } }

		public DlgFind( FindParameters parameters )
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			_Parameters = parameters;
		}

		/// <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()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(DlgFind));
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this._FindStateBroken = new System.Windows.Forms.CheckBox();
			this._FindStateGood = new System.Windows.Forms.CheckBox();
			this._FindStateHttp = new System.Windows.Forms.CheckBox();
			this._FindStateUnknown = new System.Windows.Forms.CheckBox();
			this._FindState = new System.Windows.Forms.CheckBox();
			this._FindStateScript = new System.Windows.Forms.CheckBox();
			this._FindNext = new System.Windows.Forms.Button();
			this._FindPrev = new System.Windows.Forms.Button();
			this._Cancel = new System.Windows.Forms.Button();
			this.groupBox2 = new System.Windows.Forms.GroupBox();
			this._FindStringExpression = new System.Windows.Forms.TextBox();
			this._FindStringRegexLabel = new System.Windows.Forms.Label();
			this._FindStringNot = new System.Windows.Forms.CheckBox();
			this._FindStringLink = new System.Windows.Forms.CheckBox();
			this._FindStringIgnoreCase = new System.Windows.Forms.CheckBox();
			this.groupBox3 = new System.Windows.Forms.GroupBox();
			this._FindClassLink = new System.Windows.Forms.CheckBox();
			this._FindClassHtml = new System.Windows.Forms.CheckBox();
			this._FindClassChm = new System.Windows.Forms.CheckBox();
			this._FindClassIndex = new System.Windows.Forms.CheckBox();
			this._FindClassTOC = new System.Windows.Forms.CheckBox();
			this._FindClass = new System.Windows.Forms.CheckBox();
			this._FindClassAnchor = new System.Windows.Forms.CheckBox();
			this.groupBox1.SuspendLayout();
			this.groupBox2.SuspendLayout();
			this.groupBox3.SuspendLayout();
			this.SuspendLayout();
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this._FindStateBroken);
			this.groupBox1.Controls.Add(this._FindStateGood);
			this.groupBox1.Controls.Add(this._FindStateHttp);
			this.groupBox1.Controls.Add(this._FindStateUnknown);
			this.groupBox1.Controls.Add(this._FindState);
			this.groupBox1.Controls.Add(this._FindStateScript);
			this.groupBox1.Location = new System.Drawing.Point(192, 8);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(168, 208);
			this.groupBox1.TabIndex = 1;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "State";
			// 
			// _FindStateBroken
			// 
			this._FindStateBroken.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this._FindStateBroken.Location = new System.Drawing.Point(56, 152);
			this._FindStateBroken.Name = "_FindStateBroken";
			this._FindStateBroken.TabIndex = 5;
			this._FindStateBroken.Text = "Broken";
			// 
			// _FindStateGood
			// 
			this._FindStateGood.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this._FindStateGood.Location = new System.Drawing.Point(56, 56);
			this._FindStateGood.Name = "_FindStateGood";
			this._FindStateGood.TabIndex = 1;
			this._FindStateGood.Text = "Good";
			// 
			// _FindStateHttp
			// 
			this._FindStateHttp.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this._FindStateHttp.Location = new System.Drawing.Point(56, 104);
			this._FindStateHttp.Name = "_FindStateHttp";
			this._FindStateHttp.TabIndex = 3;
			this._FindStateHttp.Text = "Http";
			// 
			// _FindStateUnknown
			// 
			this._FindStateUnknown.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this._FindStateUnknown.Location = new System.Drawing.Point(56, 80);
			this._FindStateUnknown.Name = "_FindStateUnknown";
			this._FindStateUnknown.TabIndex = 2;
			this._FindStateUnknown.Text = "Unknown";
			// 
			// _FindState
			// 
			this._FindState.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this._FindState.Location = new System.Drawing.Point(16, 24);
			this._FindState.Name = "_FindState";
			this._FindState.TabIndex = 0;
			this._FindState.Text = "Find by State";
			this._FindState.CheckedChanged += new System.EventHandler(this._FindState_CheckedChanged);
			// 
			// _FindStateScript
			// 
			this._FindStateScript.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this._FindStateScript.Location = new System.Drawing.Point(56, 128);
			this._FindStateScript.Name = "_FindStateScript";
			this._FindStateScript.TabIndex = 4;
			this._FindStateScript.Text = "Script";
			// 
			// _FindNext
			// 
			this._FindNext.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this._FindNext.Location = new System.Drawing.Point(104, 392);
			this._FindNext.Name = "_FindNext";
			this._FindNext.TabIndex = 3;
			this._FindNext.Text = "Find Next";
			this._FindNext.Click += new System.EventHandler(this._FindNext_Click);
			// 
			// _FindPrev
			// 
			this._FindPrev.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this._FindPrev.Location = new System.Drawing.Point(192, 392);
			this._FindPrev.Name = "_FindPrev";
			this._FindPrev.TabIndex = 4;
			this._FindPrev.Text = "Find Prev";
			this._FindPrev.Click += new System.EventHandler(this._FindPrev_Click);
			// 
			// _Cancel
			// 
			this._Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this._Cancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this._Cancel.Location = new System.Drawing.Point(280, 392);
			this._Cancel.Name = "_Cancel";
			this._Cancel.TabIndex = 5;
			this._Cancel.Text = "Cancel";
			// 
			// groupBox2
			// 
			this.groupBox2.Controls.Add(this._FindStringExpression);
			this.groupBox2.Controls.Add(this._FindStringRegexLabel);
			this.groupBox2.Controls.Add(this._FindStringNot);
			this.groupBox2.Controls.Add(this._FindStringLink);
			this.groupBox2.Controls.Add(this._FindStringIgnoreCase);
			this.groupBox2.Location = new System.Drawing.Point(8, 224);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(352, 160);
			this.groupBox2.TabIndex = 2;
			this.groupBox2.TabStop = false;
			this.groupBox2.Text = "Link";
			// 
			// _FindStringExpression
			// 
			this._FindStringExpression.Location = new System.Drawing.Point(48, 112);
			this._FindStringExpression.Name = "_FindStringExpression";
			this._FindStringExpression.Size = new System.Drawing.Size(288, 20);
			this._FindStringExpression.TabIndex = 4;
			this._FindStringExpression.Text = "";
			// 
			// _FindStringRegexLabel
			// 
			this._FindStringRegexLabel.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this._FindStringRegexLabel.Location = new System.Drawing.Point(48, 88);
			this._FindStringRegexLabel.Name = "_FindStringRegexLabel";
			this._FindStringRegexLabel.Size = new System.Drawing.Size(152, 23);
			this._FindStringRegexLabel.TabIndex = 3;
			this._FindStringRegexLabel.Text = "Regular Expression :";
			// 
			// _FindStringNot
			// 
			this._FindStringNot.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this._FindStringNot.Location = new System.Drawing.Point(48, 56);
			this._FindStringNot.Name = "_FindStringNot";
			this._FindStringNot.Size = new System.Drawing.Size(56, 24);
			this._FindStringNot.TabIndex = 1;
			this._FindStringNot.Text = "Not";
			// 
			// _FindStringLink
			// 
			this._FindStringLink.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this._FindStringLink.Location = new System.Drawing.Point(16, 24);
			this._FindStringLink.Name = "_FindStringLink";
			this._FindStringLink.TabIndex = 0;
			this._FindStringLink.Text = "Find by Link";
			this._FindStringLink.CheckedChanged += new System.EventHandler(this._FindStringLink_CheckedChanged);
			// 
			// _FindStringIgnoreCase
			// 
			this._FindStringIgnoreCase.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this._FindStringIgnoreCase.Location = new System.Drawing.Point(112, 56);
			this._FindStringIgnoreCase.Name = "_FindStringIgnoreCase";
			this._FindStringIgnoreCase.TabIndex = 2;
			this._FindStringIgnoreCase.Text = "Ignore Case";
			// 
			// groupBox3
			// 
			this.groupBox3.Controls.Add(this._FindClassLink);
			this.groupBox3.Controls.Add(this._FindClassHtml);
			this.groupBox3.Controls.Add(this._FindClassChm);
			this.groupBox3.Controls.Add(this._FindClassIndex);
			this.groupBox3.Controls.Add(this._FindClassTOC);
			this.groupBox3.Controls.Add(this._FindClass);
			this.groupBox3.Controls.Add(this._FindClassAnchor);
			this.groupBox3.Location = new System.Drawing.Point(8, 8);
			this.groupBox3.Name = "groupBox3";
			this.groupBox3.Size = new System.Drawing.Size(168, 208);
			this.groupBox3.TabIndex = 0;
			this.groupBox3.TabStop = false;
			this.groupBox3.Text = "Class";
			// 
			// _FindClassLink
			// 
			this._FindClassLink.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this._FindClassLink.Location = new System.Drawing.Point(56, 176);
			this._FindClassLink.Name = "_FindClassLink";
			this._FindClassLink.TabIndex = 5;
			this._FindClassLink.Text = "Link";
			// 
			// _FindClassHtml
			// 
			this._FindClassHtml.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this._FindClassHtml.Location = new System.Drawing.Point(56, 128);
			this._FindClassHtml.Name = "_FindClassHtml";
			this._FindClassHtml.TabIndex = 4;
			this._FindClassHtml.Text = "Html";
			// 
			// _FindClassChm
			// 
			this._FindClassChm.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this._FindClassChm.Location = new System.Drawing.Point(56, 104);
			this._FindClassChm.Name = "_FindClassChm";
			this._FindClassChm.TabIndex = 3;
			this._FindClassChm.Text = "Chm";
			// 
			// _FindClassIndex
			// 
			this._FindClassIndex.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this._FindClassIndex.Location = new System.Drawing.Point(56, 80);
			this._FindClassIndex.Name = "_FindClassIndex";
			this._FindClassIndex.TabIndex = 2;
			this._FindClassIndex.Text = "Index";
			// 
			// _FindClassTOC
			// 
			this._FindClassTOC.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this._FindClassTOC.Location = new System.Drawing.Point(56, 56);
			this._FindClassTOC.Name = "_FindClassTOC";
			this._FindClassTOC.TabIndex = 1;
			this._FindClassTOC.Text = "TOC";
			// 
			// _FindClass
			// 
			this._FindClass.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this._FindClass.Location = new System.Drawing.Point(16, 24);
			this._FindClass.Name = "_FindClass";
			this._FindClass.TabIndex = 0;
			this._FindClass.Text = "Find by Class";
			this._FindClass.CheckedChanged += new System.EventHandler(this._FindClass_CheckedChanged);
			// 
			// _FindClassAnchor
			// 
			this._FindClassAnchor.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this._FindClassAnchor.Location = new System.Drawing.Point(56, 152);
			this._FindClassAnchor.Name = "_FindClassAnchor";
			this._FindClassAnchor.TabIndex = 5;
			this._FindClassAnchor.Text = "Anchor";
			// 
			// DlgFind
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(370, 424);
			this.Controls.Add(this.groupBox3);
			this.Controls.Add(this.groupBox2);
			this.Controls.Add(this._Cancel);
			this.Controls.Add(this._FindPrev);
			this.Controls.Add(this._FindNext);
			this.Controls.Add(this.groupBox1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "DlgFind";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			this.Text = "Find";
			this.Load += new System.EventHandler(this.DlgFind_Load);
			this.groupBox1.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			this.groupBox3.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void DlgFind_Load( object sender, System.EventArgs e )
		{
			_FindClass       .Checked = _Parameters.FindClass      ;
			_FindClassTOC    .Checked = _Parameters.FindClassTOC   ;
			_FindClassIndex  .Checked = _Parameters.FindClassIndex ;
			_FindClassChm    .Checked = _Parameters.FindClassChm   ;
			_FindClassHtml   .Checked = _Parameters.FindClassHtml  ;
			_FindClassAnchor .Checked = _Parameters.FindClassAnchor;
			_FindClassLink   .Checked = _Parameters.FindClassLink  ;

			_FindState        .Checked = _Parameters.FindState        ;
			_FindStateUnknown .Checked = _Parameters.FindStateUnknown ;
			_FindStateHttp    .Checked = _Parameters.FindStateHttp    ;
			_FindStateScript  .Checked = _Parameters.FindStateScript  ;
			_FindStateGood    .Checked = _Parameters.FindStateGood    ;
			_FindStateBroken  .Checked = _Parameters.FindStateBroken  ;

			_FindStringLink          .Checked = _Parameters.FindStringLink       ;
			_FindStringNot           .Checked = _Parameters.FindStringNot        ;
			_FindStringIgnoreCase    .Checked = _Parameters.FindStringIgnoreCase ;
			_FindStringExpression    .Text    = _Parameters.FindStringExpression ;

			_FindClass_CheckedChanged( null, null );
			_FindState_CheckedChanged( null, null );
			_FindStringLink_CheckedChanged( null, null );
		}

		private void _FindClass_CheckedChanged(object sender, System.EventArgs e)
		{
			bool b = ( _FindClass.Checked );

			_FindClassTOC   .Enabled = b;
			_FindClassIndex .Enabled = b;
			_FindClassChm   .Enabled = b;
			_FindClassHtml  .Enabled = b;
			_FindClassAnchor.Enabled = b;
			_FindClassLink  .Enabled = b;
		}

		private void _FindState_CheckedChanged( object sender, System.EventArgs e )
		{
			bool b = ( _FindState.Checked );

			_FindStateUnknown .Enabled = b;
			_FindStateHttp    .Enabled = b;
			_FindStateScript  .Enabled = b;
			_FindStateGood    .Enabled = b;
			_FindStateBroken  .Enabled = b;
	
		}

		private void _FindStringLink_CheckedChanged( object sender, System.EventArgs e )
		{
			bool b = ( _FindStringLink.Checked );

			_FindStringNot           .Enabled = b;
			_FindStringIgnoreCase    .Enabled = b;
			_FindStringRegexLabel    .Enabled = b;
			_FindStringExpression    .Enabled = b;
		}

		private void _FindNext_Click( object sender, System.EventArgs e )
		{
			_Direction = FindDirection.Next;
			OnOk();
		}

		private void _FindPrev_Click( object sender, System.EventArgs e )
		{
			_Direction = FindDirection.Previous;
			OnOk();
		}

		private void OnOk()
		{
			_Parameters.FindClass      = _FindClass       .Checked ;
			_Parameters.FindClassTOC   = _FindClassTOC    .Checked ;
			_Parameters.FindClassIndex = _FindClassIndex  .Checked ;
			_Parameters.FindClassChm   = _FindClassChm    .Checked ;
			_Parameters.FindClassHtml  = _FindClassHtml   .Checked ;
			_Parameters.FindClassAnchor= _FindClassAnchor .Checked ;
			_Parameters.FindClassLink  = _FindClassLink   .Checked ;

			_Parameters.FindState        = _FindState        .Checked;
			_Parameters.FindStateUnknown = _FindStateUnknown .Checked;
			_Parameters.FindStateHttp    = _FindStateHttp    .Checked;
			_Parameters.FindStateScript  = _FindStateScript  .Checked;
			_Parameters.FindStateGood    = _FindStateGood    .Checked;
			_Parameters.FindStateBroken  = _FindStateBroken  .Checked;

			_Parameters.FindStringLink       = _FindStringLink          .Checked ;
			_Parameters.FindStringNot        = _FindStringNot           .Checked ;
			_Parameters.FindStringIgnoreCase = _FindStringIgnoreCase    .Checked ;
			_Parameters.FindStringExpression = _FindStringExpression    .Text    ;

			DialogResult = DialogResult.OK;
		}
	}
}

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)


Written By
United Kingdom United Kingdom
I discovered C# and .NET 1.0 Beta 1 in late 2000 and loved them immediately.
I have been writing software professionally in C# ever since

In real life, I have spent 3 years travelling abroad,
I have held a UK Private Pilots Licence for 20 years,
and I am a PADI Divemaster.

I now live near idyllic Bournemouth in England.

I can work 'virtually' anywhere!

Comments and Discussions