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

📄 prefsform.cs

📁 一个使用.NET Framework开发的、免费的、开发源码的下载管理程序.
💻 CS
字号:
/************************************************************
	
PrefsForm.cs

Form that lets the user define various settings referenced
throughout the application

Revision history:
	November 28, 2000 by Joe Hardy
		- File created
	Late June - 6 July, 2000 by Joe Hardy
		- Cut all the code across to work with beta 2

************************************************************/

using System;
using System.Windows.Forms;
using System.Drawing;

class PrefsForm : Form {
	CheckBox chkUseProxy = new CheckBox();
	Label lblProxyHost = new Label();
	TextBox txtProxyHostname = new TextBox();
	TextBox txtProxyPort = new TextBox();
	Label lblPortColon = new Label();
	Button cmdOK = new Button();
	Button cmdCancel = new Button();

	public PrefsForm() {
		this.FormBorderStyle=FormBorderStyle.FixedDialog;
		this.Size = new Size(300, 150);
		this.Text = "Preferences";
		this.Font = new Font(new FontFamily("Tahoma"), 8);
		this.MaximizeBox = false;
		this.MinimizeBox = false;
		this.AcceptButton = cmdOK;
		this.CancelButton = cmdCancel;

		chkUseProxy.Text = "Use Proxy Server";
		chkUseProxy.Location = new Point(8, 8);
		chkUseProxy.Size = new Size(150, 15);
		chkUseProxy.Click += new EventHandler(this.chkUseProxy_Click);
		chkUseProxy.Checked = (AppSettings.GetSetting("UseProxy") == "True");

		lblProxyHost.Text = "HTTP Proxy:";
		lblProxyHost.Location = new Point(8, 35);
		lblProxyHost.AutoSize = true;

		txtProxyHostname.Location = new Point(lblProxyHost.Left + lblProxyHost.Width + 6, 35);
		txtProxyHostname.Width = 150;
		txtProxyHostname.Text = AppSettings.GetSetting("ProxyHostname");
		
		txtProxyPort.Width = 30;
		txtProxyPort.Location = new Point(txtProxyHostname.Left + txtProxyHostname.Width + 12, 35);
		txtProxyPort.Text = AppSettings.GetSetting("ProxyPort");

		lblPortColon.Location = new Point(txtProxyHostname.Left + txtProxyHostname.Width + 3, 35);
		lblPortColon.AutoSize = true;
		lblPortColon.Text = ":";
		
		txtProxyPort.Enabled=txtProxyHostname.Enabled=chkUseProxy.Checked;

		cmdOK.Text = "&OK";
		cmdOK.Location = new Point(8, 70);
		cmdOK.Click += new EventHandler(this.cmdOK_Click);

		cmdCancel.Text = "&Cancel";
		cmdCancel.Location = new Point(90, 70);

		this.Controls.Add(chkUseProxy);
		this.Controls.Add(lblProxyHost);
		this.Controls.Add(txtProxyHostname);
		this.Controls.Add(lblPortColon);
		this.Controls.Add(txtProxyPort);
		this.Controls.Add(cmdOK);
		this.Controls.Add(cmdCancel);
	}

	private void cmdOK_Click(Object Src, EventArgs e) {
		if (chkUseProxy.Checked && (txtProxyHostname.Text == "" || txtProxyPort.Text == "")) {
			MessageBox.Show("One or more fields weren't completed.");
			return;
		}
		
		AppSettings.SaveSetting("UseProxy", chkUseProxy.Checked.ToString());
		AppSettings.SaveSetting("ProxyHostname", txtProxyHostname.Text);
		AppSettings.SaveSetting("ProxyPort", txtProxyPort.Text);

		this.Close();
		this.Dispose();
		return;
	}

	private void chkUseProxy_Click(Object Src, EventArgs e) {
		txtProxyHostname.Enabled=txtProxyPort.Enabled=chkUseProxy.Checked;
	}
}

⌨️ 快捷键说明

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