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

📄 config.cs

📁 自定义协议
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;

namespace CodeManager
{
	/// <summary>
	/// Config 的摘要说明。
	/// </summary>
	public class Config : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.Button OK;
		private System.Windows.Forms.Button CANCEL;
		private System.Windows.Forms.TextBox Cfg_Box;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Config()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.panel1 = new System.Windows.Forms.Panel();
			this.CANCEL = new System.Windows.Forms.Button();
			this.OK = new System.Windows.Forms.Button();
			this.Cfg_Box = new System.Windows.Forms.TextBox();
			this.panel1.SuspendLayout();
			this.SuspendLayout();
			// 
			// panel1
			// 
			this.panel1.Controls.Add(this.CANCEL);
			this.panel1.Controls.Add(this.OK);
			this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.panel1.Location = new System.Drawing.Point(0, 249);
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(292, 24);
			this.panel1.TabIndex = 0;
			// 
			// CANCEL
			// 
			this.CANCEL.Dock = System.Windows.Forms.DockStyle.Right;
			this.CANCEL.Location = new System.Drawing.Point(188, 0);
			this.CANCEL.Name = "CANCEL";
			this.CANCEL.Size = new System.Drawing.Size(104, 24);
			this.CANCEL.TabIndex = 1;
			this.CANCEL.Text = "取消";
			this.CANCEL.Click += new System.EventHandler(this.CANCEL_Click);
			// 
			// OK
			// 
			this.OK.Dock = System.Windows.Forms.DockStyle.Left;
			this.OK.Location = new System.Drawing.Point(0, 0);
			this.OK.Name = "OK";
			this.OK.Size = new System.Drawing.Size(88, 24);
			this.OK.TabIndex = 0;
			this.OK.Text = "确定";
			this.OK.Click += new System.EventHandler(this.OK_Click);
			// 
			// Cfg_Box
			// 
			this.Cfg_Box.Dock = System.Windows.Forms.DockStyle.Fill;
			this.Cfg_Box.Location = new System.Drawing.Point(0, 0);
			this.Cfg_Box.Multiline = true;
			this.Cfg_Box.Name = "Cfg_Box";
			this.Cfg_Box.Size = new System.Drawing.Size(292, 249);
			this.Cfg_Box.TabIndex = 3;
			this.Cfg_Box.Text = "";
			// 
			// Config
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(292, 273);
			this.Controls.Add(this.Cfg_Box);
			this.Controls.Add(this.panel1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.Name = "Config";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			this.Text = "设置";
			this.Load += new System.EventHandler(this.Config_Load);
			this.panel1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void Config_Load(object sender, System.EventArgs e)
		{
			lock(typeof(MainForm))
			{
				
				using (StreamReader sr = new StreamReader(MainForm.cfFile)) 
				{
					char []buf = new char[1024];
					sr.Read(buf, 0, buf.Length);
					Cfg_Box.Text = new String(buf);
				}
			}
		}

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

		private void OK_Click(object sender, System.EventArgs e)
		{
			lock(typeof(MainForm))
			{
				using (StreamWriter sw = new StreamWriter(MainForm.cfFile, false)) 
				{
					sw.Write(Cfg_Box.Text);
				}
			}
			this.Close();
		}
	}
}

⌨️ 快捷键说明

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