⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmexception.cs

📁 LLBLGen 1.21 Sourcecode
💻 CS
字号:
//////////////////////////////////////////////////////////////////////
// Part of LLBLGen sourcecode. See version information
//////////////////////////////////////////////////////////////////////
// COPYRIGHTS:
// Copyright (c)2002 Solutions Design. All rights reserved.
// 
// Released under the following license: (BSD2)
// -------------------------------------------
// Redistribution and use in source and binary forms, with or without modification, 
// are permitted provided that the following conditions are met: 
//
// 1) Redistributions of source code must retain the above copyright notice, this list of 
//    conditions and the following disclaimer. 
// 2) Redistributions in binary form must reproduce the above copyright notice, this list of 
//    conditions and the following disclaimer in the documentation and/or other materials 
//    provided with the distribution. 
// 
// THIS SOFTWARE IS PROVIDED BY SOLUTIONS DESIGN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOLUTIONS DESIGN OR CONTRIBUTORS BE LIABLE FOR 
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
//
// The views and conclusions contained in the software and documentation are those of the authors 
// and should not be interpreted as representing official policies, either expressed or implied, 
// of Solutions Design. 
//
//////////////////////////////////////////////////////////////////////
// Contributers to the code:
//		- Frans Bouma [FB]
//////////////////////////////////////////////////////////////////////

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace LLBLGen
{
	/// <summary>
	/// Purpose: general exception viewer.
	/// </summary>
	public class frmException : System.Windows.Forms.Form
	{
		#region Class Member Declaration
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.Button btnClose;
		private Exception m_exException;
		private System.Windows.Forms.TextBox tbxSource;
		private System.Windows.Forms.RichTextBox tbxStackTrace;
		private System.Windows.Forms.RichTextBox tbxMessage;
		private System.ComponentModel.Container components = null;
		#endregion

		public frmException()
		{
			InitializeComponent();
		}

		public frmException(Exception exException)
		{
			InitializeComponent();
			m_exException = exException;
			ViewExceptionInWindow();
		}


		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		
		/// <summary>
		/// Purpose: will load the private membervariable m_kexException's data
		/// into the windows' controls and thus view it. Set m_kexException with the
		/// property kexException.
		/// </summary>
		public void ViewExceptionInWindow()
		{
			if(m_exException==null)
			{
				// no exception loaded
				tbxMessage.Text = "No exception loaded into window: can't visualize exception";
				return;
			}
			// visualize the exception.
			tbxStackTrace.SelectionBullet=true;
			tbxMessage.SelectionBullet=true;
			tbxMessage.Text += m_exException.Message + Environment.NewLine;
			tbxSource.Text += m_exException.Source + Environment.NewLine;
			tbxStackTrace.Text += m_exException.StackTrace + Environment.NewLine;
			// go into the inner exceptions.
			for(Exception exInnerException = m_exException.InnerException;
				exInnerException!=null;exInnerException = exInnerException.InnerException)
			{
				tbxMessage.Text += exInnerException.Message + Environment.NewLine;
				tbxSource.Text += exInnerException.Source + Environment.NewLine;
				tbxStackTrace.Text += exInnerException.StackTrace + Environment.NewLine;
			}
			// strip extra newline from boxes
			tbxMessage.Text = tbxMessage.Text.Substring(0,tbxMessage.Text.Length-2);
			tbxSource.Text = tbxSource.Text.Substring(0,tbxSource.Text.Length-2);
			tbxStackTrace.Text = tbxStackTrace.Text.Substring(0,tbxStackTrace.Text.Length-2);
		}

		#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.groupBox1 = new System.Windows.Forms.GroupBox();
			this.tbxMessage = new System.Windows.Forms.RichTextBox();
			this.tbxStackTrace = new System.Windows.Forms.RichTextBox();
			this.tbxSource = new System.Windows.Forms.TextBox();
			this.label6 = new System.Windows.Forms.Label();
			this.label5 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.btnClose = new System.Windows.Forms.Button();
			this.groupBox1.SuspendLayout();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.BackColor = System.Drawing.Color.White;
			this.label1.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label1.Location = new System.Drawing.Point(4, 8);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(392, 32);
			this.label1.TabIndex = 0;
			this.label1.Text = "An exception occured. Below is the general information about this exception. Clic" +
				"k Close to close this window to resume.";
			// 
			// groupBox1
			// 
			this.groupBox1.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.tbxMessage,
																					this.tbxStackTrace,
																					this.tbxSource,
																					this.label6,
																					this.label5,
																					this.label4});
			this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.groupBox1.Location = new System.Drawing.Point(4, 54);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(394, 372);
			this.groupBox1.TabIndex = 1;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = ".NET Exception information";
			// 
			// tbxMessage
			// 
			this.tbxMessage.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.tbxMessage.BulletIndent = 10;
			this.tbxMessage.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.tbxMessage.Location = new System.Drawing.Point(8, 36);
			this.tbxMessage.Name = "tbxMessage";
			this.tbxMessage.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedVertical;
			this.tbxMessage.Size = new System.Drawing.Size(380, 88);
			this.tbxMessage.TabIndex = 2;
			this.tbxMessage.Text = "";
			// 
			// tbxStackTrace
			// 
			this.tbxStackTrace.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.tbxStackTrace.BulletIndent = 10;
			this.tbxStackTrace.CausesValidation = false;
			this.tbxStackTrace.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.tbxStackTrace.Location = new System.Drawing.Point(8, 148);
			this.tbxStackTrace.Name = "tbxStackTrace";
			this.tbxStackTrace.ReadOnly = true;
			this.tbxStackTrace.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedVertical;
			this.tbxStackTrace.Size = new System.Drawing.Size(380, 139);
			this.tbxStackTrace.TabIndex = 3;
			this.tbxStackTrace.Text = "";
			// 
			// tbxSource
			// 
			this.tbxSource.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.tbxSource.BackColor = System.Drawing.SystemColors.Window;
			this.tbxSource.Location = new System.Drawing.Point(8, 311);
			this.tbxSource.Multiline = true;
			this.tbxSource.Name = "tbxSource";
			this.tbxSource.ReadOnly = true;
			this.tbxSource.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
			this.tbxSource.Size = new System.Drawing.Size(378, 52);
			this.tbxSource.TabIndex = 4;
			this.tbxSource.Text = "";
			// 
			// label6
			// 
			this.label6.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label6.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.label6.Location = new System.Drawing.Point(8, 295);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(60, 16);
			this.label6.TabIndex = 4;
			this.label6.Text = "Source";
			// 
			// label5
			// 
			this.label5.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.label5.Location = new System.Drawing.Point(8, 132);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(188, 16);
			this.label5.TabIndex = 2;
			this.label5.Text = "Stack trace";
			// 
			// label4
			// 
			this.label4.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.label4.Location = new System.Drawing.Point(8, 20);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(64, 16);
			this.label4.TabIndex = 0;
			this.label4.Text = "Message";
			// 
			// label3
			// 
			this.label3.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.label3.BackColor = System.Drawing.Color.White;
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(404, 48);
			this.label3.TabIndex = 3;
			// 
			// btnClose
			// 
			this.btnClose.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
			this.btnClose.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.btnClose.Location = new System.Drawing.Point(174, 432);
			this.btnClose.Name = "btnClose";
			this.btnClose.Size = new System.Drawing.Size(48, 24);
			this.btnClose.TabIndex = 5;
			this.btnClose.Text = "Close";
			this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
			// 
			// frmException
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(404, 462);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.btnClose,
																		  this.label1,
																		  this.label3,
																		  this.groupBox1});
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "frmException";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Exception Viewer";
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void btnClose_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}
		
		/// <summary>
		/// Purpose: sets the membervariable m_exException which is visualized
		/// in the windows controls using ViewExceptionInWindow()
		/// </summary>
		public Exception exException
		{
			set
			{
				m_exException = value;
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -