326 lines
18 KiB
C#
326 lines
18 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.Forms;
|
|||
|
|
|||
|
namespace ITC81DB.Controls
|
|||
|
{
|
|||
|
public partial class ControlBottomConfiguration : UserControl
|
|||
|
{
|
|||
|
#region Field
|
|||
|
private FormMenu m_ParentForm;
|
|||
|
|
|||
|
public DataStore.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 = DataStore.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 DataStore.UserGroup.Level1Operator:
|
|||
|
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;
|
|||
|
this.buttonCountingOutput.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsConfiCountingOutput;
|
|||
|
this.buttonOption.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsConfiOptionBoard;
|
|||
|
break;
|
|||
|
case DataStore.UserGroup.Level2Engineer:
|
|||
|
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;
|
|||
|
this.buttonCountingOutput.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsConfiCountingOutput;
|
|||
|
this.buttonOption.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsConfiOptionBoard;
|
|||
|
break;
|
|||
|
case DataStore.UserGroup.Level3Manager:
|
|||
|
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;
|
|||
|
this.buttonCountingOutput.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsConfiCountingOutput;
|
|||
|
this.buttonOption.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsConfiOptionBoard;
|
|||
|
break;
|
|||
|
case DataStore.UserGroup.Level4Developer:
|
|||
|
this.buttonSerialCOM1.Enabled = true;
|
|||
|
this.buttonSerialCOM3.Enabled = true;
|
|||
|
this.buttonSerialCOM4.Enabled = true;
|
|||
|
this.buttonEthernet.Enabled = true;
|
|||
|
this.buttonCountingOutput.Enabled = true;
|
|||
|
this.buttonOption.Enabled = true;
|
|||
|
break;
|
|||
|
case DataStore.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;
|
|||
|
this.buttonCountingOutput.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsConfiCountingOutput;
|
|||
|
this.buttonOption.Enabled = this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsConfiOptionBoard;
|
|||
|
break;
|
|||
|
default:
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
public void UpdateDisplayMenuButton(DataStore.MenuBottomConfiguration menu)
|
|||
|
{
|
|||
|
switch (menu)
|
|||
|
{
|
|||
|
case DataStore.MenuBottomConfiguration.CountingOutput:
|
|||
|
if (this.buttonCountingOutput.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
|
|||
|
this.buttonCountingOutput.ButtonDown();
|
|||
|
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.buttonOption.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|||
|
this.buttonOption.ButtonUp();
|
|||
|
if (this.buttonOptionBoard.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|||
|
this.buttonOptionBoard.ButtonUp();
|
|||
|
break;
|
|||
|
case DataStore.MenuBottomConfiguration.SerialCOM1:
|
|||
|
if (this.buttonCountingOutput.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|||
|
this.buttonCountingOutput.ButtonUp();
|
|||
|
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.buttonOption.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|||
|
this.buttonOption.ButtonUp();
|
|||
|
if (this.buttonOptionBoard.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|||
|
this.buttonOptionBoard.ButtonUp();
|
|||
|
break;
|
|||
|
case DataStore.MenuBottomConfiguration.SerialCOM3:
|
|||
|
if (this.buttonCountingOutput.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|||
|
this.buttonCountingOutput.ButtonUp();
|
|||
|
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.buttonOption.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|||
|
this.buttonOption.ButtonUp();
|
|||
|
if (this.buttonOptionBoard.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|||
|
this.buttonOptionBoard.ButtonUp();
|
|||
|
break;
|
|||
|
case DataStore.MenuBottomConfiguration.SerialCOM4:
|
|||
|
if (this.buttonCountingOutput.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|||
|
this.buttonCountingOutput.ButtonUp();
|
|||
|
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.buttonOption.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|||
|
this.buttonOption.ButtonUp();
|
|||
|
if (this.buttonOptionBoard.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|||
|
this.buttonOptionBoard.ButtonUp();
|
|||
|
break;
|
|||
|
case DataStore.MenuBottomConfiguration.Ethernet:
|
|||
|
if (this.buttonCountingOutput.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|||
|
this.buttonCountingOutput.ButtonUp();
|
|||
|
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.buttonOption.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|||
|
this.buttonOption.ButtonUp();
|
|||
|
if (this.buttonOptionBoard.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|||
|
this.buttonOptionBoard.ButtonUp();
|
|||
|
break;
|
|||
|
case DataStore.MenuBottomConfiguration.Help:
|
|||
|
if (this.buttonCountingOutput.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|||
|
this.buttonCountingOutput.ButtonUp();
|
|||
|
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.buttonOption.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|||
|
this.buttonOption.ButtonUp();
|
|||
|
if (this.buttonOptionBoard.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|||
|
this.buttonOptionBoard.ButtonUp();
|
|||
|
break;
|
|||
|
case DataStore.MenuBottomConfiguration.Option:
|
|||
|
if (this.buttonCountingOutput.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|||
|
this.buttonCountingOutput.ButtonUp();
|
|||
|
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.buttonOption.ButtonStatus != SmartButton.BUTSTATUS.DOWN)
|
|||
|
this.buttonOption.ButtonDown();
|
|||
|
if (this.buttonOptionBoard.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|||
|
this.buttonOptionBoard.ButtonUp();
|
|||
|
break;
|
|||
|
case DataStore.MenuBottomConfiguration.OptionBoard:
|
|||
|
if (this.buttonCountingOutput.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|||
|
this.buttonCountingOutput.ButtonUp();
|
|||
|
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.buttonOption.ButtonStatus != SmartButton.BUTSTATUS.UP)
|
|||
|
this.buttonOption.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 = DataStore.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 = DataStore.MenuBottomConfiguration.Help;
|
|||
|
else if (button == this.buttonSerialCOM1)
|
|||
|
this.CurrentMenu = DataStore.MenuBottomConfiguration.SerialCOM1;
|
|||
|
else if (button == this.buttonSerialCOM3)
|
|||
|
this.CurrentMenu = DataStore.MenuBottomConfiguration.SerialCOM3;
|
|||
|
else if (button == this.buttonSerialCOM4)
|
|||
|
this.CurrentMenu = DataStore.MenuBottomConfiguration.SerialCOM4;
|
|||
|
else if (button == this.buttonEthernet)
|
|||
|
this.CurrentMenu = DataStore.MenuBottomConfiguration.Ethernet;
|
|||
|
else if (button == this.buttonOption)
|
|||
|
this.CurrentMenu = DataStore.MenuBottomConfiguration.Option;
|
|||
|
else if (button == this.buttonOptionBoard)
|
|||
|
this.CurrentMenu = DataStore.MenuBottomConfiguration.OptionBoard;
|
|||
|
else if (button == this.buttonCountingOutput)
|
|||
|
this.CurrentMenu = DataStore.MenuBottomConfiguration.CountingOutput;
|
|||
|
else
|
|||
|
this.CurrentMenu = DataStore.MenuBottomConfiguration.Help;
|
|||
|
|
|||
|
this.ParentForm.DisplayBottomConfiguration(this.CurrentMenu);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|