Archive for the ‘ WPF ’ Category

Create Event Handlers for WPF frontends in Java

In one of the previous posts I showed how a WPF frontend can be controlled by a Java application. Furthermore, I demonstrated how proxies can be generated automatically that allows for more convenient way of programming the Java part. However, there is no way so far, to handle interaction of the user with the WPF frontend in the Java backend. This posts demonstrates the basics for such an implementation.

It uses the existing socket communication to send an event to the Java program whenever a relevant user interaction with the WPF frontend occurs. The java program interprets the received event and calls the corresponding handler that is selected depending on the type of event. Thus, to determine which event handler is to be called the type of event need to be set during modeling the user interface in XAML. To enable this, we will introduce a new attached property available to all controls.
Continue reading

Examples of Visual Effects in WPF/XAML

In this post we will create a WPF application that shows an color changing logo reflected on a polished surface. We will use nothing but XAML to create visual effects such as mirroring, a horizon, a spotlight and dynamic colorization of a grayscale image.

Continue reading

Generate Proxies for the WPF frontend

In the previous post we learned how a WPF user interface can be driven from a java application. The solution that was presented allows showing views, modifying controls’ properties, and starting or stopping animations. It is based on a set of generic functions that provide for the required functionality. Each one of these takes additional parameters to adress a specific view, control, animation, and property.

Assuming there is a control named mute in the view main. To set its boolean property checked to true, we need to call wpfFrontend.setWidgetPropertyBool("main", "mute", "checked", true). This call will fail, when the view, the control, or the property is not found for the given names, which can likely happen because of mispelling or after refactoring the user interface. Such errors cannot be detected by the Java compiler and will lead to runtime errors that are hard to detect. One can use proxies that encapsulate all the adressing in order to avoid these problems and offer a more convenient way to access the elements of the WPF frontend. Using proxies the modification of the control’s property can be done by a call to a setter, e.g. wpfFrontend.main.mute.setChecked(true).

This post shows how such Java proxies can be generated from a high-level description of the frontend elements.
Continue reading

Remote Control a WPF Frontend from Java

Windows Presentation Foundation is a powerful framework for building rich user interfaces that comes with great GUI builders. However, for creating the application logic WPF requires to use one of one of the .NET programming languages such as Visual Basic or C#. Java, also a great programming language for writing application logic, is not supported.

This post describes how to connect a an application written in Java to a WPF based user interface.

The solution uses socket communication, allowing to separate the user interface and its computation logic into different processes or programs. This can be necessary, if they are implemented in different programming languages. Furthermore, it allows to run frontend and backend on different machines or processors.
Continue reading