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; using ITC81DB.DialogForms; namespace ITC81DB.Controls { public partial class ControlBottomEquipment : UserControl { #region Field private FormMenu m_ParentForm; private DataStore.MenuBottomEquipment CurrentMenu; private Collection CollectionButtonMenu; #endregion #region Constructor public ControlBottomEquipment(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() { } public void DefaultSetting() { this.CurrentMenu = DataStore.MenuBottomEquipment.Help; this.CollectionButtonMenu = new Collection(); this.CollectionButtonMenu.Clear(); this.CollectionButtonMenu.Add(this.buttonHelp); this.CollectionButtonMenu.Add(this.buttonInitialize); this.CollectionButtonMenu.Add(this.buttonUpdate); this.CollectionButtonMenu.Add(this.buttonUser); this.CollectionButtonMenu.Add(this.buttonTest); this.CollectionButtonMenu.Add(this.buttonSystemLog); if (this.ParentForm.ParentForm.SystemConfig1.IsLogin == true) this.buttonUser.Visible = true; else this.buttonUser.Visible = false; } 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.buttonUpdate.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsEquipUpdate; this.buttonInitialize.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsEquipInitialize; this.buttonFunction.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsEquipFunctionSetting; this.buttonUser.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsEquipUserSetting; this.buttonEngineerSetting.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsEquipEngineerSetting; this.buttonSystemLog.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsEquipSystemLog; break; case DataStore.UserGroup.Level2Engineer: this.buttonUpdate.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsEquipUpdate; this.buttonInitialize.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsEquipInitialize; this.buttonFunction.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsEquipFunctionSetting; this.buttonUser.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsEquipUserSetting; this.buttonEngineerSetting.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsEquipEngineerSetting; this.buttonSystemLog.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsEquipSystemLog; break; case DataStore.UserGroup.Level3Manager: this.buttonUpdate.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsEquipUpdate; this.buttonInitialize.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsEquipInitialize; this.buttonFunction.Enabled = true; this.buttonUser.Enabled = true; this.buttonEngineerSetting.Enabled = true; this.buttonSystemLog.Enabled = true; break; case DataStore.UserGroup.Level4Developer: this.buttonUpdate.Enabled = true; this.buttonInitialize.Enabled = true; this.buttonFunction.Enabled = true; this.buttonUser.Enabled = true; this.buttonEngineerSetting.Enabled = true; this.buttonSystemLog.Enabled = true; break; case DataStore.UserGroup.NotLogin: this.buttonUpdate.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsEquipUpdate; this.buttonInitialize.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsEquipInitialize; this.buttonFunction.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsEquipFunctionSetting; this.buttonUser.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsEquipUserSetting; this.buttonEngineerSetting.Enabled = true; this.buttonSystemLog.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsEquipSystemLog; break; default: break; } } public void UpdateDisplayMenuButton(DataStore.MenuBottomEquipment menu) { switch (menu) { case DataStore.MenuBottomEquipment.FunctionSetting: if (this.buttonFunction.ButtonStatus != SmartButton.BUTSTATUS.DOWN) this.buttonFunction.ButtonDown(); if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonHelp.ButtonUp(); if (this.buttonInitialize.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonInitialize.ButtonUp(); if (this.buttonTest.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonTest.ButtonUp(); if (this.buttonUpdate.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonUpdate.ButtonUp(); if (this.buttonSystemLog.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonSystemLog.ButtonDown(); if (this.buttonUser.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonUser.ButtonUp(); if (this.buttonEngineerSetting.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonEngineerSetting.ButtonUp(); break; case DataStore.MenuBottomEquipment.Help: if (this.buttonFunction.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonFunction.ButtonUp(); if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.DOWN) this.buttonHelp.ButtonDown(); if (this.buttonInitialize.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonInitialize.ButtonUp(); if (this.buttonTest.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonTest.ButtonUp(); if (this.buttonUpdate.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonUpdate.ButtonUp(); if (this.buttonSystemLog.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonSystemLog.ButtonDown(); if (this.buttonUser.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonUser.ButtonUp(); if (this.buttonEngineerSetting.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonEngineerSetting.ButtonUp(); break; case DataStore.MenuBottomEquipment.Initialize: if (this.buttonFunction.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonFunction.ButtonUp(); if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonHelp.ButtonUp(); if (this.buttonInitialize.ButtonStatus != SmartButton.BUTSTATUS.DOWN) this.buttonInitialize.ButtonDown(); if (this.buttonTest.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonTest.ButtonUp(); if (this.buttonUpdate.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonUpdate.ButtonUp(); if (this.buttonSystemLog.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonSystemLog.ButtonDown(); if (this.buttonUser.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonUser.ButtonUp(); if (this.buttonEngineerSetting.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonEngineerSetting.ButtonUp(); break; case DataStore.MenuBottomEquipment.Test: if (this.buttonFunction.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonFunction.ButtonUp(); if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonHelp.ButtonUp(); if (this.buttonInitialize.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonInitialize.ButtonUp(); if (this.buttonTest.ButtonStatus != SmartButton.BUTSTATUS.DOWN) this.buttonTest.ButtonDown(); if (this.buttonUpdate.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonUpdate.ButtonUp(); if (this.buttonSystemLog.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonSystemLog.ButtonDown(); if (this.buttonUser.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonUser.ButtonUp(); if (this.buttonEngineerSetting.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonEngineerSetting.ButtonUp(); break; case DataStore.MenuBottomEquipment.SystemLog: if (this.buttonFunction.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonFunction.ButtonUp(); if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonHelp.ButtonUp(); if (this.buttonInitialize.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonInitialize.ButtonUp(); if (this.buttonTest.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonTest.ButtonUp(); if (this.buttonUpdate.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonUpdate.ButtonDown(); if (this.buttonSystemLog.ButtonStatus != SmartButton.BUTSTATUS.DOWN) this.buttonSystemLog.ButtonDown(); if (this.buttonUser.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonUser.ButtonUp(); if (this.buttonEngineerSetting.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonEngineerSetting.ButtonUp(); break; case DataStore.MenuBottomEquipment.Update: if (this.buttonFunction.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonFunction.ButtonUp(); if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonHelp.ButtonUp(); if (this.buttonInitialize.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonInitialize.ButtonUp(); if (this.buttonTest.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonTest.ButtonUp(); if (this.buttonUpdate.ButtonStatus != SmartButton.BUTSTATUS.DOWN) this.buttonUpdate.ButtonDown(); if (this.buttonSystemLog.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonSystemLog.ButtonDown(); if (this.buttonUser.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonUser.ButtonUp(); if (this.buttonEngineerSetting.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonEngineerSetting.ButtonUp(); break; case DataStore.MenuBottomEquipment.User: if (this.buttonFunction.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonFunction.ButtonUp(); if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonHelp.ButtonUp(); if (this.buttonInitialize.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonInitialize.ButtonUp(); if (this.buttonTest.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonTest.ButtonUp(); if (this.buttonUpdate.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonUpdate.ButtonUp(); if (this.buttonSystemLog.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonSystemLog.ButtonDown(); if (this.buttonUser.ButtonStatus != SmartButton.BUTSTATUS.DOWN) this.buttonUser.ButtonDown(); if (this.buttonEngineerSetting.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonEngineerSetting.ButtonUp(); break; case DataStore.MenuBottomEquipment.Engineer: if (this.buttonFunction.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonFunction.ButtonUp(); if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonHelp.ButtonUp(); if (this.buttonInitialize.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonInitialize.ButtonUp(); if (this.buttonTest.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonTest.ButtonUp(); if (this.buttonUpdate.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonUpdate.ButtonUp(); if (this.buttonSystemLog.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonSystemLog.ButtonDown(); if (this.buttonUser.ButtonStatus != SmartButton.BUTSTATUS.UP) this.buttonUser.ButtonUp(); if (this.buttonEngineerSetting.ButtonStatus != SmartButton.BUTSTATUS.DOWN) this.buttonEngineerSetting.ButtonDown(); break; default: break; } } private void UpdateDisplayUser(UserItem user) { if (user.Group == DataStore.UserGroup.Level4Developer && this.ParentForm.ParentForm.SystemConfig1.IsLogin == true) this.DisplayHiddenMenu(true); else this.DisplayHiddenMenu(false); //this.DisplayHiddenMenu(); } public void DisplayHiddenMenu(bool bValue) { if (this.ParentForm.ParentForm.SystemConfig1.IsLogin == true) this.buttonEngineerSetting.Location = new Point(456, 0); else this.buttonEngineerSetting.Location = new Point(385, 0); this.buttonEngineerSetting.Visible = bValue; } public void DisplayRefresh(SystemStatus status) { this.buttonHelp.ButtonDown(); this.buttonUpdate.ButtonUp(); this.buttonInitialize.ButtonUp(); this.buttonFunction.ButtonUp(); this.buttonUser.ButtonUp(); this.buttonTest.ButtonUp(); this.buttonSystemLog.ButtonUp(); this.CurrentMenu = DataStore.MenuBottomEquipment.Help; this.ParentForm.DisplayBottomEquipment(this.CurrentMenu); this.UpdateDisplayUser(status.CurrentUser); } #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.MenuBottomEquipment.Help; else if (button == this.buttonUpdate) this.CurrentMenu = DataStore.MenuBottomEquipment.Update; else if (button == this.buttonInitialize) this.CurrentMenu = DataStore.MenuBottomEquipment.Initialize; else if (button == this.buttonFunction) this.CurrentMenu = DataStore.MenuBottomEquipment.FunctionSetting; else if (button == this.buttonSystemLog) this.CurrentMenu = DataStore.MenuBottomEquipment.SystemLog; else if (button == this.buttonUser) this.CurrentMenu = DataStore.MenuBottomEquipment.User; else if (button == this.buttonTest) this.CurrentMenu = DataStore.MenuBottomEquipment.Test; else if (button == this.buttonEngineerSetting) this.CurrentMenu = DataStore.MenuBottomEquipment.Engineer; else this.CurrentMenu = DataStore.MenuBottomEquipment.Help; this.ParentForm.DisplayBottomEquipment(this.CurrentMenu); } #endregion } }