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 Eigenschappen vereist door IMovableControl

        // Het Form dat dit MovableObject omvat.
        private MercatorUi.MovableControls.Interfaces.IFormForMovableControls _form = null;
        public MercatorUi.MovableControls.Interfaces.IFormForMovableControls Form { get { return _form; } set { if (_form == null) _form = value; } }


        // Geeft aan dat de controle beschikbaar is voor de gebruiker: alle event van de stijl "valueChanged" worden veroorzaakt door de gebruiker, niet door 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 Methodes vereist door 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("U bevindt zich in het informatiebestand {0} en de actieve fiche is \"{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());
            }
        }
    }
}