Introduction

About WebMAP: WinForms to Web

WebMAP: WinForms to Web is a tool designed to convert .NET Framework apps based on C# and Windows Forms to a modern web architecture:
    Business logic source code is converted to ASP.NET Core.
    The user interface(UI) rendered as HTML using Angular, JavaScript, and KendoUI.
For VB.Net, contact us for alternatives.

Code Conversions

Here is an example of the very first WinForms application any programmer would do. The program consists of a form and a button that changes the text. The comparison side by side with the converted app shows minimum alterations:
WinForms VS WebMAP
The emphasis of WebMap: WinForms to Web is the transparency for the developer from the original application to the converted one, which is also reflected in the following example code from C# to WebMAP.
Source code Form1.cs:
1
namespace HelloWorld
2
{
3
public partial class Form1 : Form
4
{
5
public Form1()
6
{
7
InitializeComponent();
8
}
9
10
private void button1_Click(object sender, EventArgs e)
11
{
12
this.label1.Text = "Hello World";
13
}
14
}
15
}
Copied!
Converted code Form1.cs:
1
namespace HelloWorld
2
{
3
4
[Observable]
5
public partial class Form1 : Mobilize.Web.Form
6
{
7
public Form1()
8
{
9
InitializeComponent();
10
}
11
12
private void button1_Click(object sender, EventArgs e)
13
{
14
this.label1.Text = "Hello World";
15
}
16
17
}
18
}
Copied!
The automation of web processes is clear for the user, thanks to internal libraries such as Weaving, that provides functions to interact with the BackEnd/CoreServices. So, the converted code does not add unnecessary complexity and maintains its similarity to the original.
The UI represents a new challenge to convert, and so, we tackle this problem by converting the Windows.Forms into an Angular component divided into three main files:
    1.
    HTML
    2.
    CSS
    3.
    TypeScript
For this same example, the form called Form1.cs is converted as:
Source code Form1.designer.cs
1
namespace HelloWorld
2
{
3
partial class Form1
4
{
5
/// <summary>
6
/// Required designer variable.
7
/// </summary>
8
private System.ComponentModel.IContainer components = null;
9
10
/// <summary>
11
/// Clean up any resources being used.
12
/// </summary>
13
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
14
protected override void Dispose(bool disposing)
15
{
16
if (disposing && (components != null))
17
{
18
components.Dispose();
19
}
20
base.Dispose(disposing);
21
}
22
23
Windows Form Designer generated code
24
25
private System.Windows.Forms.Button button1;
26
private System.Windows.Forms.Label label1;
27
}
28
}
Copied!
Every control declared inside the Form1.designer.cs file will have its corresponding HTML tag as is the case with Button.
Converted code form1.component.html
1
<div *ngIf="model">
2
<wm-window [model]="model" id="Form1" class="HelloWorld_Form1">
3
<ng-template let-model>
4
<div class="Form1">
5
<wm-label id="label1" [model]="model.label1" class="label1" tabindex="2">My First Sample</wm-label>
6
<wm-button id="button1" [model]="model.button1" class="button1" tabindex="1"></wm-button>
7
</div>
8
</ng-template>
9
</wm-window>
10
</div>
Copied!
Now, let's take a look at the .css file that pairs with the form1.component.html file:
Converted code form1.component.css
1
.HelloWorld_Form1 {
2
left: -1px;
3
top: -1px;
4
}
5
.HelloWorld_Form1 .Form1 {
6
width: 398px;
7
height: 143px;
8
overflow: hidden;
9
}
10
.HelloWorld_Form1 .label1 {
11
width: auto;
12
weight: bold;
13
font-size: 26.25px;
14
left: 12px;
15
top: 25px;
16
height: auto;
17
position: absolute;
18
white-space: nowrap;
19
overflow: hidden;
20
}
21
.HelloWorld_Form1 .button1 {
22
font-size: 14.25px;
23
left: 12px;
24
top: 78px;
25
width: 116px;
26
height: 50px;
27
position: absolute;
28
padding: 0px 0px 0px 0px;
29
display: table-cell;
30
vertical-align: middle;
31
display: table-cell;
32
}
Copied!
Also, the CSS files have a corresponding property for each control linked with the name of the class.
And finally, the typescript file contains an angular component class declaration for the Form class.
Converted code form1.component.ts
1
import { Component, ChangeDetectorRef, ElementRef
2
, Output, Renderer2, ViewEncapsulation} from "@angular/core";
3
import { EventData, dataTransfer} from "@mobilize/base-components";
4
import { FormComponent} from "@mobilize/winforms-components";
5
import { WebMapService} from "@mobilize/angularclient";
6
@Component({
7
selector : "hello-world-form1",
8
styleUrls : ["./form1.component.css"],
9
templateUrl : "./form1.component.html",
10
encapsulation : ViewEncapsulation.None
11
})
12
@dataTransfer(["frmHelloWorldForm1"])
13
export class Form1Component extends FormComponent {
14
protected webServices : WebMapService;
15
constructor (wmservice : WebMapService,
16
changeDetector : ChangeDetectorRef,render2 : Renderer2,elem : ElementRef) {
17
super(wmservice,changeDetector,render2,elem);
18
}
19
}
Copied!
Now you have covered the basics of what WebMAP: WinForms to Web conversion looks like. Let's proceed with a further explanation of how to run a full conversion process and run the output application by yourself.
Last modified 11mo ago