using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using MercatorApi;
using MercatorUi;
using System.Windows.Forms;

namespace SigStock
{
    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.FindMovableControlsByType(typeof(MercatorUi.Forms.Sig.SigObjects.TarifQ));
            if (l.Count > 0)
            {
                MercatorUi.Forms.Sig.SigObjects.TarifQ tarifQ = (MercatorUi.Forms.Sig.SigObjects.TarifQ)l[0];
                tarifQ.AfterRead += new MercatorUi.Forms.Sig.SigObjects.TarifQ.AfterReadHandler(tarifQ_AfterRead);
            }
        }

        public void FormClosedCustomize(System.Windows.Forms.Form WindowsForm)
        {
            MercatorUi.Forms.Sig.SigForm sigForm = (MercatorUi.Forms.Sig.SigForm)WindowsForm;
            List<Control> l = sigForm.FindMovableControlsByType(typeof(MercatorUi.Forms.Sig.SigObjects.TarifQ));
            if (l.Count > 0)
            {
                MercatorUi.Forms.Sig.SigObjects.TarifQ tarifQ = (MercatorUi.Forms.Sig.SigObjects.TarifQ)l[0];
                tarifQ.AfterRead -= new MercatorUi.Forms.Sig.SigObjects.TarifQ.AfterReadHandler(tarifQ_AfterRead);
            }
        }

        void tarifQ_AfterRead(object sender, EventArgs e)
        {
            MercatorUi.Forms.Sig.SigObjects.TarifQ tarifQ = (MercatorUi.Forms.Sig.SigObjects.TarifQ)sender;
            tarifQ.Grid.Columns[0].Width = 500;
        }
    }
}