In this article, the basic concepts of Forms are explained.
In terms of the MVC concept, the Operations could be called the Controllers. The Forms would be the Views and the Database would be the Model.
A form communicates with the user. Information (handed down from an operation) can be presented and actions (for example button clicks) can invoke new actions.
The AI-Framework distinguishes three types:
Operation.SomePublicPropertyOrVar.See also: Operations
The following examples show the different type of forms.
public class InvoiceOverviewOp : FormOperationExBase
{
public InvoiceOverviewOp( ... , ... , IExpression<IDbKey<User>> userKey)
: base(database, customerKey)
{
RegisterInputParameter(UserKey, userKey);
}
protected override IForm CreateStartupForm()
{
return new InvoiceOverviewFrm(this);
}
...
This is an operation (normally we end the name of an operation file with the letters Op, as in InvoiceOverviewOp), that needs a form, in this case InvoiceOverviewFrm.
CreateStartupForm(), and returns an interface, namely IForm. Here, we tell the Operation which Form to use.this).public class InvoiceOverviewFrm : FormBase<InvoiceOverviewOp>
{
public InvoiceOverviewFrm(InvoiceOverviewOp operation)
: base(operation)
{
}
protected override IUIElement CreateGui()
{
return new VBox
{
...
This is the form, connected to the operation.
InvoiceOverviewOp.InvoiceOverviewOp is the base operation.CreateGui(), and returns an interface, IUIElement.Note 1: In the AI-Framework, the form has access to all public properties and methods of the operation.
The code is simply: Operation.SomeProperty for a property, or Operation.DoSomething() for a method.
Note 2: An operation may have more than one form. For example a form to show statistics, and another form to ask for additional input. A form can be associated with only one operation. In other words, the same form cannot be used for more than one operation.
public class ConfirmPriceOp: SimpleFormOperationBase
{
public ConfirmPriceOp(IDbDefinition database)
: base(database)
{
}
...
protected override IUIElement CreateGui(IForm form)
{
return new HBox
{
...
}
}
The operation ConfirmPriceOp needs one form. In this example, the form is defined and called within the operation class itself. The class inherits from SimpleFormOperationBase, in order to have the necessary elements available.
Different from the previous example, here the UI is overridden directly in line 10.
public class SomeApplication : FormApplicationBase, IFiliaalProcess
{
...
protected override IMenuItem[] CreateMenuItems()
{
var mainMenuItems = new List<IMenuItem>
{
new GroupMenuItem("articles", Images.Article)
{
new FunctionCallMenuItem(new ArticleMaintenanceOp(... some parameters ...)
.Start(this)
.AddDisabledWhen(... some boolean ...)
.Call())
{
VisibleWhen = IsActive
},
new FunctionCallMenuItem(new ArtikelAddOp(...
The class inherits from FormApplicationBase. This base contains the elements to build up a (grouped) menu structure.
CreateMenuItems and returns an interface.ArticleMaintenanceOp is called, with its parameters,See also Operations
See also the Tutorial: Setting up an operation and a form
Article ID: 167
Created: Tue, Aug 27, 2019
Last Updated: Thu, Jan 9, 2020
Online URL: https://wiki-ai-framework.abstract-it.nl/article/forms-167.html