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 ControlBottomBasic : UserControl
    {
        #region Field
        private FormMenu m_ParentForm;

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

        #region Constructor
        public ControlBottomBasic(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_MenuBottomBasic.Help;

            this.CollectionButtonMenu = new Collection<SmartButton>();
            this.CollectionButtonMenu.Clear();
            this.CollectionButtonMenu.Add(this.buttonHelp);
            this.CollectionButtonMenu.Add(this.buttonTime);
            this.CollectionButtonMenu.Add(this.buttonProduct);
            this.CollectionButtonMenu.Add(this.buttonDataBackup);
            this.CollectionButtonMenu.Add(this.buttonDataStatistics);
        }

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

        public void UpdateDisplayMenuButton(Define.E_MenuBottomBasic menu)
        {
            switch (menu)
            {
                case Define.E_MenuBottomBasic.DataBackup:
                    if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonHelp.ButtonUp();
                    if (this.buttonTime.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonTime.ButtonUp();
                    if (this.buttonProduct.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonProduct.ButtonUp();
                    if (this.buttonDataBackup.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
                        this.buttonDataBackup.ButtonDown();
                    if (this.buttonDataStatistics.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonDataStatistics.ButtonUp();
                    break;
                case Define.E_MenuBottomBasic.DataStatistics:
                    if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonHelp.ButtonUp();
                    if (this.buttonTime.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonTime.ButtonUp();
                    if (this.buttonProduct.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonProduct.ButtonUp();
                    if (this.buttonDataBackup.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonDataBackup.ButtonUp();
                    if (this.buttonDataStatistics.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
                        this.buttonDataStatistics.ButtonDown();
                    break;
                case Define.E_MenuBottomBasic.Help:
                    if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
                        this.buttonHelp.ButtonDown();
                    if (this.buttonTime.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonTime.ButtonUp();
                    if (this.buttonProduct.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonProduct.ButtonUp();
                    if (this.buttonDataBackup.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonDataBackup.ButtonUp();
                    if (this.buttonDataStatistics.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonDataStatistics.ButtonUp();
                    break;
                case Define.E_MenuBottomBasic.Product:
                    if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonHelp.ButtonUp();
                    if (this.buttonTime.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonTime.ButtonUp();
                    if (this.buttonProduct.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
                        this.buttonProduct.ButtonDown();
                    if (this.buttonDataBackup.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonDataBackup.ButtonUp();
                    if (this.buttonDataStatistics.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonDataStatistics.ButtonUp();
                    break;
                case Define.E_MenuBottomBasic.Time:
                    if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonHelp.ButtonUp();
                    if (this.buttonTime.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
                        this.buttonTime.ButtonDown();
                    if (this.buttonProduct.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonProduct.ButtonUp();
                    if (this.buttonDataBackup.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonDataBackup.ButtonUp();
                    if (this.buttonDataStatistics.ButtonStatus != SmartButton.BUTSTATUS.UP)
                        this.buttonDataStatistics.ButtonUp();
                    break;
                default:
                    break;
            }
        }

        public void DisplayRefresh(SystemStatus status)
        {
            this.buttonHelp.ButtonDown();
            this.buttonDataBackup.ButtonUp();
            this.buttonDataStatistics.ButtonUp();
            this.buttonProduct.ButtonUp();
            this.buttonTime.ButtonUp();

            this.CurrentMenu = Define.E_MenuBottomBasic.Help;
            this.ParentForm.DisplayBottomBasic(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_MenuBottomBasic.Help;
            else if (button == this.buttonTime)
                this.CurrentMenu = Define.E_MenuBottomBasic.Time;
            else if (button == this.buttonProduct)
                this.CurrentMenu = Define.E_MenuBottomBasic.Product;
            else if (button == this.buttonDataBackup)
                this.CurrentMenu = Define.E_MenuBottomBasic.DataBackup;
            else if (button == this.buttonDataStatistics)
                this.CurrentMenu = Define.E_MenuBottomBasic.DataStatistics;
            else
                this.CurrentMenu = Define.E_MenuBottomBasic.Help;

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