Writing a Layout Control
The following steps provide an overview of how to write a new Windows layout control for Aptify:
If using the template provided by Aptify for this project, configure the template as described in Loading the Sample Code and Templates, rename the project and class, and skip to Step 9.
- Open a new Class Library project in Visual Studio.
- Configure the Properties for the project.
- When assigning an assembly name for this object, use this format: [EntityName]LayoutControl (remove spaces in the entity name)For example: RentalAgreementsLayoutControl (or SampleRentalAgreementsLayoutControl, as shown in the figure below).
- Specify a root namespace for your project.For example: Aptify.SampleApplication.MotorLoaner, as shown below.
- Click the References tab in the Properties page and add a reference to the following Aptify objects:
- AptifyApplication
- AptifyExceptionManagement
- AptifyFormTemplateControls
- AptifyGenericDataServices
- AptifyGenericEntity
- AptifyGenericEntityBase
- AptifyUtility
- AptifyWindowsControls
- IAptifyDataServices
- IAptifyFormTemplateHost
System.Windows.Forms (this is a Microsoft .NET object)
References to the following Microsoft Objects should already exist in the project: System, System.Data, and System.Xml. You can find the Aptify objects in your Aptify Windows application's C:\Program Files\Aptify 5.5 directory.
- Open the class file.
- Add Option Explicit On and Option Strict On at the top of the class file (as described in Use Option Explicit and Option Strict.
- Add Imports Aptify.Framework.WindowsControls namespace to the class file to import the Aptify Windows Controls.
- Define the name for your class (typically this is Public Class [Entity Name]Layout).
- Add Inherits FormTemplateLayout below the class name.
- Declare the instances of the controls from the form with which this class will interact.
- In following figure, the RentalAgreementsLayout declares a variable for each field displayed on the Rental Agreements form. Each field has a variable that is declared as an instance of its particular Aptify Windows Control, such as an AptifyLinkBox or AptifyTextBox.
- In following figure, the RentalAgreementsLayout declares a variable for each field displayed on the Rental Agreements form. Each field has a variable that is declared as an instance of its particular Aptify Windows Control, such as an AptifyLinkBox or AptifyTextBox.
- Write a FindControls method to locate the controls on the form and assign them to the variables you declared to handle events.
- See the source code for the RentalAgreementsLayoutControl for its implementation of FindControls, a portion of which is shown in the figure below.
- Override the OnFormTemplateLoaded method that is called when the form has loaded.
- Write code to define the behavior required of the Layout Control.
- See the source code for the Rental Agreements Layout Control for an example of how to implement control visibility.
- The layout control implements three phases of a Rental Agreements record (Check-Out, Check-In, and Complete) and sets control visibility according to each phase. See An Example of the Effects of a Layout Control for an overview of how this control visibility translates to the user experience.
- See the _m_lnkVehicleID_ValueChanged_ method in the Rental Agreements Layout Control's source code for an example of how to automatically populate one field (StartingMileage) when a user populates another field (VehicleID) on the form.
- See the Aptify Software Development Kit (SDK) for information on other layout controls created for Aptify business applications, including these classes:
- Companies: Aptify.Applications.Companies.CompaniesLayout
- Persons: Aptify.Applications.Persons.PersonsLayout
- Products: Aptify.Applications.ProductSetup.WindowsControls.ProductLayout
- Orders: Aptify.Applications.OrderEntry.WindowsControls.OrdersLayout
- Build, test, and sign the assembly. See Best Practices When Writing Code for Aptify for details.
- Add the assembly to the Aptify Object Repository and link it to the appropriate form's top-level Form Templates record.
- See Adding a Layout Control for instructions on how to add the layout control to Aptify.
Copyright © 2014-2017 Aptify - Confidential and Proprietary