Click here to Skip to main content
15,895,538 members
Articles / Programming Languages / C#

VSEDebug - VS.NET Debugging Enhancement

Rate me:
Please Sign up or sign in to vote.
4.92/5 (37 votes)
25 Apr 20049 min read 170K   2.2K   58  
VSEDebug is a VS.NET debugger add-in that adds the ability to debug complex types in simpler form.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace vsedebug
{
	/// <summary>
	/// Summary description for VSEDebugSettings.
	/// </summary>
	public class VSEDebugSettings : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Button SettingsOK;
		private System.Windows.Forms.Button SettingsCancel;
		private System.Windows.Forms.NumericUpDown ItemsPerDivisionNode;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.RadioButton NoDelay;
		private System.Windows.Forms.RadioButton Delay;
		private System.Windows.Forms.NumericUpDown DelayInMS;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.RadioButton ManualUpdate;
		public VSEUtil.DelayMode DMode;
		public int DelayInMillsecs;
		public int ItemsPerDivision;
		public int LinesAboveTP;
		public int LinesBelowTP;
		public System.Drawing.Font DFont;
		private System.Windows.Forms.GroupBox groupBox2;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.NumericUpDown LinesBelow;
		private System.Windows.Forms.NumericUpDown LinesAbove;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.Button FontButton;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public VSEDebugSettings(VSEUtil.DelayMode mode, int delay, int itemsperdivision, int linesabove, int linesbelow)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			switch (mode)
			{
				case VSEUtil.DelayMode.none:
					NoDelay.Checked = true;
					break;
				case VSEUtil.DelayMode.manualupdate:
					ManualUpdate.Checked = true;
					break;
				case VSEUtil.DelayMode.delay:
					Delay.Checked = true;
					break;
			}
			DMode = mode;
			DelayInMillsecs = delay;
			DelayInMS.Value = delay;
			ItemsPerDivision = itemsperdivision;
			ItemsPerDivisionNode.Value = itemsperdivision;
			LinesAbove.Value = linesabove;
			LinesAboveTP = linesabove;
			LinesBelow.Value = linesbelow;
			LinesBelowTP = linesbelow;
		}

		/// <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.label1 = new System.Windows.Forms.Label();
			this.SettingsOK = new System.Windows.Forms.Button();
			this.SettingsCancel = new System.Windows.Forms.Button();
			this.ItemsPerDivisionNode = new System.Windows.Forms.NumericUpDown();
			this.label2 = new System.Windows.Forms.Label();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.ManualUpdate = new System.Windows.Forms.RadioButton();
			this.label3 = new System.Windows.Forms.Label();
			this.DelayInMS = new System.Windows.Forms.NumericUpDown();
			this.Delay = new System.Windows.Forms.RadioButton();
			this.NoDelay = new System.Windows.Forms.RadioButton();
			this.groupBox2 = new System.Windows.Forms.GroupBox();
			this.label6 = new System.Windows.Forms.Label();
			this.label5 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.LinesBelow = new System.Windows.Forms.NumericUpDown();
			this.LinesAbove = new System.Windows.Forms.NumericUpDown();
			this.FontButton = new System.Windows.Forms.Button();
			((System.ComponentModel.ISupportInitialize)(this.ItemsPerDivisionNode)).BeginInit();
			this.groupBox1.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.DelayInMS)).BeginInit();
			this.groupBox2.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.LinesBelow)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.LinesAbove)).BeginInit();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(16, 16);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(408, 40);
			this.label1.TabIndex = 0;
			this.label1.Text = "Use this dialog box to set the various properties of the VSE Debug add-in";
			// 
			// SettingsOK
			// 
			this.SettingsOK.Location = new System.Drawing.Point(448, 16);
			this.SettingsOK.Name = "SettingsOK";
			this.SettingsOK.Size = new System.Drawing.Size(104, 32);
			this.SettingsOK.TabIndex = 1;
			this.SettingsOK.Text = "OK";
			this.SettingsOK.Click += new System.EventHandler(this.SettingsOK_Click);
			// 
			// SettingsCancel
			// 
			this.SettingsCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.SettingsCancel.Location = new System.Drawing.Point(448, 56);
			this.SettingsCancel.Name = "SettingsCancel";
			this.SettingsCancel.Size = new System.Drawing.Size(104, 32);
			this.SettingsCancel.TabIndex = 2;
			this.SettingsCancel.Text = "Cancel";
			this.SettingsCancel.Click += new System.EventHandler(this.SettingsCancel_Click);
			// 
			// ItemsPerDivisionNode
			// 
			this.ItemsPerDivisionNode.Location = new System.Drawing.Point(16, 64);
			this.ItemsPerDivisionNode.Minimum = new System.Decimal(new int[] {
																				 2,
																				 0,
																				 0,
																				 0});
			this.ItemsPerDivisionNode.Name = "ItemsPerDivisionNode";
			this.ItemsPerDivisionNode.Size = new System.Drawing.Size(64, 22);
			this.ItemsPerDivisionNode.TabIndex = 3;
			this.ItemsPerDivisionNode.Value = new System.Decimal(new int[] {
																			   10,
																			   0,
																			   0,
																			   0});
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(88, 64);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(152, 23);
			this.label2.TabIndex = 4;
			this.label2.Text = "Items per Division Node";
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.ManualUpdate,
																					this.label3,
																					this.DelayInMS,
																					this.Delay,
																					this.NoDelay});
			this.groupBox1.Location = new System.Drawing.Point(16, 232);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(424, 248);
			this.groupBox1.TabIndex = 5;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Updates";
			// 
			// ManualUpdate
			// 
			this.ManualUpdate.Checked = true;
			this.ManualUpdate.Location = new System.Drawing.Point(16, 208);
			this.ManualUpdate.Name = "ManualUpdate";
			this.ManualUpdate.Size = new System.Drawing.Size(168, 24);
			this.ManualUpdate.TabIndex = 4;
			this.ManualUpdate.TabStop = true;
			this.ManualUpdate.Text = "Manual Update";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(16, 32);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(392, 136);
			this.label3.TabIndex = 3;
			this.label3.Text = @"Since the add-in isn't the fastest thing to use in the world, unavoidably, it can be useful to set a delay to the update.  This delay ensures that when rapidly stepping through code, the control will not update until you have stopped stepping through code and the specified number of milliseconds has passed.  The manual update button will keep the windows from updating at all, until a specific key is pressed, which at that time, they will all update.  This will keep processor usage to a minimum until you need the addin the most.  The update key is f2";
			// 
			// DelayInMS
			// 
			this.DelayInMS.Increment = new System.Decimal(new int[] {
																		10,
																		0,
																		0,
																		0});
			this.DelayInMS.Location = new System.Drawing.Point(272, 208);
			this.DelayInMS.Maximum = new System.Decimal(new int[] {
																	  10000,
																	  0,
																	  0,
																	  0});
			this.DelayInMS.Minimum = new System.Decimal(new int[] {
																	  1,
																	  0,
																	  0,
																	  0});
			this.DelayInMS.Name = "DelayInMS";
			this.DelayInMS.Size = new System.Drawing.Size(56, 22);
			this.DelayInMS.TabIndex = 2;
			this.DelayInMS.Value = new System.Decimal(new int[] {
																	100,
																	0,
																	0,
																	0});
			// 
			// Delay
			// 
			this.Delay.Location = new System.Drawing.Point(256, 184);
			this.Delay.Name = "Delay";
			this.Delay.Size = new System.Drawing.Size(152, 24);
			this.Delay.TabIndex = 1;
			this.Delay.Text = "Delay In Millseconds:";
			// 
			// NoDelay
			// 
			this.NoDelay.Location = new System.Drawing.Point(16, 184);
			this.NoDelay.Name = "NoDelay";
			this.NoDelay.TabIndex = 0;
			this.NoDelay.Text = "No Delay";
			// 
			// groupBox2
			// 
			this.groupBox2.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.label6,
																					this.label5,
																					this.label4,
																					this.LinesBelow,
																					this.LinesAbove});
			this.groupBox2.Location = new System.Drawing.Point(16, 96);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(424, 120);
			this.groupBox2.TabIndex = 6;
			this.groupBox2.TabStop = false;
			this.groupBox2.Text = "Autos Parsing";
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(80, 56);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(240, 23);
			this.label6.TabIndex = 4;
			this.label6.Text = "Current line";
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(80, 80);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(240, 23);
			this.label5.TabIndex = 3;
			this.label5.Text = "Lines below current line to parse";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(80, 32);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(240, 23);
			this.label4.TabIndex = 2;
			this.label4.Text = "Lines above current line to parse";
			// 
			// LinesBelow
			// 
			this.LinesBelow.Location = new System.Drawing.Point(16, 80);
			this.LinesBelow.Name = "LinesBelow";
			this.LinesBelow.Size = new System.Drawing.Size(56, 22);
			this.LinesBelow.TabIndex = 1;
			// 
			// LinesAbove
			// 
			this.LinesAbove.Location = new System.Drawing.Point(16, 32);
			this.LinesAbove.Name = "LinesAbove";
			this.LinesAbove.Size = new System.Drawing.Size(56, 22);
			this.LinesAbove.TabIndex = 0;
			// 
			// FontButton
			// 
			this.FontButton.Location = new System.Drawing.Point(16, 496);
			this.FontButton.Name = "FontButton";
			this.FontButton.Size = new System.Drawing.Size(104, 32);
			this.FontButton.TabIndex = 7;
			this.FontButton.Text = "Font...";
			this.FontButton.Click += new System.EventHandler(this.FontButton_Click);
			// 
			// VSEDebugSettings
			// 
			this.AcceptButton = this.SettingsOK;
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
			this.CancelButton = this.SettingsCancel;
			this.ClientSize = new System.Drawing.Size(566, 539);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.FontButton,
																		  this.groupBox2,
																		  this.groupBox1,
																		  this.label2,
																		  this.ItemsPerDivisionNode,
																		  this.SettingsCancel,
																		  this.SettingsOK,
																		  this.label1});
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "VSEDebugSettings";
			this.Text = "VSEDebug Settings";
			this.Load += new System.EventHandler(this.VSEDebugSettings_Load);
			((System.ComponentModel.ISupportInitialize)(this.ItemsPerDivisionNode)).EndInit();
			this.groupBox1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.DelayInMS)).EndInit();
			this.groupBox2.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.LinesBelow)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.LinesAbove)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void SettingsOK_Click(object sender, System.EventArgs e)
		{
			ItemsPerDivision = (int)ItemsPerDivisionNode.Value;
			DelayInMillsecs = (int)DelayInMS.Value;
			LinesAboveTP = (int)LinesAbove.Value;
			LinesBelowTP = (int)LinesBelow.Value;
			if(NoDelay.Checked == true)
			{
				DMode = VSEUtil.DelayMode.none;
			}
			if(ManualUpdate.Checked == true)
			{
				DMode = VSEUtil.DelayMode.manualupdate;
			}
			if(Delay.Checked == true)
			{
				DMode = VSEUtil.DelayMode.delay;
			}
			this.Close();
		}

		private void SettingsCancel_Click(object sender, System.EventArgs e)
		{
			DelayInMillsecs = -1;
			ItemsPerDivision = -1;
			this.Close();
		}

		private void VSEDebugSettings_Load(object sender, System.EventArgs e)
		{
		
		}

		private void FontButton_Click(object sender, System.EventArgs e)
		{
			System.Windows.Forms.FontDialog fdialog = new System.Windows.Forms.FontDialog();
			fdialog.Font = VSEUtil.DisplayFont;

			if( fdialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
			{
				DFont = fdialog.Font;
				if(VSEUtil.VSDebugger.CurrentMode != EnvDTE.dbgDebugMode.dbgDesignMode)
					MessageBox.Show("Any font changes made will not manifest until the debugger is restarted.");
			}
		}
	}
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
I'm a student at the University of Florida studying computer engineering.

You may find additional information about vsedebug at http://vsedebug.sourceforge.net

Comments and Discussions