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

📄 frmlogfile.cs

📁 本论文叙述了联机考试系统的现状以及C#语言的概况。重点介绍了联机考试系统的实现过程:包括系统分析、 系统调查、 数据流程分析、功能设计、 数据库设计、 系统物理配置方案、 系统实现、 系统测试和调试。
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;

namespace SupermarketProject
{
	/// <summary>
	/// Summary description for frmLogFile.
	/// </summary>
	public class frmLogFile : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label lblLogFile;
		private System.Windows.Forms.Button btnShowLogFile;
		private System.Windows.Forms.Button btnExit;
		private System.Windows.Forms.RichTextBox rtbLogFile;
		private System.ComponentModel.IContainer components;
		private System.Windows.Forms.HelpProvider hlpLogFile;
		private System.Windows.Forms.ToolTip tipLogFile;
		private string logFilePath;
		
		public frmLogFile(string logFilePath)
		{

			this.logFilePath = logFilePath;
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
            this.hlpLogFile.HelpNamespace=@"..\..\HELP\SupermarketHelp.chm"; 
			//
			// TODO: Add any constructor code after InitializeComponent call
			//

		}
		

		/// <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.components = new System.ComponentModel.Container();
			this.lblLogFile = new System.Windows.Forms.Label();
			this.btnShowLogFile = new System.Windows.Forms.Button();
			this.btnExit = new System.Windows.Forms.Button();
			this.rtbLogFile = new System.Windows.Forms.RichTextBox();
			this.hlpLogFile = new System.Windows.Forms.HelpProvider();
			this.tipLogFile = new System.Windows.Forms.ToolTip(this.components);
			this.SuspendLayout();
			// 
			// lblLogFile
			// 
			this.lblLogFile.Location = new System.Drawing.Point(278, 17);
			this.lblLogFile.Name = "lblLogFile";
			this.lblLogFile.Size = new System.Drawing.Size(68, 25);
			this.lblLogFile.TabIndex = 0;
			this.lblLogFile.Text = "日志文件";
			this.lblLogFile.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// btnShowLogFile
			// 
			this.btnShowLogFile.Location = new System.Drawing.Point(307, 362);
			this.btnShowLogFile.Name = "btnShowLogFile";
			this.btnShowLogFile.Size = new System.Drawing.Size(163, 25);
			this.btnShowLogFile.TabIndex = 2;
			this.btnShowLogFile.Text = "显示其他日志文件(&S)";
			this.btnShowLogFile.Click += new System.EventHandler(this.btnShowLogFile_Click);
			this.btnShowLogFile.MouseHover += new System.EventHandler(this.btnShowLogFile_MouseHover);
			// 
			// btnExit
			// 
			this.btnExit.Location = new System.Drawing.Point(518, 362);
			this.btnExit.Name = "btnExit";
			this.btnExit.Size = new System.Drawing.Size(90, 25);
			this.btnExit.TabIndex = 3;
			this.btnExit.Text = "退出(&E)";
			this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
			// 
			// rtbLogFile
			// 
			this.rtbLogFile.Location = new System.Drawing.Point(29, 43);
			this.rtbLogFile.Name = "rtbLogFile";
			this.rtbLogFile.ReadOnly = true;
			this.rtbLogFile.Size = new System.Drawing.Size(595, 284);
			this.rtbLogFile.TabIndex = 1;
			this.rtbLogFile.Text = "";
			this.rtbLogFile.WordWrap = false;
			// 
			// tipLogFile
			// 
			this.tipLogFile.AutomaticDelay = 150;
			// 
			// frmLogFile
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(652, 393);
			this.Controls.Add(this.rtbLogFile);
			this.Controls.Add(this.btnExit);
			this.Controls.Add(this.btnShowLogFile);
			this.Controls.Add(this.lblLogFile);
			this.Name = "frmLogFile";
			this.Text = "日志文件";
			this.Load += new System.EventHandler(this.frmLogFile_Load);
			this.ResumeLayout(false);

		}
		#endregion

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

			if (this.logFilePath != "")
			{
				Stream stream = new FileStream(logFilePath,FileMode.Open,
					FileAccess.Read, FileShare.Read);
				rtbLogFile.LoadFile(stream,RichTextBoxStreamType.PlainText);
			}			


			//rtbLogFile.LoadFile(logFilePath,RichTextBoxStreamType.PlainText);
			
		}

		private void btnExit_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void btnShowLogFile_Click(object sender, System.EventArgs e)
		{
			//create a folderbrowserdialog instance and filedialog instance
			FolderBrowserDialog fbdLogFileFolder = new FolderBrowserDialog();			               OpenFileDialog ofdlgLogFile = new OpenFileDialog();

			ofdlgLogFile.DefaultExt = ".txt";
			ofdlgLogFile.Filter = "文本文件 (*.txt)|*.txt";
		
			fbdLogFileFolder.Description = 
				"选择要用作默认值的目录。";
            // Do not allow the user to create new files via the FolderBrowserDialog.
			fbdLogFileFolder.ShowNewFolderButton = false;

			DialogResult dresult = fbdLogFileFolder.ShowDialog();
			if(dresult == DialogResult.OK)
			{
				ofdlgLogFile.InitialDirectory = fbdLogFileFolder.SelectedPath;
				ofdlgLogFile.FileName = null;
			}

			// Display the openFile dialog.
			DialogResult result = ofdlgLogFile.ShowDialog();

			// OK button was pressed.
			if(result == DialogResult.OK) 
			{
				logFilePath = ofdlgLogFile.FileName;
				
				// Output the requested file in richTextBox1.
				Stream stream = ofdlgLogFile.OpenFile();
				rtbLogFile.LoadFile(stream,RichTextBoxStreamType.PlainText);
				stream.Close();    
			}
		}

		private void btnShowLogFile_MouseHover(object sender, System.EventArgs e)
		{
			this.tipLogFile.SetToolTip(this.btnShowLogFile,"这将允许选择查看其他的日志文件");	

		}
	}
}

⌨️ 快捷键说明

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