Life Beyond WinForms

Upgrade Windows Forms apps to cross-platform web and mobile applications.

by Levie Rufenacht

Introduction

Windows Forms (WinForms) is a widely used application development framework for building desktop applications on Windows. The framework powers mission-critical applications across the globe spanning every industry imaginable. The framework, which was open-sourced on December 4, 2018, is maintained by an active community of developers with over 230+ contributors and daily check-ins.

While the framework is actively maintained, a number of problems may exist in companies that cause them to consider moving away from WinForms. These could be due to both internal and external pressures such as demand from customers, management, or “future-proofing” the technology stack to align with industry trends.

Reasons for Migration

Availability

Thanks to remote work, customers and employees demand that applications be accessible at any time, from anywhere in the world, and on any platform. Using a remote desktop may provide a quick solution to provide teams with access to internal applications, but doesn’t provide a solution to the underlying issue that is the modernization of the application itself.

User Experience

For some companies, the user experience might be a core focus that drives them towards application modernization on the web. It’s becoming increasingly common that customers access applications via a web interface instead of traditional methods such as an executable download. They expect the application to look and “feel” like a modern web application.

When customers analyze a company’s product over its competitors, all functionality being equal, it makes sense for the customer to choose the web-based solution over the company providing a desktop solution.

Future-Proofing

A common but simple thought by management might be “how do we stay competitive?” and the solution usually involves an analysis of industry trends and how they can be applied to existing software products. Oftentimes this can require a rewrite of the existing product in an entirely new technology that is unknown or involves a significant learning curve for developers at the company.

Maintainability

Desktop applications often require manual installation and updates which can lead to errors or delays in accessing new features or security patches. Additionally, supporting multiple versions of a desktop application can strain resources, as developers need to allocate time and effort to maintain compatibility and provide technical support for older versions. These factors can contribute to a higher cost and effort associated with maintaining and updating desktop applications

Introducing Wisej.NET

Wisej.NET is an enterprise-scale web development framework that caters to the needs of existing WinForms developers. Wisej.NET allows these developers to be productive on day one by removing the need to learn JavaScript, HTML, and CSS and instead use only C# or VB.NET.

Each one of the hundreds of controls available in Wisej.NET contains two components: a server-side C# object and a client-side JavaScript object. Both components are always synchronized meaning that changing the text of an input element on the client’s browser will automatically update the Text property of the corresponding TextBox .NET object. The two sides communicate using a single, secured, and session-specific API endpoint that utilizes JSON and WebSocket.

Wisej.NET comes with a pixel-perfect designer for Visual Studio installed via the Visual Studio Marketplace. Similar to Windows Forms, a set of controls exist in the toolbox which can be dragged, dropped, and modified on the visual designer. Every control added to the Wisej.NET designer is a pure HTML5 web component as an Input, Button, or iFrame element.

Development Paradigm

Wisej.NET adopts a development paradigm that's similar to WinForms, providing a responsive event-driven programming model that is familiar to many .NET developers. This approach allows developers to create highly interactive web applications using the .NET framework, leveraging the event-driven style of WinForms.

Supported Architectures

Wisej.NET can accommodate modern architectural patterns such as Model-View-Controller (MVC) and Model-View-ViewModel (MVVM). In the case of MVC, Wisej.NET can handle the controller's actions, where business logic is processed, and efficiently manage the views for presenting data. As for the MVVM pattern, Wisej.NET can be used to bind ViewModel properties to the user interface, enabling changes in the model to automatically update the view and vice versa.

Namespaces

In an effort to simplify migrations from WinForms to web, Wisej.NET integrates all of the WinForms controls as web controls under a new namespace. For example, System.Windows.Forms.Button becomes Wisej.Web.Button.

A Simple Example

Wisej.NET’s API includes classes such as TextBox, Button, ComboBox, DataGridView, and many others that can be configured, styled, and added into layout objects instances of classes such as FlowLayoutPanel, FlexLayoutPanel, TableLayoutPanel, and others.

The following example shows the creation of a Wisej.NET Form:

/// <summary>
/// A visible Window in the browser.
/// </summary>
public partial class MainWindow : Form
{
	public MainWindow()
	{ 
		InitializeComponent();
	}
 
	// event handler for Form / Window initialization.
	private void Window1_Load(object sender, EventArgs e)
	{
		// create a new TextBox with a label.
		var textBox = new TextBox { LabelText = "Enter your email" };
 
		// create a new Button with some text.
		var button = new Button { Text = "Sign up" };
 
		// create a "success" label.
		var label = new Label();
 
		// attach to the button's click event.
		button.Click += (se, ev) =>
		{
			label.Text = $"Welcome: {textBox.Text}";
		};
 
		// add the controls to the view.
		this.flexLayoutPanel.Controls.AddRange(new Control[] { textBox, button, label });
	}
}

The following is a screenshot of the previous example:

Mobile Development

The same development paradigm that is shown above can be applied to mobile development with Wisej.NET Hybrid. Hybrid applications are web applications that can interact with native device features such as biometric authentication, native document scanning, utilization of native UI components such as status bar colors, the native tab bar, and more.

Wisej.NET Hybrid is built on top of .NET MAUI and can leverage any MAUI feature and more.

Simple Example

/// <summary>
/// A visible Window in the browser.
/// </summary>
public partial class MainWindow : Form
{
	public MainWindow()
	{ 
		InitializeComponent();
	}
 
	// event handler for Form / Window initialization.
	private void Window1_Load(object sender, EventArgs e)
	{
		// change the status bar color.
		Device.StatusBar.BackColor = ColorTranslator.FromHtml("#353A40");

		// change the bottom bar color.
		Device.BottomBar.BackColor = ColorTranslator.FromHtml("#353A40");
	}

	private void buttonLogin_Click(object sender, EventArgs e)
	{
		var username = this.textBoxUsername.Text;
		var password = this.textBoxPassword.Text;

		LoginUser(username, password);
	}

	private void LoginUser(string username, string password)
	{
		// insert login logic.
		Device.Popups.DisplayAlert("Welcome", $"Welcome back, {username}");
	}
}

Hybrid applications can either run online connected to an external web server or offline using an embedded web server (EmbedIO).

Conclusion

WinForms is a great framework for creating powerful desktop applications, but in the case that the application needs to be modernized for the web, Wisej.NET provides a great solution. Wisej.NET’s visual designer and development paradigm make it easy for WinForms developers to use their existing knowledge to build or migrate enterprise-scale applications for the web. Wisej.NET supports any architecture and includes a set of 100+ web controls.

Get Started

Wisej.NET is available for free to independent developers.

For enterprise inquiries reach out to sales@wisej.com.

Last updated

Logo

© Ice Tea Group LLC, All Rights Reserved.