using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using MercatorUi;
using MercatorApi;
using System.Linq;

namespace SigCli
{
    public class Customizer : MercatorUi.ICustomizers.IFormLoadCustomizer
    {
        public void FormLoadCustomize(Form form)
        {
            MercatorUi.Forms.Sig.SigForm sigForm = (MercatorUi.Forms.Sig.SigForm)form;
            foreach(var textBoxPays in sigForm.MovableControls.Values.OfType<MercatorUi.MovableControls.MovableTextBox>().Where(c => c.Source == "C_PAYS"))
            {
                textBoxPays.Validator = new MercatorUi.Validators.ControlValidator(
                    textBoxPays,
                    "Le pays ne peut être vide !",
                    (s, e) =>
                        {
                            e.IsValid = !string.IsNullOrWhiteSpace(textBoxPays.Text);
                        }
                    );
            }
        }
    }
}