Beispiel #1
0
        private void frmScreen_Load(object sender, EventArgs e)
        {
            //vncControl.AllowInput = true;
            vncControl.AllowRemoteCursor = false;
            vncControl.Capture           = true;
            vncControl.Cursor            = Cursors.Default;

            // return;

            var options = new RemoteViewing.Vnc.VncClientConnectOptions();

            if (sPassword != "")
            {
                options.Password = sPassword.ToCharArray();
            }

            try
            {
                try
                {
                    Cursor = Cursors.WaitCursor;
                    try
                    {
                        vncControl.Client.Connect(sHost, iPort, options);
                    }
                    finally { Cursor = Cursors.Default; }
                }
                catch (RemoteViewing.Vnc.VncException ex)
                {
                    MessageBoxEx.Show(this, "Connection failed (" + ex.Reason.ToString() + ").", "Connect", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                catch (SocketException ex)
                {
                    MessageBoxEx.Show(this, "Connection failed (" + ex.SocketErrorCode.ToString() + ").", "Connect", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                vncControl.Focus();

                this.Height = vncControl.Client.Framebuffer.Height;
                this.Width  = vncControl.Client.Framebuffer.Width;
            }
            finally
            {
                if (options.Password != null)
                {
                    Array.Clear(options.Password, 0, options.Password.Length);
                }
            }


            SeeThroughPanel x = new SeeThroughPanel();

            x.Parent = vncControl;

            x.Dock = DockStyle.Fill;
        }
Beispiel #2
0
        public string StartSession()
        {
            //vncControl.AllowInput = true;
            vncControl.AllowRemoteCursor = true;
            //vncControl.Capture = true;
            //vncControl.Cursor = Cursors.Default;
            var options = new RemoteViewing.Vnc.VncClientConnectOptions();

            options.Password = "******".ToCharArray();
            if (Port.Length > 0)
            {
            }
            int iPort = Convert.ToInt32(Port);

            try
            {
                try
                {
                    //  Cursor = Cursors.WaitCursor;
                    try
                    {
                        if (!this.IsHandleCreated)
                        {
                            this.CreateControl();
                        }

                        vncControl.Client.Connect(IP, iPort, options);
                    }
                    finally {// Cursor = Cursors.Default;
                    }
                }
                catch (RemoteViewing.Vnc.VncException ex)
                {
                    return("Connection failed (" + ex.Reason.ToString() + ").");
                }
                catch (System.Net.Sockets.SocketException ex)
                {
                    return("Connection failed (" + ex.SocketErrorCode.ToString() + ").");
                }
                vncControl.Focus();
            }
            finally
            {
                if (options.Password != null)
                {
                    Array.Clear(options.Password, 0, options.Password.Length);
                }
            }
            return(string.Empty);
        }