Ejemplo n.º 1
0
        /// <summary>
        /// Connect to a VNC Host and determine whether or not the server requires a password.
        /// </summary>
        /// <param name="host">The IP Address or Host Name of the VNC Host.</param>
        /// <param name="display">The Display number (used on Unix hosts).</param>
        /// <param name="viewOnly">Determines whether mouse and keyboard events will be sent to the host.</param>
        /// <param name="scaled">Determines whether to use desktop scaling or leave it normal and clip.</param>
        /// <exception cref="System.ArgumentNullException">Thrown if host is null.</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">Thrown if display is negative.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown if the RemoteDesktop control is already Connected.  See <see cref="VncSharpWpf.RemoteDesktop.IsConnected" />.</exception>
        public void Connect(string host, int display, bool viewOnly, bool scaled)
        {
            // TODO: Should this be done asynchronously so as not to block the UI?  Since an event
            // indicates the end of the connection, maybe that would be a better design.
            InsureConnection(false);

            if (host == null)
            {
                throw new ArgumentNullException("host");
            }
            if (display < 0)
            {
                throw new ArgumentOutOfRangeException("display", display, "Display number must be a positive integer.");
            }

            // Start protocol-level handling and determine whether a password is needed
            vnc = new VncClient();
            vnc.ConnectionLost += new EventHandler(VncClientConnectionLost);
            vnc.ServerCutText  += new EventHandler(VncServerCutText);

            passwordPending = vnc.Connect(host, display, VncPort, viewOnly);

            desktopPolicy = new VncWpfDesktopPolicy(vnc, this);
            SetScalingMode(scaled);

            if (passwordPending)
            {
                // Server needs a password, so call which ever method is refered to by the GetPassword delegate.
                string password = GetPassword();

                if (password == null)
                {
                    // No password could be obtained (e.g., user clicked Cancel), so stop connecting
                    return;
                }
                else
                {
                    Authenticate(password);
                }
            }
            else
            {
                // No password needed, so go ahead and Initialize here
                this.waitLabel.Content = "Connecting to VNC host " + host + "(" + port + ") , please wait... ";
                Initialize();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Wait for a connection from VNC Server.
        /// </summary>
        /// <param name="host">Hostname or IP Address</param>
        /// <param name="port">Listening Port</param>
        /// <param name="viewOnly">Set true if you use viewonly mode</param>
        /// <param name="scaled">Set true if you use scaled mode</param>
        public void Listen(string host, int port = 5500, bool viewOnly = false, bool scaled = false)
        {
            InsureConnection(false);

            if (host == null)
            {
                throw new ArgumentNullException("host");
            }

            vnc = new VncClient();
            vnc.ConnectionLost      += new EventHandler(VncClientConnectionLost);
            vnc.ServerCutText       += new EventHandler(VncServerCutText);
            vnc.ConnectedFromServer += new VncConnectedFromServerHandler(ConnectedFromServerEventHandler);

            desktopPolicy = new VncWpfDesktopPolicy(vnc, this);
            SetScalingMode(scaled);
            SetState(RuntimeState.Listen);
            vnc.Listen(host, port, viewOnly);

            this.waitLabel.Content    = "Wait for a connection at " + Dns.GetHostEntry(host).AddressList[0] + ":" + port;
            this.waitLabel.Visibility = Visibility.Visible;
        }
Ejemplo n.º 3
0
 public VncWpfDesktopPolicy(VncClient vnc,
                                RemoteDesktopWpf remoteDesktop) 
     : base(vnc, remoteDesktop)
 {
 }
 public VncDesktopTransformPolicy(VncClient vnc,
                                  RemoteDesktopWpf remoteDesktop)
 {
     this.vnc = vnc;
     this.remoteDesktop = remoteDesktop;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Wait for a connection from VNC Server.
        /// </summary>
        /// <param name="host">Hostname or IP Address</param>
        /// <param name="port">Listening Port</param>
        /// <param name="viewOnly">Set true if you use viewonly mode</param>
        /// <param name="scaled">Set true if you use scaled mode</param>
        public void Listen(string host, int port = 5500, bool viewOnly = false, bool scaled = false)
        {
            InsureConnection(false);

            if (host == null)
            {
                throw new ArgumentNullException("host");
            }

            vnc = new VncClient();
            vnc.ConnectionLost += new EventHandler(VncClientConnectionLost);
            vnc.ServerCutText += new EventHandler(VncServerCutText);
            vnc.ConnectedFromServer += new VncConnectedFromServerHandler(ConnectedFromServerEventHandler);

            desktopPolicy = new VncWpfDesktopPolicy(vnc, this);
            SetScalingMode(scaled);
            SetState(RuntimeState.Listen);
            vnc.Listen(host, port, viewOnly);

            this.waitLabel.Content = "Wait for a connection at " + Dns.GetHostEntry(host).AddressList[0] + ":" + port;
            this.waitLabel.Visibility = Visibility.Visible;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Connect to a VNC Host and determine whether or not the server requires a password.
        /// </summary>
        /// <param name="host">The IP Address or Host Name of the VNC Host.</param>
        /// <param name="display">The Display number (used on Unix hosts).</param>
        /// <param name="viewOnly">Determines whether mouse and keyboard events will be sent to the host.</param>
        /// <param name="scaled">Determines whether to use desktop scaling or leave it normal and clip.</param>
        /// <exception cref="System.ArgumentNullException">Thrown if host is null.</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">Thrown if display is negative.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown if the RemoteDesktop control is already Connected.  See <see cref="VncSharpWpf.RemoteDesktop.IsConnected" />.</exception>
        public void Connect(string host, int display, bool viewOnly, bool scaled)
        {
            // TODO: Should this be done asynchronously so as not to block the UI?  Since an event 
            // indicates the end of the connection, maybe that would be a better design.
            InsureConnection(false);

            if (host == null) throw new ArgumentNullException("host");
            if (display < 0) throw new ArgumentOutOfRangeException("display", display, "Display number must be a positive integer.");

            // Start protocol-level handling and determine whether a password is needed
            vnc = new VncClient();
            vnc.ConnectionLost += new EventHandler(VncClientConnectionLost);
            vnc.ServerCutText += new EventHandler(VncServerCutText);

            passwordPending = vnc.Connect(host, display, VncPort, viewOnly);

            desktopPolicy = new VncWpfDesktopPolicy(vnc, this);
            SetScalingMode(scaled);

            if (passwordPending) {
                // Server needs a password, so call which ever method is refered to by the GetPassword delegate.
                string password = GetPassword();

                if (password == null) {
                    // No password could be obtained (e.g., user clicked Cancel), so stop connecting
                    return;
                } else {
                    Authenticate(password);
                }
            } else {
                // No password needed, so go ahead and Initialize here
                this.waitLabel.Content = "Connecting to VNC host " + host + "(" + port + ") , please wait... ";
                Initialize();
            }
        }
Ejemplo n.º 7
0
 public VncDesktopTransformPolicy(VncClient vnc,
                                  RemoteDesktopWpf remoteDesktop)
 {
     this.vnc           = vnc;
     this.remoteDesktop = remoteDesktop;
 }
Ejemplo n.º 8
0
 public VncWpfDesktopPolicy(VncClient vnc,
                            RemoteDesktopWpf remoteDesktop)
     : base(vnc, remoteDesktop)
 {
 }