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

📄 frmshare.cs

📁 一个p2p的c#版源码
💻 CS
📖 第 1 页 / 共 2 页
字号:

		/// <summary>
		/// This is also a user defined constructor called from the
		/// Search button to view the search results
		/// This constructor is called from within this code only
		/// it is used to pass any type of request if needed at the time of
		/// its construction
		/// </summary>
		/// <param name="Computername stores the name of the computer to connect"> </param>
		/// <param name="Request stores what type of request you want to send to the listener"> </param>
		/// <param name="Scope scope value needed, if any"> </param>
		/// <param name="Mask mask value needed if any"> </param>
		public frmShare(string Computername, string Request, string Scope, string Mask)
		{
            // Required for Windows Form Designer support
			// This line is not auto generated, instead it has been copied from
			// default constructor
            InitializeComponent();

			// Puts the Computer.ico as the form icon
			this.Icon = new System.Drawing.Icon(Application.StartupPath + "\\Computer.ico");
			
			// COMPUTERNAME is a global variable used to store the name
			// and IP Address of the computer to which you are currently
			// connected
			COMPUTERNAME = Computername;
			
			// Open connection is a user defined function responsible for
			// opening a socket connection for listener. This function
			// returns a bool value
			if( OpenConnection(COMPUTERNAME) )
			{
				// Creates an XML request with scope and mask
				CreateRequest(Request,Scope,Mask);
				
				// Sends this request to listener
				SendDataToListener(REQUESTFILE);
				
				// get the response from listener
				GetDataFromListener(RESPONSEFILE);
				
				// Parse that response for records and show those records
				Parsing(RESPONSEFILE);
				
				// Closes the active connection
				CloseConnection();
				
				// Assign scope to sText local variable
				string sText = Scope;
				
				// Extract the name of the PARENTFOLDER
				sText = sText.Substring(0, sText.LastIndexOf("\\")+1);
				
				// changes the caption of this dialog box
				this.Text = sText + " on '" + Computername + "'";
				
				// Assign the value for PARENTFOLDER
				PARENTFOLDER = sText;
				
				// Changes the text of the status bar
				sBar.Text = sText;
			}
		}

		/// <summary>
        ///    Clean up any resources being used.
        ///    auto generated function by IDE
        /// </summary>
        public override void Dispose()
        {
            base.Dispose();
            components.Dispose();
        }

        /// <summary>
        ///    Required method for Designer support - do not modify
        ///    the contents of this method with the code editor.
        ///    These are also auto generated lines of code
        /// </summary>
        private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			this.clhType = new System.Windows.Forms.ColumnHeader();
			this.toolTipText = new System.Windows.Forms.ToolTip(this.components);
			this.btnClose = new System.Windows.Forms.Button();
			this.btnSearch = new System.Windows.Forms.Button();
			this.btnUpload = new System.Windows.Forms.Button();
			this.btnDownload = new System.Windows.Forms.Button();
			this.lvFiles = new System.Windows.Forms.ListView();
			this.clhFilename = new System.Windows.Forms.ColumnHeader();
			this.clhFileSize = new System.Windows.Forms.ColumnHeader();
			this.sBar = new System.Windows.Forms.StatusBar();
			this.FileOpenDialog = new System.Windows.Forms.OpenFileDialog();
			this.FileSaveDialog = new System.Windows.Forms.SaveFileDialog();
			this.lblCopyright = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// clhType
			// 
			this.clhType.Text = "Type";
			this.clhType.Width = 108;
			// 
			// btnClose
			// 
			this.btnClose.BackColor = System.Drawing.Color.Chocolate;
			this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnClose.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnClose.ForeColor = System.Drawing.Color.White;
			this.btnClose.Location = new System.Drawing.Point(217, 5);
			this.btnClose.Name = "btnClose";
			this.btnClose.Size = new System.Drawing.Size(71, 31);
			this.btnClose.TabIndex = 3;
			this.btnClose.Text = "&Close";
			this.toolTipText.SetToolTip(this.btnClose, "Exist from this window");
			this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
			// 
			// btnSearch
			// 
			this.btnSearch.BackColor = System.Drawing.Color.Chocolate;
			this.btnSearch.Enabled = false;
			this.btnSearch.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnSearch.ForeColor = System.Drawing.Color.White;
			this.btnSearch.Location = new System.Drawing.Point(146, 5);
			this.btnSearch.Name = "btnSearch";
			this.btnSearch.Size = new System.Drawing.Size(71, 31);
			this.btnSearch.TabIndex = 2;
			this.btnSearch.Text = "&Search";
			this.toolTipText.SetToolTip(this.btnSearch, "Search for file(s) or folder(s)");
			this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
			// 
			// btnUpload
			// 
			this.btnUpload.BackColor = System.Drawing.Color.Chocolate;
			this.btnUpload.Enabled = false;
			this.btnUpload.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnUpload.ForeColor = System.Drawing.Color.White;
			this.btnUpload.Location = new System.Drawing.Point(4, 5);
			this.btnUpload.Name = "btnUpload";
			this.btnUpload.Size = new System.Drawing.Size(71, 31);
			this.btnUpload.TabIndex = 0;
			this.btnUpload.Text = "&Upload";
			this.toolTipText.SetToolTip(this.btnUpload, "Writes the file to current location");
			this.btnUpload.Click += new System.EventHandler(this.btnUpload_Click);
			// 
			// btnDownload
			// 
			this.btnDownload.BackColor = System.Drawing.Color.Chocolate;
			this.btnDownload.Enabled = false;
			this.btnDownload.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnDownload.ForeColor = System.Drawing.Color.White;
			this.btnDownload.Location = new System.Drawing.Point(75, 5);
			this.btnDownload.Name = "btnDownload";
			this.btnDownload.Size = new System.Drawing.Size(71, 31);
			this.btnDownload.TabIndex = 1;
			this.btnDownload.Text = "&Download";
			this.toolTipText.SetToolTip(this.btnDownload, "Download file to this computer");
			this.btnDownload.Click += new System.EventHandler(this.btnDownload_Click);
			// 
			// lvFiles
			// 
			this.lvFiles.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
																					  this.clhFilename,
																					  this.clhFileSize,
																					  this.clhType});
			this.lvFiles.ForeColor = System.Drawing.SystemColors.WindowText;
			this.lvFiles.FullRowSelect = true;
			this.lvFiles.HideSelection = false;
			this.lvFiles.Location = new System.Drawing.Point(3, 41);
			this.lvFiles.MultiSelect = false;
			this.lvFiles.Name = "lvFiles";
			this.lvFiles.Size = new System.Drawing.Size(502, 211);
			this.lvFiles.TabIndex = 4;
			this.toolTipText.SetToolTip(this.lvFiles, "Double click an entry to open");
			this.lvFiles.View = System.Windows.Forms.View.Details;
			this.lvFiles.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.lvFiles_KeyPress);
			this.lvFiles.DoubleClick += new System.EventHandler(this.lvFiles_DoubleClick);
			// 
			// clhFilename
			// 
			this.clhFilename.Text = "File / Folder";
			this.clhFilename.Width = 303;
			// 
			// clhFileSize
			// 
			this.clhFileSize.Text = "Size";
			this.clhFileSize.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			this.clhFileSize.Width = 69;
			// 
			// sBar
			// 
			this.sBar.Location = new System.Drawing.Point(0, 259);
			this.sBar.Name = "sBar";
			this.sBar.Size = new System.Drawing.Size(508, 16);
			this.sBar.TabIndex = 5;
			// 
			// FileOpenDialog
			// 
			this.FileOpenDialog.Filter = "*.* (All files)|";
			this.FileOpenDialog.Title = "Select a file to upload";
			// 
			// lblCopyright
			// 
			this.lblCopyright.Location = new System.Drawing.Point(314, 14);
			this.lblCopyright.Name = "lblCopyright";
			this.lblCopyright.Size = new System.Drawing.Size(192, 14);
			this.lblCopyright.TabIndex = 6;
			this.lblCopyright.Text = "

⌨️ 快捷键说明

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