using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace TestMovableObject
{
    public partial class TestUserControl : UserControl, MercatorUi.MovableControls.Interfaces.IMovableControl
    {

        public TestUserControl()
        {
            InitializeComponent();
        }

#region propriétés requises par IMovableControl

        // la Form qui héberge ce MovableObject
        private MercatorUi.MovableControls.Interfaces.IFormForMovableControls _form = null;
        public MercatorUi.MovableControls.Interfaces.IFormForMovableControls Form { get { return _form; } set { if (_form == null) _form = value; } }


        // indique que le contrôle est à la disposition de l'utilisateur : tous les évènements du style "valueChanged" sont causés par l'utilisateur, pas par Mercator
        private bool _userMode = false;
        public bool UserMode { get { return _userMode; } set { _userMode = value; } }

        internal bool afterDone = false;
        public bool AfterDone { get { return afterDone; } set { afterDone = value; } }
        
        private List<MercatorUi.MovableControls.MovableExpression> _expressionsToRefresh = null;
        public List<MercatorUi.MovableControls.MovableExpression> ExpressionsToRefresh { get { return _expressionsToRefresh; } set { _expressionsToRefresh = value; } }

#endregion


#region méthodes requises par IMovableControl

        public void OnAfterRead(EventArgs e)
        {
            if (Form is MercatorUi.Forms.Sig.SigForm)
            {
                MercatorUi.Forms.Sig.SigForm sigForm = (MercatorUi.Forms.Sig.SigForm)Form;
                label1.Text = string.Format("Vous êtes dans le signalétique {0} et la fiche en cours est \"{1}\" !", sigForm.Sig.Module, sigForm.DataSourceRow[sigForm.Sig.Letter1 + "_ID"]);
            }
        }

        public void OnBeforeWrite(EventArgs e)
        {

        }

        public void OnAfterWrite(EventArgs e)
        {
            
        }

#endregion

        private void button1_Click(object sender, EventArgs e)
        {
            if (Form is MercatorUi.Forms.Sig.SigForm)
            {
                MercatorUi.Forms.Sig.SigForm sigForm = (MercatorUi.Forms.Sig.SigForm)Form;
                if (sigForm.Sig.Module == MercatorUi.Sig._SigEnum.STOCK)
                    MercatorUi.Dialogs.Stop(sigForm.DataSourceRow["S_MODELE"].ToString());
                else
                    MercatorUi.Dialogs.Stop(sigForm.DataSourceRow[sigForm.Sig.Letter1 + "_NOM"].ToString());
            }
        }
    }
}