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

using SmartX;
using INT51DB.Forms;

namespace INT51DB.Controls
{
    public partial class ControlBottomConfiguration : UserControl
    {
        #region Field
        private FormMenu m_ParentForm;

        private DataStore.MenuBottomConfiguration CurrentMenu;
        private Collection<SmartButton> CollectionButtonMenu;
        #endregion

        #region Constructor
        public ControlBottomConfiguration(FormMenu parent)
        {
            InitializeComponent();

            this.ParentForm = parent;

            this.InitializeDesign();
            this.DefaultSetting();
        }
        #endregion

        #region Property
        public FormMenu ParentForm
        {
            get { return this.m_ParentForm; }
            private set { this.m_ParentForm = value; }
        }
        #endregion

        #region Method
        public void InitializeDesign()
        {
        }
        private void DefaultSetting()
        {
            this.CurrentMenu = DataStore.MenuBottomConfiguration.Help;

            this.CollectionButtonMenu = new Collection<SmartButton>();
            this.CollectionButtonMenu.Clear();
            this.CollectionButtonMenu.Add(this.buttonHelp);
            this.CollectionButtonMenu.Add(this.buttonCommunication);
            this.CollectionButtonMenu.Add(this.buttonOption);
        }

        public void CurrentControlEnable(bool enable)
        {
            foreach (SmartButton button in this.CollectionButtonMenu)
                button.Enabled = enable;
        }

        public void UpdateDisplayMenuButton(DataStore.MenuBottomConfiguration menu)
        {
            switch (menu)
            {
                case DataStore.MenuBottomConfiguration.Communication:
                    if (this.buttonCommunication.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
                        this.buttonCommunication.ButtonDown();
                    if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonHelp.ButtonUp();
                    if (this.buttonOption.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        buttonOption.ButtonUp();
                    break;
                case DataStore.MenuBottomConfiguration.Help:
                    if (this.buttonCommunication.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonCommunication.ButtonUp();
                    if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
                        this.buttonHelp.ButtonDown();
                    if (this.buttonOption.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        buttonOption.ButtonUp();
                    break;
                case DataStore.MenuBottomConfiguration.Option:
                    if (this.buttonCommunication.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonCommunication.ButtonUp();
                    if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonHelp.ButtonUp();
                    if (this.buttonOption.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
                        buttonOption.ButtonDown();
                    break;
                default:
                    break;
            }
        }

        public void DisplayRefresh(DataStore.UserGroup group)
        {
            this.buttonHelp.ButtonDown();
            this.buttonCommunication.ButtonUp();
            this.buttonOption.ButtonUp();

            this.CurrentMenu = DataStore.MenuBottomConfiguration.Help;
            this.ParentForm.DisplayBottomConfiguration(this.CurrentMenu);
        }
        #endregion

        #region Event Handler
        private void buttonMenu_Click(object sender, EventArgs e)
        {
            SmartButton button = sender as SmartButton;

            if (button == null)
                return;

            if (button == this.buttonHelp)
                this.CurrentMenu = DataStore.MenuBottomConfiguration.Help;
            else if (button == this.buttonCommunication)
                this.CurrentMenu = DataStore.MenuBottomConfiguration.Communication;
            else if (button == this.buttonOption)
                this.CurrentMenu = DataStore.MenuBottomConfiguration.Option;
            else
                this.CurrentMenu = DataStore.MenuBottomConfiguration.Help;

            this.ParentForm.DisplayBottomConfiguration(this.CurrentMenu);
        }
        #endregion
    }
}
