Base class for desktop clipping/scaling policies. Used by RemoteDesktop.
Exemple #1
0
        public RemoteDesktopWpf() : base()
        {
            InitializeComponent();

            // Use a simple desktop policy for design mode.  This will be replaced in Connect()
            desktopPolicy = new VncDesignModeDesktopPolicy(this);

            if (desktopPolicy.AutoScroll)
            {
                scrollviewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
                scrollviewer.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            }
            else
            {
                scrollviewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
                scrollviewer.VerticalScrollBarVisibility   = ScrollBarVisibility.Disabled;
            }

            // Users of the control can choose to use their own Authentication GetPassword() method via the delegate above.  This is a default only.
            GetPassword = new AuthenticateDelegate(PasswordDialogWpf.GetPassword);

            // EventHandler Settings
            this.designModeDesktop.SizeChanged += new System.Windows.SizeChangedEventHandler(SizeChangedEventHandler);
            this.designModeDesktop.MouseMove   += new MouseEventHandler(MouseDownUpMoveEventHandler);
            this.designModeDesktop.MouseDown   += new MouseButtonEventHandler(MouseDownUpMoveEventHandler);
            this.designModeDesktop.MouseUp     += new MouseButtonEventHandler(MouseDownUpMoveEventHandler);
            this.designModeDesktop.MouseWheel  += new MouseWheelEventHandler(MouseWHeelEventHandler);
        }
Exemple #2
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();
            }
        }
Exemple #3
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;
        }
        /// <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;
        }
        /// <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();
            }
        }
		public RemoteDesktopWpf() : base()
		{
            InitializeComponent();

			// Use a simple desktop policy for design mode.  This will be replaced in Connect()
            desktopPolicy = new VncDesignModeDesktopPolicy(this);

            if (desktopPolicy.AutoScroll)
            {
                scrollviewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
                scrollviewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            } else {
                scrollviewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
                scrollviewer.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;
            }
            
			// Users of the control can choose to use their own Authentication GetPassword() method via the delegate above.  This is a default only.
			GetPassword = new AuthenticateDelegate(PasswordDialogWpf.GetPassword);

            // EventHandler Settings
            this.designModeDesktop.SizeChanged +=new System.Windows.SizeChangedEventHandler(SizeChangedEventHandler);
            this.designModeDesktop.MouseMove += new MouseEventHandler(MouseDownUpMoveEventHandler);
            this.designModeDesktop.MouseDown += new MouseButtonEventHandler(MouseDownUpMoveEventHandler);
            this.designModeDesktop.MouseUp += new MouseButtonEventHandler(MouseDownUpMoveEventHandler);
            this.designModeDesktop.MouseWheel +=new MouseWheelEventHandler(MouseWHeelEventHandler);
		}