public MouseControlForm(string ipOrHostname, int width, int height)
        {
            InitializeComponent();
            DoubleBuffered = true;
            vncClient      = new VncClient(ipOrHostname, Constants.VNC_PORT)
            {
                ReceiveBufferSize = Constants.IMAGE_SIZE,
                ReceiveTimeout    = 1000
            };
            ClientSize = new Size(width, height);
            vncClient.SetNewDataArriveEventHandler(DataArrivedHandler);

            Task.Factory.StartNew(() =>
            {
                while (working)
                {
                    try
                    {
                        vncClient.Send(VncCommand.GetScreen);
                        Thread.Sleep(Constants.SCREEN_WAIT_TIME);
                    }
                    catch (SocketException)
                    {
                        working = false;
                    }
                }
            });
        }
 private void Send(string message, string caller)
 {
     try
     {
         vncClient.Send(message);
     }
     catch (Exception ex)
     {
         ErrorBox.Show(caller, ex);
     }
 }
示例#3
0
 private void Send(string message, DataArrivedEventHandler vncClientDataArrived = null)
 {
     try
     {
         var vncClient = new VncClient(cb_Computer.Text, Constants.VNC_PORT);
         vncClient.SetNewDataArriveEventHandler(vncClientDataArrived);
         vncClient.Send(message);
     }
     catch (Exception ex)
     {
         ErrorBox.Show("MainForm.Send", ex);
     }
 }