Saving and loading forms
How the IDE stores a form in generated code.
In this documentation
- Beep.Forms
- Architecture
- Authoring in the Object Navigator
- WinForms runtime
- WPF runtime
- End-to-end example
- Remote UI limitations
- Overview
- Context menus
- Blocks and items
- Triggers
- Lists of values
- Validation
- Master detail
- Navigation and queries
- Alerts, editors and timers
- Calling other forms
- Form menus
- Hosting in WinForms step by step
- Hosting in WPF step by step
- Saving and loading forms
- The IDE toolbar and dialogs
- Troubleshooting
Beep.Forms has no separate form file format. The IDE writes a form as C# in the form's .Designer.cs file, and for WPF in the .xaml.cs file, inside marked regions. When it opens the form again it scans those regions and reads the form back. These files are not Oracle .fmb files and are not compatible with them.
Marker regions
Each region starts and ends with a generated comment that begins // <copilot-generated-. The region names are:
bootstrap-shared: the host field.bootstrap-hooks: the host construction.bootstrap-registrations: block definitions.relationship-registrations,trigger-registrations,lov-registrations,validation-registrations.visualattribute-registrations,itemeditor-registrations,recordgroup-registrations,parameterlist-registrations.alert-registrations,editor-registrations,objectgroup-registrations,menu-registrations.
Where registrations live
The designer declares the host field as WinFormFormHost _formsHost and creates it in InitializeComponent. Block definitions are added to _formsHost.Definition.Blocks there. The other registrations are written into a method named RegisterBeepFormsMetadata, because the manager is still null while the designer runs. It starts by taking the manager from the host and throws "Assign _formsHost.FormsManager before calling RegisterBeepFormsMetadata()." when it is missing. It is safe to call again because registrations are keyed.
What the method contains
manager.Triggers.RegisterTrigger(new TriggerDefinition(TriggerType.X, TriggerScope.Y)
{
TriggerId = "block.item.Type", BlockName = "...", ItemName = "...", Handler = this.HandlerName
});
manager.LOV.RegisterLOV("block", "field", new LOVDefinition { /* ... */ });
manager.Validation.RegisterRule(new ValidationRule { /* ... */ });
manager.CreateMasterDetailRelation("master", "detail", "masterKey", "foreignKey");
manager.CreateAlert(name, title, message, AlertStyle.X, button1, button2, button3);
manager.CreateEditor(name, title, width, height, wrap, scroll);
manager.ItemProperties.SetItemEditor(block, item, editor);
manager.CreateRecordGroup(name, connection, entity, null);
manager.CreateParameterList(name);
A trigger id has three dot separated parts, for example ord.qty.WhenValidateItem, ord..PreQuery or ..WhenNewFormInstance. The handler must be a valid C# identifier. The IDE adds the handler method to the form's own partial class.
Trigger names
The IDE accepts Oracle style names such as "When-Validate-Item". It removes hyphens, underscores and spaces and matches the result to a TriggerType name without regard to case. A name that matches nothing writes no registration.
Block regions
Each block gets its own region marked with the block name. It creates a BlockDefinition, sets the block and entity members, adds a BlockFieldDefinition per field to Entity.Fields, and adds the block to the host's Definition.Blocks.