-
Notifications
You must be signed in to change notification settings - Fork 0
Desktop Viewer
The Display Viewer is a GUI client that can connect to the socket server and view near real time display changes. It is written using Avalonia, so it can be compiled to run on Windows, Linux and macOS. At the heart of this app is a standalone Avalonia control that communicates with the server and renders a duplicate of the display image. The control can also be placed within your own application.
There are both a graphics and command client version of the Avalonia control. The graphics control receives PNG images of the changed area of a screen and updates the GUI accordingly. The command client receives render commands that were processed by the server and renders them locally for display. The downside to this version is the fonts used on the server must be installed locally to render correctly. The upsides are a lot less network traffic is generated, and the GUI responds near instantly to commands processed by the server. The project currently uses the command client.
Both versions of the control can easily be included in your own Avalonia app for custom purposes. If you wish to use the graphics client, you need to copy GraphicsClient.cs and CommunicationService.cs to your project. If you wish to use the command client, you need to copy CommandClient.cs and CommunicationService.cs to your project as well as add the IoTDisplay.Common project to your solution and reference it. The command client utilizes the IoTDisplay renderer in the Common project to duplicate the screen. This will make the compiled size of your application somewhat larger due to the dependencies within the IoTDisplay.Common project itself.
MainWindow.axaml in the IoTDisplay.Desktop project is a sample screen that can use either control. This line
in the <Window>
tag adds the control's namespace so it can be used within the screen:
xmlns:views="clr-namespace:IoTDisplay.Desktop"
You can use your own namespace if you change the namespace in the client and CommunicationService classes.
In your screen or user control, add something similar to this:
<views:CommandClient Name="iotDisplay" Width="800" Height="480" SocketType="TCPSocket" Host="192.168.1.11">
</views:CommandClient>
Name is optional and for use within your own code. Width and Height should be no smaller than what the server is configured to use for the display. Details on the SocketType and Host can be found on the Configuration page. These values can also be set programmatically by your own code. The provided sample screen reads SocketType and Host from a configuration file, for example, and sets them in the code behind.
There is a ConnectionChanged event that is raised whenever the socket connection status changes. If desired, your program can look for that event and handle it accordingly. CommunicationService.ConnectionChangedEventArgs is passed as the event arguments with details on the connection change. The client also has IsConnected and ConnectionMessage properties with the current connection status.
The sample screen also looks for PointerPressed and PointerWheelChanged events on the client just to showcase the possibility of using those events to trigger context sensitive actions within your own application.