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

📄 connectionbar.cs

📁 ftp上传的c#程序. ftp上传的c#程序.
💻 CS
字号:
namespace FTP.View.VisibleControls 
{
	using System;
	using System.Windows.Forms;
	using System.Drawing;
	using FTP.Model.DataStructures;

	internal class ConnectionBar : AbstractPanel 
	{
		private HandleUserGestures  handleUserGestures;
		private int horizontalPosition = 0; // Used to space components

		// Input fields
		internal TextBox  tbServerAddress;
		internal TextBox  tbServerPort;
		internal TextBox  tbUserName;
		internal TextBox  tbPassword;
		private  Label    lbServerAddress;
		private  Label    lbServerPort;
		private  Label    lbUserName;
		private  Label    lbPassword;
		private  Button   bConnect;

		// Constructor
		internal ConnectionBar(HandleUserGestures pHandleUserGestures) 
		{
			this.handleUserGestures  = pHandleUserGestures;
			this.Size = new Size(900,23);
/*
			tbServerAddress = createHorizontalTextBox("194.151.255.141", 15, 80);
			tbServerPort    = createHorizontalTextBox("21", 5, 30);
			tbUserName      = createHorizontalTextBox("anonymous", 20, 80);
			tbPassword      = createHorizontalTextBox("john@bbc.com", 20, 80);
	*/
			lbServerAddress = createHorizontalLabel("Server Address", 100);
			tbServerAddress = createHorizontalTextBox("127.0.0.1", 15, 80);
			lbServerPort    = createHorizontalLabel("Server Port", 80);
			tbServerPort    = createHorizontalTextBox("21", 5, 30);
			lbUserName      = createHorizontalLabel("User Name", 75);
			tbUserName      = createHorizontalTextBox("paul", 20, 80);
			lbPassword      = createHorizontalLabel("Password", 70);
			tbPassword      = createHorizontalTextBox("paul", 20, 80);
			tbPassword.PasswordChar = '*';
			bConnect        = new Button();
			bConnect.Text   = "Connect";
			bConnect.Name   = "Connect";
			bConnect.Location = new Point(this.horizontalPosition + 7, 0);
			bConnect.Click += new System.EventHandler (this.buttonClick);
			this.Controls.AddRange(new Control[] {
													 lbServerAddress,tbServerAddress,lbServerPort,tbServerPort,
													 lbUserName, tbUserName, lbPassword, tbPassword, bConnect});
		}

		// method to create a Label
		private Label createHorizontalLabel(string pText, int pWidth) 
		{
			Label rLabel = new Label();
			rLabel.Text = pText;
			rLabel.Location = new Point(horizontalPosition, 0);
			rLabel.Size     = new Size(pWidth, 20);
			rLabel.Font = new System.Drawing.Font ("Arial", 10, System.Drawing.FontStyle.Regular);
			rLabel.BackColor = System.Drawing.SystemColors.Control;
			rLabel.TextAlign = ContentAlignment.MiddleRight;
			horizontalPosition += pWidth;
			return (rLabel);
		}

		// method to create a Text Box
		private TextBox createHorizontalTextBox(string pText, int pLength, int pWidth) 
		{
			TextBox rTextBox   = new TextBox ();
			rTextBox.Location  = new Point(horizontalPosition, 0);
			rTextBox.Size      = new Size(pWidth, 20);
			rTextBox.ReadOnly  = false;
			rTextBox.Text      = pText;
			rTextBox.MaxLength = pLength;
			rTextBox.Font      = new System.Drawing.Font ("Arial", 10, System.Drawing.FontStyle.Regular);
			rTextBox.BackColor = System.Drawing.SystemColors.Window;
			rTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
			horizontalPosition += pWidth + 5;
			return (rTextBox);
		}

		private void buttonClick (object sender, System.EventArgs e) 
		{
      
			// Determine which button the user clicked on
			//			Button	lxButton		= (Button)sender;
			//      switch (lxButton.Name.ToUpper()) {
			//      case "CONNECT":
			//        userGesture.command = "CONNECT";
			//        break;
			//      }
  
			string messageToView = "CONNECT";
			handleUserGestures.handleUserGesture(messageToView);
			//ftpController.processUserGesture(userGesture);
		}
		
		// IViewComonentInterface methods  
		public override void AcceptModelChanges(ModelViewState ftpViewState) 
		{
		}

		public override void ExtractUserChanges(ref ModelViewState pFtpViewState) 
		{
			pFtpViewState.serverAddress  = tbServerAddress.Text;
			pFtpViewState.serverPort     = Convert.ToInt32(tbServerPort.Text);
			pFtpViewState.userName       = tbUserName.Text;
			pFtpViewState.password       = tbPassword.Text;
		}
	}
}

⌨️ 快捷键说明

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