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.Forms; namespace ITC81DB.Controls { public partial class ControlBottomInformation : UserControl { #region Field private FormMenu m_ParentForm; private DataStore.MenuBottomInformation CurrentMenu; private Collection 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 = DataStore.MenuBottomInformation.Help; this.CollectionButtonMenu = new Collection(); this.CollectionButtonMenu.Clear(); this.CollectionButtonMenu.Add(this.buttonHelp); this.CollectionButtonMenu.Add(this.buttonAS); this.CollectionButtonMenu.Add(this.buttonInformation); } public void CurrentControlEnable(bool enable) { foreach (SmartButton button in this.CollectionButtonMenu) button.Enabled = enable; } public void UpdateMenuDisplay(SystemStatus status) { switch (status.CurrentUser.Group) { case DataStore.UserGroup.Level1Operator: this.buttonAS.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsInforAS; this.buttonInformation.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsInforSystem; break; case DataStore.UserGroup.Level2Engineer: this.buttonAS.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsInforAS; this.buttonInformation.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsInforSystem; break; case DataStore.UserGroup.Level3Manager: this.buttonAS.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsInforAS; this.buttonInformation.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsInforSystem; break; case DataStore.UserGroup.Level4Developer: this.buttonAS.Enabled = true; this.buttonInformation.Enabled = true; break; case DataStore.UserGroup.NotLogin: this.buttonAS.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsInforAS; this.buttonInformation.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsInforSystem; break; default: break; } } public void UpdateDisplayMenuButton(DataStore.MenuBottomInformation menu) { switch (menu) { case DataStore.MenuBottomInformation.Help: if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.DOWN) this.buttonHelp.ButtonDown(); if (this.buttonInformation.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonInformation.ButtonUp(); if (this.buttonAS.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonAS.ButtonUp(); break; case DataStore.MenuBottomInformation.SystemInformation: if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonHelp.ButtonUp(); if (this.buttonInformation.ButtonStatus != SmartButton.BUTSTATUS.DOWN) this.buttonInformation.ButtonDown(); if (this.buttonAS.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonAS.ButtonUp(); break; case DataStore.MenuBottomInformation.AS: if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonHelp.ButtonUp(); if (this.buttonInformation.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonInformation.ButtonUp(); if (this.buttonAS.ButtonStatus != SmartButton.BUTSTATUS.DOWN) this.buttonAS.ButtonDown(); break; default: break; } } public void DisplayRefresh(SystemStatus status) { this.buttonHelp.ButtonDown(); this.buttonInformation.ButtonUp(); this.buttonAS.ButtonUp(); this.CurrentMenu = DataStore.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 = DataStore.MenuBottomInformation.Help; else if (button == this.buttonInformation) this.CurrentMenu = DataStore.MenuBottomInformation.SystemInformation; else if (button == this.buttonAS) this.CurrentMenu = DataStore.MenuBottomInformation.AS; else this.CurrentMenu = DataStore.MenuBottomInformation.Help; this.ParentForm.DisplayBottomInformation(this.CurrentMenu); } #endregion } }