示例#1
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            var config = await ReadConfigAsync();

            _VncClient = new VncClient(config.BitsPerPixel, config.Depth);
            _VncClient.Connect(config.Host, config.Port);

            var auth = new VncAuthenticator(config.Password);

            _VncClient.Authenticate(auth);
            _VncClient.Initialize();

            _VncImage       = new WriteableBitmap(_VncClient.Framebuffer.Width, _VncClient.Framebuffer.Height);
            VncImage.Source = _VncImage;

            _VncClient.OnFramebufferUpdate += _VncClient_OnFramebufferUpdate;
            _VncClient.ReceiveUpdates();
        }
示例#2
0
        /// <summary>
        /// After protocol-level initialization and connecting is complete, the local GUI objects have to be set-up,
        /// and requests for updates to the remote host begun.
        /// </summary>
        /// <exception cref="System.InvalidOperationException">Thrown if the RemoteDesktop control is already in the
        /// Connected state.  See <see cref="IsConnected" />.</exception>
        private void Initialize()
        {
            // Finish protocol handshake with host now that authentication is done.
            InsureConnection(false);
            vnc.Initialize(bitsPerPixel, depth);
            SetState(RuntimeState.Connected);

            // Create a buffer on which updated rectangles will be drawn and draw a "please wait..."
            // message on the buffer for initial display until we start getting rectangles
            SetupDesktop();

            // Tell the user of this control the necessary info about the desktop in order to setup the display
            OnConnectComplete(new ConnectEventArgs(vnc.Framebuffer.Width,
                                                   vnc.Framebuffer.Height,
                                                   vnc.Framebuffer.DesktopName));


            // Start getting updates from the remote host (vnc.StartUpdates will begin a worker thread).
            vnc.VncUpdate += VncUpdate;
            vnc.StartUpdates();
        }