Dit customizervoorbeeld toont het gebruik van de event AfterRead, BeforeWrite en AfterWrite in het informatiebestand "Klanten". Het werd opgesteld op basis van een SigCli-customizer die de volgende interfaces implementeert:
De code die enkel werd geschreven om deze 3 event te begrijpen, ziet er als volgt uit:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using MercatorApi;
using MercatorUi;
using System.Windows.Forms;
namespace SigCli
{
public class Customizer : MercatorUi.ICustomizers. IFormLoadCustomizer , MercatorUi.ICustomizers. IFormClosedCustomizer
{
public void FormLoadCustomize(System.Windows.Forms. Form WindowsForm)
{
MercatorUi.Forms.Sig. SigForm sigForm = (MercatorUi.Forms.Sig. SigForm )WindowsForm;
List < Control > l = sigForm.FindMovableControlsBySource( "C_NOM" );
if (l.Count > 0)
{
MercatorUi.MovableControls. MovableTextBox textBox = (MercatorUi.MovableControls. MovableTextBox )l[0];
textBox.AfterRead += new MercatorUi.MovableControls. MovableTextBox . AfterReadHandler (textBox_AfterRead);
textBox.BeforeWrite += new MercatorUi.MovableControls. MovableTextBox . BeforeWriteHandler (textBox_BeforeWrite);
textBox.AfterWrite += new MercatorUi.MovableControls. MovableTextBox . AfterWriteHandler (textBox_AfterWrite);
}
}
public void FormClosedCustomize(System.Windows.Forms. Form WindowsForm)
{
MercatorUi.Forms.Sig. SigForm sigForm = (MercatorUi.Forms.Sig. SigForm )WindowsForm;
List < Control > l = sigForm.FindMovableControlsBySource( "C_NOM" );
if (l.Count > 0)
{
MercatorUi.MovableControls. MovableTextBox textBox = (MercatorUi.MovableControls. MovableTextBox )l[0];
textBox.AfterRead -= new MercatorUi.MovableControls. MovableTextBox . AfterReadHandler (textBox_AfterRead);
textBox.BeforeWrite -= new MercatorUi.MovableControls. MovableTextBox . BeforeWriteHandler (textBox_BeforeWrite);
textBox.AfterWrite -= new MercatorUi.MovableControls. MovableTextBox . AfterWriteHandler (textBox_AfterWrite);
}
}
void textBox_AfterRead( object sender, EventArgs e)
{
MercatorUi.MovableControls. MovableTextBox textBox = (MercatorUi.MovableControls. MovableTextBox )sender;
MercatorUi. Dialogs .Stop( string .Format( "De in de DB gelezen waarde is \"{0}\"." , textBox.Text));
}
void textBox_BeforeWrite( object sender, EventArgs e)
{
MercatorUi.MovableControls. MovableTextBox textBox = (MercatorUi.MovableControls. MovableTextBox )sender;
MercatorUi. Dialogs .Stop( string .Format( "De waarde die in geval van wijziging in de DB zal worden ingevoerd, is \"{0}\"." , textBox.Text));
}
void textBox_AfterWrite( object sender, EventArgs e)
{
MercatorUi.MovableControls. MovableTextBox textBox = (MercatorUi.MovableControls. MovableTextBox )sender;
MercatorUi. Dialogs .Stop( string .Format( "De waarde \"{0}\" is in de DB ingevoerd." , textBox.Text));
}
}
}