예제 #1
0
        private void start_ping_server()
        {
            try
            {
                serverMain.RecvBytes();
                serverMain.Send("+START_PING " + serverPing_Port.ToString());
                serverPing  = new TCP.Server(serverPing_Port);
                isConnected = true;
                serverPing.Start();

                Cmd_panel.Enabled            = true;
                Cap_start_capture_bt.Enabled = true;
                Cmd_stop_server_bt.Enabled   = true;
                System.Media.SystemSounds.Asterisk.Play();
            }
            catch (Exception ex)
            {
                Cmd_stop_server_bt_Click(null, EventArgs.Empty);
                if (Cap_auto_restart_server_chb.Checked)
                {
                    Cmd_start_server_bt_Click(null, EventArgs.Empty);
                }
                return;
            }

            Task.Factory.StartNew(() =>
            {
                try
                {
                    System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
                    while (true)
                    {
                        serverPing.Send("+PING");
                        sw.Start();
                        serverPing.RecvBytes();
                        sw.Stop();
                        Cap_raw_tx.Text = serverPing.GetClientIP + " - " + sw.Elapsed.TotalMilliseconds.ToString() + "ms";
                        sw.Reset();
                        Thread.Sleep(1000);
                    }
                }
                catch (NullReferenceException)
                {
                    Cmd_stop_server_bt_Click(null, EventArgs.Empty);
                }
                catch (Exception ex)
                {
                    Cmd_stop_server_bt_Click(null, EventArgs.Empty);
                    MessageBox.Show(ex.Message, "Client Error", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                }
            });
        }
예제 #2
0
 private void mouseFunction(string sendCmd)
 {
     Task.Factory.StartNew(() =>
     {
         string mousePoint = Cap_mouse_X_tx.Text + "," + Cap_mouse_Y_tx.Text;
         try
         {
             serverMouse.Send(sendCmd + " " + mousePoint);
         }
         catch
         {
             Cap_send_mouse_ckb.Checked = false;
         }
     });
 }
예제 #3
0
        private void start_capture_server()
        {
            Task.Factory.StartNew(() =>
            {
                try
                {
                    Cap_start_capture_bt.Enabled = false;
                    serverMain.Send("+START_CAP " + serverCapture_Port.ToString());

                    serverCapture = new TCP.Server(serverCapture_Port);
                    serverCapture.Start();
                    Cap_stop_capture_bt.Enabled = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                try
                {
                    while (isConnected)
                    {
                        ImageConverter imgconv = new ImageConverter();
                        byte[] imgBytes        = serverCapture.RecvBytes();
                        try
                        {
                            Main_screen_pic.Image = (Image)imgconv.ConvertFrom(imgBytes);
                        } catch { }
                        serverCapture.Send(Cap_fps_num_tr.Value.ToString() + ",");
                        Thread.Sleep(1);
                    }
                    serverCapture.Stop();
                    serverCapture         = null;
                    Main_screen_pic.Image = null;
                }
                catch (Exception ex)
                {
                    if (serverCapture != null)
                    {
                        serverCapture.Stop();
                    }
                    serverCapture = null;
                    Cap_start_capture_bt.Enabled = true;
                    Cap_stop_capture_bt.Enabled  = false;
                    Main_screen_pic.Image        = null;
                }
            });
        }
예제 #4
0
 private void MainForm_KeyPress(object sender, KeyPressEventArgs e)
 {
     if ((serverMain != null) & (serverKeyboard != null) & Cap_keyinput_send_chb.Checked)
     {
         Task.Factory.StartNew(() =>
         {
             try
             {
                 serverKeyboard.Send(e.KeyChar.ToString());
             }
             catch (Exception ex)
             {
                 Cap_keyinput_send_chb.Checked = false;
             }
         });
     }
 }