254 lines
12 KiB
C#
254 lines
12 KiB
C#
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_0H.Forms;
|
|
using ITC81DB_2H.Datastore;
|
|
|
|
namespace ITC81DB_0H.Controls
|
|
{
|
|
public partial class ControlBottomConfiguration : UserControl
|
|
{
|
|
#region Field
|
|
private FormMenu m_ParentForm;
|
|
|
|
public Define.E_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 = Define.E_MenuBottomConfiguration.Help;
|
|
|
|
this.CollectionButtonMenu = new Collection<SmartButton>();
|
|
this.CollectionButtonMenu.Clear();
|
|
this.CollectionButtonMenu.Add(this.buttonHelp);
|
|
this.CollectionButtonMenu.Add(this.buttonSerialCOM1);
|
|
this.CollectionButtonMenu.Add(this.buttonSerialCOM3);
|
|
this.CollectionButtonMenu.Add(this.buttonSerialCOM4);
|
|
this.CollectionButtonMenu.Add(this.buttonEthernet);
|
|
this.CollectionButtonMenu.Add(this.buttonOption);
|
|
this.CollectionButtonMenu.Add(this.buttonOptionBoard);
|
|
}
|
|
|
|
public void CurrentControlEnable(bool enable)
|
|
{
|
|
foreach (SmartButton button in this.CollectionButtonMenu)
|
|
button.Enabled = enable;
|
|
}
|
|
|
|
public void UpdateMenuDisplay(SystemStatus status)
|
|
{
|
|
switch (status.CurrentUser.Group)
|
|
{
|
|
case Define.E_UserGroup.Level1:
|
|
this.buttonSerialCOM1.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsConfiSerial;
|
|
this.buttonSerialCOM3.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsConfiSerial;
|
|
this.buttonSerialCOM4.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsConfiSerial;
|
|
this.buttonEthernet.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsConfiEthernet;
|
|
break;
|
|
case Define.E_UserGroup.Level2:
|
|
this.buttonSerialCOM1.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsConfiSerial;
|
|
this.buttonSerialCOM3.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsConfiSerial;
|
|
this.buttonSerialCOM4.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsConfiSerial;
|
|
this.buttonEthernet.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsConfiEthernet;
|
|
break;
|
|
case Define.E_UserGroup.Level3:
|
|
this.buttonSerialCOM1.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsConfiSerial;
|
|
this.buttonSerialCOM3.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsConfiSerial;
|
|
this.buttonSerialCOM4.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsConfiSerial;
|
|
this.buttonEthernet.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsConfiEthernet;
|
|
break;
|
|
case Define.E_UserGroup.Admin:
|
|
case Define.E_UserGroup.Developer:
|
|
this.buttonSerialCOM1.Enabled = true;
|
|
this.buttonSerialCOM3.Enabled = true;
|
|
this.buttonSerialCOM4.Enabled = true;
|
|
this.buttonEthernet.Enabled = true;
|
|
break;
|
|
case Define.E_UserGroup.NotLogin:
|
|
this.buttonSerialCOM1.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsConfiSerial;
|
|
this.buttonSerialCOM3.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsConfiSerial;
|
|
this.buttonSerialCOM4.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsConfiSerial;
|
|
this.buttonEthernet.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsConfiEthernet;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
public void UpdateDisplayMenuButton(Define.E_MenuBottomConfiguration menu)
|
|
{
|
|
switch (menu)
|
|
{
|
|
case Define.E_MenuBottomConfiguration.SerialCOM1:
|
|
if (this.buttonSerialCOM1.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
|
|
this.buttonSerialCOM1.ButtonDown();
|
|
if (this.buttonSerialCOM3.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonSerialCOM3.ButtonUp();
|
|
if (this.buttonSerialCOM4.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonSerialCOM4.ButtonUp();
|
|
if (this.buttonEthernet.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonEthernet.ButtonUp();
|
|
if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonHelp.ButtonUp();
|
|
if (this.buttonOptionBoard.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonOptionBoard.ButtonUp();
|
|
break;
|
|
case Define.E_MenuBottomConfiguration.SerialCOM3:
|
|
if (this.buttonSerialCOM1.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonSerialCOM1.ButtonUp();
|
|
if (this.buttonSerialCOM3.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
|
|
this.buttonSerialCOM3.ButtonDown();
|
|
if (this.buttonSerialCOM4.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonSerialCOM4.ButtonUp();
|
|
if (this.buttonEthernet.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonEthernet.ButtonUp();
|
|
if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonHelp.ButtonUp();
|
|
if (this.buttonOptionBoard.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonOptionBoard.ButtonUp();
|
|
break;
|
|
case Define.E_MenuBottomConfiguration.SerialCOM4:
|
|
if (this.buttonSerialCOM1.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonSerialCOM1.ButtonUp();
|
|
if (this.buttonSerialCOM3.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonSerialCOM3.ButtonUp();
|
|
if (this.buttonSerialCOM4.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
|
|
this.buttonSerialCOM4.ButtonDown();
|
|
if (this.buttonEthernet.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonEthernet.ButtonUp();
|
|
if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonHelp.ButtonUp();
|
|
if (this.buttonOptionBoard.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonOptionBoard.ButtonUp();
|
|
break;
|
|
case Define.E_MenuBottomConfiguration.Ethernet:
|
|
if (this.buttonSerialCOM1.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonSerialCOM1.ButtonUp();
|
|
if (this.buttonSerialCOM3.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonSerialCOM3.ButtonUp();
|
|
if (this.buttonSerialCOM4.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonSerialCOM4.ButtonUp();
|
|
if (this.buttonEthernet.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
|
|
this.buttonEthernet.ButtonDown();
|
|
if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonHelp.ButtonUp();
|
|
if (this.buttonOptionBoard.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonOptionBoard.ButtonUp();
|
|
break;
|
|
case Define.E_MenuBottomConfiguration.Help:
|
|
if (this.buttonSerialCOM1.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonSerialCOM1.ButtonUp();
|
|
if (this.buttonSerialCOM3.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonSerialCOM3.ButtonUp();
|
|
if (this.buttonSerialCOM4.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonSerialCOM4.ButtonUp();
|
|
if (this.buttonEthernet.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonEthernet.ButtonUp();
|
|
if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
|
|
this.buttonHelp.ButtonDown();
|
|
if (this.buttonOptionBoard.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonOptionBoard.ButtonUp();
|
|
break;
|
|
case Define.E_MenuBottomConfiguration.OptionBoard:
|
|
if (this.buttonSerialCOM1.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonSerialCOM1.ButtonUp();
|
|
if (this.buttonSerialCOM3.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonSerialCOM3.ButtonUp();
|
|
if (this.buttonSerialCOM4.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonSerialCOM4.ButtonUp();
|
|
if (this.buttonEthernet.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonEthernet.ButtonUp();
|
|
if (this.buttonHelp.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|
this.buttonHelp.ButtonUp();
|
|
if (this.buttonOptionBoard.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
|
|
this.buttonOptionBoard.ButtonDown();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void DisplayRefresh(SystemStatus status)
|
|
{
|
|
int value;
|
|
|
|
value = int.Parse(this.ParentForm.ParentForm.CurrentSystemParameter1.OptionBoard);
|
|
if (value == 0)
|
|
this.buttonOptionBoard.Visible = false;
|
|
else
|
|
this.buttonOptionBoard.Visible = true;
|
|
|
|
this.buttonHelp.ButtonDown();
|
|
this.buttonSerialCOM1.ButtonUp();
|
|
this.buttonSerialCOM3.ButtonUp();
|
|
this.buttonSerialCOM4.ButtonUp();
|
|
this.buttonEthernet.ButtonUp();
|
|
this.buttonOption.ButtonUp();
|
|
this.buttonOptionBoard.ButtonUp();
|
|
|
|
this.CurrentMenu = Define.E_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 = Define.E_MenuBottomConfiguration.Help;
|
|
else if (button == this.buttonSerialCOM1)
|
|
this.CurrentMenu = Define.E_MenuBottomConfiguration.SerialCOM1;
|
|
else if (button == this.buttonSerialCOM3)
|
|
this.CurrentMenu = Define.E_MenuBottomConfiguration.SerialCOM3;
|
|
else if (button == this.buttonSerialCOM4)
|
|
this.CurrentMenu = Define.E_MenuBottomConfiguration.SerialCOM4;
|
|
else if (button == this.buttonEthernet)
|
|
this.CurrentMenu = Define.E_MenuBottomConfiguration.Ethernet;
|
|
else if (button == this.buttonOptionBoard)
|
|
this.CurrentMenu = Define.E_MenuBottomConfiguration.OptionBoard;
|
|
else
|
|
this.CurrentMenu = Define.E_MenuBottomConfiguration.Help;
|
|
|
|
this.ParentForm.DisplayBottomConfiguration(this.CurrentMenu);
|
|
}
|
|
#endregion
|
|
}
|
|
}
|