private void btnFileDownload_Click(object sender, EventArgs e) { int transfPort = 0; if (!Int32.TryParse(txtTransferPort.Text, out transfPort)) { MessageBox.Show("Please put in a valid port before requesting a file.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (listFiles.SelectedItems.Count != 1) return; if (listFiles.SelectedItems[0].SubItems[1].Text != "FILE") return; SaveFileDialog sfd = new SaveFileDialog(); if (sfd.ShowDialog() == DialogResult.OK) { FileServer fs = new FileServer(this ,ip, transfPort, sfd.FileName, String.Empty); fs.StartListeningForFile(); SendASCII("SEND_FILE<%SEP%>" + txtLocation.Text + listFiles.SelectedItems[0].SubItems[0].Text + "<%SEP%>" + txtTransferPort.Text); SetText(lblStatus, "REQUEST sent. Awaiting for initial data."); } }
private void btnFileUpload_Click(object sender, EventArgs e) { int transfPort = 0; if (!Int32.TryParse(txtTransferPort.Text, out transfPort)) { MessageBox.Show("Please put in a valid port before requesting a file.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (String.IsNullOrEmpty(txtLocation.Text)) return; FileUploadDisplay display = new FileUploadDisplay(this, txtLocation.Text); if (display.ShowDialog() == DialogResult.OK) { FileServer fs = new FileServer(this, ip, transfPort, String.Empty, _toUpload_local); fs.StartListeningForUpload(); SendASCII("GETREADY_RECV_FILE<%SEP%>" + _toUpload_remote + "<%SEP%>" + txtTransferPort.Text); } }
// Capture Screenshot private void btnCaptureScreenshot_Click(object sender, EventArgs e) { int quality = 50; int port = 81; if (Int32.TryParse(txtQuality.Text, out quality) && quality > 0 && quality <= 100 && Int32.TryParse(txtSSPort.Text, out port) && port > 0) { FileServer fs = new FileServer(this, ip, port, Path.GetTempPath() + "\\remoteSS" + Guid.NewGuid().ToString() , String.Empty); fs.StartListeningForSS(); SendASCII("GETSCREEN<%SEP%>" + txtQuality.Text + "<%SEP%>" + txtSSPort.Text); btnCaptureScreenshot.Text = "Processing..."; btnCaptureScreenshot.Enabled = false; txtQuality.Enabled = false; txtSSPort.Enabled = false; } else MessageBox.Show("Please enter valid integers into the boxes.", "Type Conversion Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }