C# Class VncSharpWpf.RemoteDesktopWpf

The RemoteDesktop control takes care of all the necessary RFB Protocol and GUI handling, including mouse and keyboard support, as well as requesting and processing screen updates from the remote VNC host. Most users will choose to use the RemoteDesktop control alone and not use any of the other protocol classes directly.
Inheritance: System.Windows.Controls.UserControl
ファイルを表示 Open project: nakano531/VncSharpWpf Class Usage Examples

Public Properties

Property Type Description
GetPassword AuthenticateDelegate

Private Properties

Property Type Description
ConvertKeyToAscii char
GetKeyboardLayout System.IntPtr
GetKeyboardState bool
InitializeComponent void
InsureConnection void
KeyDownEventHandler void
KeyUpEventHandler void
ManageKeyDownAndKeyUp void
MapVirtualKeyEx uint
MouseDownUpMoveEventHandler void
MouseWHeelEventHandler void
PressKeys void
SetState void
SizeChangedEventHandler void
System void
ToUnicodeEx int
UpdateRemotePointer void

Public Methods

Method Description
Authenticate ( string password ) : void

Authenticate with the VNC Host using a user supplied password.

Connect ( string host ) : void

Connect to a VNC Host and determine whether or not the server requires a password.

Connect ( string host, bool viewOnly ) : void

Connect to a VNC Host and determine whether or not the server requires a password.

Connect ( string host, bool viewOnly, bool scaled ) : void

Connect to a VNC Host and determine whether or not the server requires a password.

Connect ( string host, int display ) : void

Connect to a VNC Host and determine whether or not the server requires a password.

Connect ( string host, int display, bool viewOnly ) : void

Connect to a VNC Host and determine whether or not the server requires a password.

Connect ( string host, int display, bool viewOnly, bool scaled ) : void

Connect to a VNC Host and determine whether or not the server requires a password.

ConnectedFromServerEventHandler ( object sender, bool authentication ) : void

Event Handler for Event "ConnectedFromServer"

Disconnect ( ) : void

Stops the remote host from sending further updates and disconnects.

FillServerClipboard ( ) : void

Fills the remote server's clipboard with the text in the client's clipboard, if any.

FillServerClipboard ( string text ) : void

Fills the remote server's clipboard with text.

FullScreenUpdate ( ) : void

Get a complete update of the entire screen from the remote host.

You should allow users to call FullScreenUpdate in order to correct corruption of the local image. This will simply request that the next update be for the full screen, and not a portion of it. It will not do the update while blocking.

Listen ( string host, int port = 5500, bool viewOnly = false, bool scaled = false ) : void

Wait for a connection from VNC Server.

RemoteDesktopWpf ( ) : System
SendSpecialKeys ( SpecialKeys keys ) : void

Sends a keyboard combination that would otherwise be reserved for the client PC.

Keyboard combinations are Pressed and then Released, while single keys (e.g., SpecialKeys.Ctrl) are only pressed so that subsequent keys will be modified.

SendSpecialKeys ( SpecialKeys keys, bool release ) : void

Sends a keyboard combination that would otherwise be reserved for the client PC.

Keyboard combinations are Pressed and then Released, while single keys (e.g., SpecialKeys.Ctrl) are only pressed so that subsequent keys will be modified.

SetInputMode ( bool viewOnly ) : void

Changes the input mode to view-only or interactive.

SetScalingMode ( bool scaled ) : void

Set the remote desktop's scaling mode.

StopListen ( ) : void

Stop Listening.

Protected Methods

Method Description
Initialize ( ) : void

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.

OnClipboardChanged ( ) : void
OnConnectComplete ( ConnectEventArgs e ) : void

Dispatches the ConnectComplete event if any targets have registered.

OnConnectionLost ( ) : void

Dispatches the ConnectionLost event if any targets have registered.

OnStoppedListen ( ) : void
SetupDesktop ( ) : void

Creates and initially sets-up the local bitmap that will represent the remote desktop image.

VncClientConnectionLost ( object sender, EventArgs e ) : void

RemoteDesktop listens for ConnectionLost events from the VncClient object.

VncServerCutText ( object sender, EventArgs e ) : void
VncUpdate ( object sender, VncEventArgs e ) : void

Private Methods

Method Description
ConvertKeyToAscii ( Key key ) : char

Convert Key to Ascii Character.

