.NET WinForms Framework - 1.0
Description
This extension provides support for Windows Forms . Windows Forms is a web app development framework for DotNet that includes a large library of UI components.
Function Point, Quality and Sizing support
- Function Points (transactions): a green tick indicates that OMG Function Point counting and Transaction Risk Index are supported
- Quality and Sizing: a green tick indicates that CAST can measure size and that a minimum set of Quality Rules exist
| Function Points (transactions) | Quality and Sizing |
|---|---|
| ✅ | ❌ |
The transaction model provided in this extension designates Windows Forms Form objects as Entry Point Transactions. When CAST cannot link a Windows Forms Event Subscription object to its corresponding Windows Forms Form, it designates the event subscription as an Entry Point Transaction as a fallback. The existing model (defined by com.castsoftware.dotnet.config.tcc (v. 1.6.0-funcrel or later)) designates C# Forms objects as Entry Point Transactions. This legacy definition remains supported unless the com.castsoftware.dotnet.winforms extension declares the same Entry Point Transaction based on the C# class name, in which case the legacy definition is overwritten.
Technical information
Once the analysis/snapshot generation has completed, you can view the results in the normal manner. The following objects and links will be resolved:
Objects
| Icon | Object Type | Description |
|---|---|---|
| Windows Forms Form | Created when a class inherits from System.Windows.Forms.Form. | |
![]() |
Windows Forms Event Subscription | Event Subcription is composed of the controller and the C# Event about to be registered, e.g: my_submit_button.Click. |
Table of supported controllers and C# Events:
| API String | Controller Type(s) |
|---|---|
| System.Windows.Forms.Control.Click.add System.Windows.Forms.Control.GotFocus.add System.Windows.Forms.Control.LostFocus.add System.Windows.Forms.Control.TextChanged.add |
Control (all controls inherit from Control) |
| System.Windows.Forms.Control.DoubleClick.add | Control (all controls inherit from Control), ListBox |
| System.Windows.Forms.Control.Leave.add System.Windows.Forms.Control.Enter.add |
Control (all controls inherit from Control), TextBox |
| System.Windows.Forms.TextBox.KeyDown.add System.Windows.Forms.TextBox.KeyPress.add System.Windows.Forms.TextBox.KeyUp.add |
TextBox |
| System.Windows.Forms.Button.DoubleClick.add | Button |
| System.Windows.Forms.CheckBox.CheckedChanged.add | CheckBox |
| System.Windows.Forms.RadioButton.CheckedChanged.add | RadioButton |
| System.Windows.Forms.ComboBox.DropDown.add System.Windows.Forms.ComboBox.SelectedIndexChanged.add System.Windows.Forms.ComboBox.SelectedValueChanged.add System.Windows.Forms.ComboBox.TextChanged.add |
ComboBox |
| System.Windows.Forms.ListBox.SelectedIndexChanged.add System.Windows.Forms.ListBox.DoubleClick.add |
ListBox |
| System.Windows.Forms.DataGridView.SelectionChanged.add System.Windows.Forms.DataGridView.CellValueChanged.add System.Windows.Forms.DataGridView.CellClick.add System.Windows.Forms.DataGridView.CellDoubleClick.add System.Windows.Forms.DataGridView.RowEnter.add System.Windows.Forms.DataGridView.RowLeave.add |
DataGridView |
| System.Windows.Forms.Timer.Tick.add | Timer |
Links
| Link Type | Caller type | Callee type | Details / Comments |
|---|---|---|---|
| callLink | Windows Forms Form | Windows Form Event Subscription | based on in which Form the controller is added. |
| callLink | Windows Forms Event Subscription | C# Method | the Handling c# method registered which the Event Subscription. |
What results can you expect?
Basic example
using System;
using System.Windows.Forms;
public class CheckBoxExample : Form
{
private CheckBox myCheckBox;
public CheckBoxExample()
{
myCheckBox = new CheckBox();
myCheckBox.Text = "Enable feature";
// Event subscriptions
myCheckBox.CheckedChanged += new EventHandler(MyCheckBox_CheckedChanged);
myCheckBox.GotFocus += new EventHandler(MyCheckBox_GotFocus);
myCheckBox.LostFocus += new EventHandler(MyCheckBox_LostFocus);
this.Controls.Add(myCheckBox);
}
private void MyCheckBox_CheckedChanged(object sender, EventArgs e)
{
Console.WriteLine("CheckBox state changed: " + myCheckBox.Checked);
}
private void MyCheckBox_GotFocus(object sender, EventArgs e)
{
Console.WriteLine("CheckBox got focus");
}
private void MyCheckBox_LostFocus(object sender, EventArgs e)
{
Console.WriteLine("CheckBox lost focus");
}
[STAThread]
public static void Main()
{
Application.EnableVisualStyles();
Application.Run(new CheckBoxExample());
}
}

Complex example with partial class
Calculator.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace PHARMACY
{
public partial class Calculator : Form
{
Double results = 0;
String operation = "";
bool isOperationPerformed = false;
public Calculator()
{
InitializeComponent();
System.Drawing.Icon ico = new System.Drawing.Icon("C:\\PMS\\Resources\\form-icon.ico");
this.Icon = ico;
}
private void button_click(object sender, EventArgs e)
{
if ((resultsTextBox.Text == "0") || (isOperationPerformed))
resultsTextBox.Clear();
isOperationPerformed = false;
Button button = (Button)sender;
if (button.Text == ".")
{
if (!(resultsTextBox.Text.Contains(".")))
resultsTextBox.Text = resultsTextBox.Text + button.Text;
}
else
{
resultsTextBox.Text = resultsTextBox.Text + button.Text;
}
}
}
}
Calculator.Designer.cs
namespace PHARMACY
{
partial class Calculator
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
Button1.Click += new System.EventHandler(button_click);
this.Controls.Add(Button1);
}
#endregion
private System.Windows.Forms.Button Button1;
}
}

