Ejemplo n.º 1
0
 private void Cap_keyinput_send_chb_CheckedChanged(object sender, EventArgs e)
 {
     if (Cap_keyinput_send_chb.Checked & (serverMain != null))
     {
         Task.Factory.StartNew(() =>
         {
             try
             {
                 serverMain.Send("+START_KEYBOARD " + serverKeyboard_Port.ToString());
                 serverKeyboard = new TCP.Server(serverKeyboard_Port);
                 serverKeyboard.Start();
             }
             catch
             {
                 Cap_keyinput_send_chb.Checked = false;
             }
         });
     }
     else
     {
         if (serverKeyboard != null)
         {
             serverKeyboard.Stop();
         }
         Cap_keyinput_send_chb.Checked = false;
         serverKeyboard = null;
     }
 }
Ejemplo n.º 2
0
 private void Cap_send_mouse_ckb_CheckedChanged(object sender, EventArgs e)
 {
     if (Cap_send_mouse_ckb.Checked & (serverMain != null) & (serverCapture != null))
     {
         Task.Factory.StartNew(() =>
         {
             try
             {
                 serverMain.Send("+START_MOUSE " + serverMouse_Port.ToString());
                 serverMouse = new TCP.Server(serverMouse_Port);
                 serverMouse.Start();
             }
             catch
             {
                 Cap_send_mouse_ckb.Checked = false;
             }
         });
     }
     else
     {
         if (serverMouse != null)
         {
             serverMouse.Stop();
         }
         Cap_send_mouse_ckb.Checked = false;
         serverMouse = null;
     }
 }
Ejemplo n.º 3
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);
                }
            });
        }
Ejemplo n.º 4
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;
                }
            });
        }
Ejemplo n.º 5
0
        private void Cmd_start_server_bt_Click(object sender, EventArgs e)
        {
            Task.Factory.StartNew(() =>
            {
                // サーバー設定
                Cmd_stop_server_bt.Enabled = true;
                serverMain                  = new TCP.Server(serverMain_Port);
                Cap_raw_tx.Text             = TCP.Server.GetLocalIP;
                Cap_raw_tx.Text             = "接続待機中...";
                Main_screen_pic.Image       = null;
                Cmd_start_server_bt.Enabled = false;
                serverMain.Start();

                Cmd_stop_server_bt.Enabled = false;
                Cap_raw_tx.Text            = "接続の確立中...";

                start_ping_server();
            });
        }
Ejemplo n.º 6
0
        private void Cmd_stop_server_bt_Click(object sender, EventArgs e)
        {
            if (serverMain != null)
            {
                serverMain.Stop();
            }
            if (serverPing != null)
            {
                serverPing.Stop();
            }
            if (serverCapture != null)
            {
                serverCapture.Stop();
            }
            serverMain    = null;
            serverPing    = null;
            serverCapture = null;
            Cmd_stop_server_bt.Enabled  = false;
            Cmd_start_server_bt.Enabled = true;
            isConnected                   = false;
            Cap_raw_tx.Text               = "停止";
            Cmd_panel.Enabled             = false;
            Cap_start_capture_bt.Enabled  = false;
            Cap_stop_capture_bt.Enabled   = false;
            Cap_send_mouse_ckb.Checked    = false;
            Cap_keyinput_send_chb.Checked = false;
            Cap_mouse_X_tx.Text           = "";
            Cap_mouse_Y_tx.Text           = "";

            if (forms_SendMsg != null)
            {
                if (!forms_SendMsg.IsDisposed)
                {
                    forms_SendMsg.Dispose();
                }
            }
            if (forms_ScreenShot != null)
            {
                if (!forms_ScreenShot.IsDisposed)
                {
                    forms_ScreenShot.Dispose();
                }
            }
            if (forms_KeyboardLogs != null)
            {
                if (!forms_KeyboardLogs.IsDisposed)
                {
                    forms_KeyboardLogs.Dispose();
                }
            }
            if (forms_CommandForm != null)
            {
                if (!forms_CommandForm.IsDisposed)
                {
                    forms_CommandForm.Dispose();
                }
            }
            if (forms_PowerSettings != null)
            {
                if (!forms_PowerSettings.IsDisposed)
                {
                    forms_PowerSettings.Dispose();
                }
            }
            if (forms_MainExplorer != null)
            {
                if (!forms_MainExplorer.IsDisposed)
                {
                    forms_MainExplorer.Dispose();
                }
            }
            if (forms_TaskManeger != null)
            {
                if (!forms_TaskManeger.IsDisposed)
                {
                    forms_TaskManeger.Dispose();
                }
            }
            if (forms_SendImage != null)
            {
                if (!forms_SendImage.IsDisposed)
                {
                    forms_SendImage.Dispose();
                }
            }
            forms_GetInfo = null;
            GC.Collect();
        }