GetKeyboardLayout ( uint idThread ) : IntPtr
GetKeyboardState ( byte lpKeyState ) : bool
InitializeComponent ( ) : void
InsureConnection ( bool connected ) : void

Insures the state of the connection to the server, either Connected or Not Connected depending on the value of the connected argument.

KeyDownEventHandler ( object sender, System.Windows.Input.KeyEventArgs e ) : void
KeyUpEventHandler ( object sender, System.Windows.Input.KeyEventArgs e ) : void
ManageKeyDownAndKeyUp ( System.Windows.Input.KeyEventArgs e, bool isDown ) : void
MapVirtualKeyEx ( uint uCode, uint uMapType, IntPtr dwhkl ) : uint
MouseDownUpMoveEventHandler ( object sender, MouseEventArgs e ) : void
MouseWHeelEventHandler ( object sender, System.Windows.Input.MouseWheelEventArgs e ) : void
PressKeys ( uint keys, bool release ) : void

Given a list of keysym values, sends a key press for each, then a release.

SetState ( RuntimeState newState ) : void
SizeChangedEventHandler ( object sender, RoutedEventArgs e ) : void

EventHandler for Image Size Change

System ( int connectionId, object target ) : void
ToUnicodeEx ( uint wVirtKey, uint wScanCode, byte lpKeyState, [ pwszBuff, int cchBuff, uint wFlags, IntPtr dwhkl ) : int
UpdateRemotePointer ( ) : void

Method Details

Authenticate() public method

Authenticate with the VNC Host using a user supplied password.
Thrown if the RemoteDesktop control is already Connected. See . Thrown if the password is null.
public Authenticate ( string password ) : void
password string The user's password.
return void

Connect() public method

Connect to a VNC Host and determine whether or not the server requires a password.
Thrown if host is null. Thrown if display is negative. Thrown if the RemoteDesktop control is already Connected. See .
public Connect ( string host ) : void
host string The IP Address or Host Name of the VNC Host.
return void

Connect() public method

Connect to a VNC Host and determine whether or not the server requires a password.
Thrown if host is null. Thrown if display is negative. Thrown if the RemoteDesktop control is already Connected. See .
public Connect ( string host, bool viewOnly ) : void
host string The IP Address or Host Name of the VNC Host.
viewOnly bool Determines whether mouse and keyboard events will be sent to the host.
return void

Connect() public method

Connect to a VNC Host and determine whether or not the server requires a password.
Thrown if host is null. Thrown if display is negative. Thrown if the RemoteDesktop control is already Connected. See .
public Connect ( string host, bool viewOnly, bool scaled ) : void
host string The IP Address or Host Name of the VNC Host.
viewOnly bool Determines whether mouse and keyboard events will be sent to the host.
scaled bool Determines whether to use desktop scaling or leave it normal and clip.
return void

Connect() public method

Connect to a VNC Host and determine whether or not the server requires a password.
Thrown if host is null. Thrown if display is negative. Thrown if the RemoteDesktop control is already Connected. See .
public Connect ( string host, int display ) : void
host string The IP Address or Host Name of the VNC Host.
display int The Display number (used on Unix hosts).
return void

Connect() public method

Connect to a VNC Host and determine whether or not the server requires a password.
Thrown if host is null. Thrown if display is negative. Thrown if the RemoteDesktop control is already Connected. See .
public Connect ( string host, int display, bool viewOnly ) : void
host string The IP Address or Host Name of the VNC Host.
display int The Display number (used on Unix hosts).
viewOnly bool Determines whether mouse and keyboard events will be sent to the host.
return void

Connect() public method

Connect to a VNC Host and determine whether or not the server requires a password.
Thrown if host is null. Thrown if display is negative. Thrown if the RemoteDesktop control is already Connected. See .
public Connect ( string host, int display, bool viewOnly, bool scaled ) : void
host string The IP Address or Host Name of the VNC Host.
display int The Display number (used on Unix hosts).
viewOnly bool Determines whether mouse and keyboard events will be sent to the host.
scaled bool Determines whether to use desktop scaling or leave it normal and clip.
return void

ConnectedFromServerEventHandler() public method

Event Handler for Event "ConnectedFromServer"
public ConnectedFromServerEventHandler ( object sender, bool authentication ) : void
sender object
authentication bool
return void

Disconnect() public method

Stops the remote host from sending further updates and disconnects.
Thrown if the RemoteDesktop control is not already in the Connected state. See .
public Disconnect ( ) : void
return void

FillServerClipboard() public method

Fills the remote server's clipboard with the text in the client's clipboard, if any.
public FillServerClipboard ( ) : void
return void

FillServerClipboard() public method

Fills the remote server's clipboard with text.
public FillServerClipboard ( string text ) : void
text string The text to put in the server's clipboard.
return void

FullScreenUpdate() public method

Get a complete update of the entire screen from the remote host.
You should allow users to call FullScreenUpdate in order to correct corruption of the local image. This will simply request that the next update be for the full screen, and not a portion of it. It will not do the update while blocking.
Thrown if the RemoteDesktop control is not in the Connected state. See .
public FullScreenUpdate ( ) : void
return void

Initialize() protected method

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.
Thrown if the RemoteDesktop control is already in the Connected state. See .
protected Initialize ( ) : void
return void

Listen() public method

Wait for a connection from VNC Server.
public Listen ( string host, int port = 5500, bool viewOnly = false, bool scaled = false ) : void
host string Hostname or IP Address
port int Listening Port
viewOnly bool Set true if you use viewonly mode
scaled bool Set true if you use scaled mode
return void

OnClipboardChanged() protected method

protected OnClipboardChanged ( ) : void
return void

OnConnectComplete() protected method

Dispatches the ConnectComplete event if any targets have registered.
Thrown if the RemoteDesktop control is not in the Connected state.
protected OnConnectComplete ( ConnectEventArgs e ) : void
e ConnectEventArgs A ConnectEventArgs object with information about the remote framebuffer's geometry.
return void

OnConnectionLost() protected method

Dispatches the ConnectionLost event if any targets have registered.
Thrown if the RemoteDesktop control is in the Connected state.
protected OnConnectionLost ( ) : void
return void

OnStoppedListen() protected method

protected OnStoppedListen ( ) : void
return void

RemoteDesktopWpf() public method

public RemoteDesktopWpf ( ) : System
return System

SendSpecialKeys() public method

Sends a keyboard combination that would otherwise be reserved for the client PC.
Keyboard combinations are Pressed and then Released, while single keys (e.g., SpecialKeys.Ctrl) are only pressed so that subsequent keys will be modified.
Thrown if the RemoteDesktop control is not in the Connected state.
public SendSpecialKeys ( SpecialKeys keys ) : void
keys SpecialKeys SpecialKeys is an enumerated list of supported keyboard combinations.
return void

SendSpecialKeys() public method

Sends a keyboard combination that would otherwise be reserved for the client PC.
Keyboard combinations are Pressed and then Released, while single keys (e.g., SpecialKeys.Ctrl) are only pressed so that subsequent keys will be modified.
Thrown if the RemoteDesktop control is not in the Connected state.
public SendSpecialKeys ( SpecialKeys keys, bool release ) : void
keys SpecialKeys SpecialKeys is an enumerated list of supported keyboard combinations.
release bool
return void

SetInputMode() public method

Changes the input mode to view-only or interactive.
public SetInputMode ( bool viewOnly ) : void
viewOnly bool True if view-only mode is desired (no mouse/keyboard events will be sent).
return void

SetScalingMode() public method

Set the remote desktop's scaling mode.
public SetScalingMode ( bool scaled ) : void
scaled bool Determines whether to use desktop scaling or leave it normal and clip.
return void

SetupDesktop() protected method

Creates and initially sets-up the local bitmap that will represent the remote desktop image.
Thrown if the RemoteDesktop control is not already in the Connected state. See .
protected SetupDesktop ( ) : void
return void

StopListen() public method

Stop Listening.
public StopListen ( ) : void
return void

VncClientConnectionLost() protected method

RemoteDesktop listens for ConnectionLost events from the VncClient object.
protected VncClientConnectionLost ( object sender, EventArgs e ) : void
sender object The VncClient object that raised the event.
e System.EventArgs An empty EventArgs object.
return void

VncServerCutText() protected method

protected VncServerCutText ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void

VncUpdate() protected method

protected VncUpdate ( object sender, VncEventArgs e ) : void
sender object
e VncEventArgs
return void

Property Details

GetPassword public_oe property

Points to a Function capable of obtaining a user's password. By default this means using the PasswordDialog.GetPassword() function; however, users of RemoteDesktop can replace this with any function they like, so long as it matches the delegate type.
public AuthenticateDelegate GetPassword
return AuthenticateDelegate