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 ITC81DB_2.Forms;

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

        private Define.E_MenuBottomInformation CurrentMenu;
        private Collection<SmartButton> CollectionButtonMenu;
        #endregion

        #region Constructor
        public ControlBottomInformation(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 = Define.E_MenuBottomInformation.Help;

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

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

        public void UpdateDisplayMenuButton(Define.E_MenuBottomInformation menu)
        {
            switch (menu)
            {
                case Define.E_MenuBottomInformation.Help:
                    if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
                        this.buttonHelp.ButtonDown();
                    if (this.buttonSystemInformation.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonSystemInformation.ButtonUp();
                    if (this.buttonASInformation.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonASInformation.ButtonUp();
                    break;
                case Define.E_MenuBottomInformation.SystemInformation:
                    if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonHelp.ButtonUp();
                    if (this.buttonSystemInformation.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
                        this.buttonSystemInformation.ButtonDown();
                    if (this.buttonASInformation.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonASInformation.ButtonUp();
                    break;
                case Define.E_MenuBottomInformation.AS:
                    if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonHelp.ButtonUp();
                    if (this.buttonSystemInformation.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonSystemInformation.ButtonUp();
                    if (this.buttonASInformation.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
                        this.buttonASInformation.ButtonDown();
                    break;
                default:
                    break;
            }
        }

        public void DisplayRefresh(SystemStatus status)
        {
            this.buttonHelp.ButtonDown();
            this.buttonSystemInformation.ButtonUp();
            this.buttonASInformation.ButtonUp();

            this.CurrentMenu = Define.E_MenuBottomInformation.Help;
            this.ParentForm.DisplayBottomInformation(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 = Define.E_MenuBottomInformation.Help;
            else if (button == this.buttonSystemInformation)
                this.CurrentMenu = Define.E_MenuBottomInformation.SystemInformation;
            else if (button == this.buttonASInformation)
                this.CurrentMenu = Define.E_MenuBottomInformation.AS;
            else
                this.CurrentMenu = Define.E_MenuBottomInformation.Help;

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