INT_PT002/INT_PT002/Forms/FormMenu.cs

580 lines
24 KiB
C#

using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using INT_PT002.Controls;
using INT_PT002.DataStore;
namespace INT_PT002.Forms
{
public partial class FormMenu : Form
{
#region Field
private FormMain m_ParentForm;
// Recipe
private ControlMenuRecipeSetting Child_Recipe_Setting;
// Setting
private ControlMenuSettingCommunication Child_Setting_Communication;
private ControlMenuSettingConfiguration Child_Setting_Configuration;
private ControlMenuSettingUserEditor Child_Setting_UserEditor;
// Manual
private ControlMenuManualIoTest Child_Manual_IoTest;
private ControlMenuManualMotorSetting Child_Manual_MotorSetting;
// Log
private ControlMenuLogHistory Child_Log_History;
private ControlMenuLogInspection Child_Log_Inspection;
private ControlMenuLogAlarm Child_Log_Alarm;
// System
private ControlMenuSystemInformation Child_System_Information;
private ControlMenuSystemTime Child_System_Time;
private ControlMenuSystemEquipment Child_System_Equipment;
private ControlMenuSystemUpdate Child_System_Update;
private Define.E_TopMenuStore SelectedTopMenu;
private Define.E_MenuRecipeStore SelectedMenuRecipe;
private Define.E_MenuSettingStore SelectedMenuSetting;
private Define.E_MenuManualStore SelectedMenuManual;
private Define.E_MenuLogStore SelectedMenuLog;
private Define.E_MenuSystemStore SelectedMenuSystem;
#endregion
#region Constructor
public FormMenu(FormMain parent)
{
InitializeComponent();
this.ParentForm = parent;
this.Initialize();
this.CreateChildControls();
}
#endregion
#region Property
public FormMain ParentForm
{
get { return this.m_ParentForm; }
private set { this.m_ParentForm = value; }
}
#endregion
#region Method
private void Initialize()
{
this.SelectedTopMenu = Define.E_TopMenuStore.Recipe;
this.SelectedMenuRecipe = Define.E_MenuRecipeStore._0_None;
this.SelectedMenuSetting = Define.E_MenuSettingStore._0_None;
this.SelectedMenuManual = Define.E_MenuManualStore._0_None;
this.SelectedMenuLog = Define.E_MenuLogStore._0_None;
this.SelectedMenuSystem = Define.E_MenuSystemStore._0_None;
}
private void CreateChildControls()
{
this.Child_Recipe_Setting = new ControlMenuRecipeSetting(this);
this.Child_Setting_Configuration = new ControlMenuSettingConfiguration(this);
this.Child_Setting_Communication = new ControlMenuSettingCommunication(this);
this.Child_Setting_UserEditor = new ControlMenuSettingUserEditor(this);
this.Child_Manual_IoTest = new ControlMenuManualIoTest(this);
this.Child_Manual_MotorSetting = new ControlMenuManualMotorSetting(this);
this.Child_Log_History = new ControlMenuLogHistory(this);
this.Child_Log_Inspection = new ControlMenuLogInspection(this);
this.Child_Log_Alarm = new ControlMenuLogAlarm(this);
this.Child_System_Equipment = new ControlMenuSystemEquipment(this);
this.Child_System_Information = new ControlMenuSystemInformation(this);
this.Child_System_Time = new ControlMenuSystemTime(this);
this.Child_System_Update = new ControlMenuSystemUpdate(this);
this.Controls.Add(this.Child_Recipe_Setting);
this.Controls.Add(this.Child_Setting_Configuration);
this.Controls.Add(this.Child_Setting_Communication);
this.Controls.Add(this.Child_Setting_UserEditor);
this.Controls.Add(this.Child_Manual_IoTest);
this.Controls.Add(this.Child_Manual_MotorSetting);
this.Controls.Add(this.Child_Log_Alarm);
this.Controls.Add(this.Child_Log_History);
this.Controls.Add(this.Child_Log_Inspection);
this.Controls.Add(this.Child_System_Equipment);
this.Controls.Add(this.Child_System_Information);
this.Controls.Add(this.Child_System_Time);
this.Controls.Add(this.Child_System_Update);
this.Child_Recipe_Setting.Location = new Point(0, 39);
this.Child_Setting_Configuration.Location = new Point(0, 39);
this.Child_Setting_Communication.Location = new Point(0, 39);
this.Child_Setting_UserEditor.Location = new Point(0, 39);
this.Child_Manual_IoTest.Location = new Point(0, 39);
this.Child_Manual_MotorSetting.Location = new Point(0, 39);
this.Child_Log_Alarm.Location = new Point(0, 39);
this.Child_Log_History.Location = new Point(0, 39);
this.Child_Log_Inspection.Location = new Point(0, 39);
this.Child_System_Equipment.Location = new Point(0, 39);
this.Child_System_Information.Location = new Point(0, 39);
this.Child_System_Time.Location = new Point(0, 39);
this.Child_System_Update.Location = new Point(0, 39);
}
private void SetTopMenu(Define.E_TopMenuStore bottom)
{
switch (bottom)
{
case Define.E_TopMenuStore.Recipe:
this.buttonRecipe.ButtonDown();
this.buttonSetting.ButtonUp();
this.buttonManual.ButtonUp();
this.buttonLog.ButtonUp();
this.buttonSystem.ButtonUp();
this.buttonBottom1.ButtonText = "Setting";
this.buttonBottom1.Visible = true;
this.buttonBottom2.Visible = false;
this.buttonBottom3.Visible = false;
this.buttonBottom4.Visible = false;
this.SelectedMenuRecipe = Define.E_MenuRecipeStore._1_Setting;
this.SetBottomMenuRecipe(this.SelectedMenuRecipe);
break;
case Define.E_TopMenuStore.Setting:
this.buttonRecipe.ButtonUp();
this.buttonSetting.ButtonDown();
this.buttonManual.ButtonUp();
this.buttonLog.ButtonUp();
this.buttonSystem.ButtonUp();
this.buttonBottom1.ButtonText = "Config";
this.buttonBottom2.ButtonText = "COM";
this.buttonBottom3.ButtonText = "User";
this.buttonBottom1.Visible = true;
this.buttonBottom2.Visible = true;
this.buttonBottom3.Visible = true;
this.buttonBottom4.Visible = false;
this.SelectedMenuSetting = Define.E_MenuSettingStore._1_Configuration;
this.SetBottomMenuSetting(this.SelectedMenuSetting);
break;
case Define.E_TopMenuStore.Manual:
this.buttonRecipe.ButtonUp();
this.buttonSetting.ButtonUp();
this.buttonManual.ButtonDown();
this.buttonLog.ButtonUp();
this.buttonSystem.ButtonUp();
this.buttonBottom1.ButtonText = "IO Test";
this.buttonBottom2.ButtonText = "Motor";
this.buttonBottom1.Visible = true;
this.buttonBottom2.Visible = true;
this.buttonBottom3.Visible = false;
this.buttonBottom4.Visible = false;
this.SelectedMenuManual = Define.E_MenuManualStore._1_IoTest;
this.SetBottomMenuManual(this.SelectedMenuManual);
break;
case Define.E_TopMenuStore.Log:
this.buttonRecipe.ButtonUp();
this.buttonSetting.ButtonUp();
this.buttonManual.ButtonUp();
this.buttonLog.ButtonDown();
this.buttonSystem.ButtonUp();
this.buttonBottom1.ButtonText = "History";
this.buttonBottom2.ButtonText = "Inspection";
this.buttonBottom3.ButtonText = "Alarm";
this.buttonBottom1.Visible = true;
this.buttonBottom2.Visible = true;
this.buttonBottom3.Visible = true;
this.buttonBottom4.Visible = false;
this.SelectedMenuLog = Define.E_MenuLogStore._1_History;
this.SetBottomMenuLog(this.SelectedMenuLog);
break;
case Define.E_TopMenuStore.System:
this.buttonRecipe.ButtonUp();
this.buttonSetting.ButtonUp();
this.buttonManual.ButtonUp();
this.buttonLog.ButtonUp();
this.buttonSystem.ButtonDown();
this.buttonBottom1.ButtonText = "Information";
this.buttonBottom2.ButtonText = "Time";
this.buttonBottom3.ButtonText = "Equipment";
this.buttonBottom4.ButtonText = "Update";
this.buttonBottom1.Visible = true;
this.buttonBottom2.Visible = true;
this.buttonBottom3.Visible = true;
this.buttonBottom4.Visible = true;
this.SelectedMenuSystem = Define.E_MenuSystemStore._1_Information;
this.SetBottomMenuSystem(this.SelectedMenuSystem);
break;
default:
this.buttonBottom1.Visible = false;
this.buttonBottom2.Visible = false;
this.buttonBottom3.Visible = false;
this.buttonBottom4.Visible = false;
break;
}
}
private void SetBottomMenuRecipe(Define.E_MenuRecipeStore menu)
{
switch (menu)
{
case Define.E_MenuRecipeStore._0_None:
break;
case Define.E_MenuRecipeStore._1_Setting:
this.Child_Recipe_Setting.DisplayRefresh();
this.Child_Recipe_Setting.BringToFront();
this.buttonBottom1.ButtonDown();
this.buttonBottom2.ButtonUp();
this.buttonBottom3.ButtonUp();
this.buttonBottom4.ButtonUp();
break;
default:
break;
}
}
private void SetBottomMenuSetting(Define.E_MenuSettingStore menu)
{
switch (menu)
{
case Define.E_MenuSettingStore._1_Configuration:
this.Child_Setting_Configuration.DisplayRefresh();
this.Child_Setting_Configuration.BringToFront();
this.buttonBottom1.ButtonDown();
this.buttonBottom2.ButtonUp();
this.buttonBottom3.ButtonUp();
this.buttonBottom4.ButtonUp();
break;
case Define.E_MenuSettingStore._2_Communication:
this.Child_Setting_Communication.DisplayRefresh();
this.Child_Setting_Communication.BringToFront();
this.buttonBottom1.ButtonUp();
this.buttonBottom2.ButtonDown();
this.buttonBottom3.ButtonUp();
this.buttonBottom4.ButtonUp();
break;
case Define.E_MenuSettingStore._3_UserEditor:
this.Child_Setting_UserEditor.DisplayRefresh();
this.Child_Setting_UserEditor.BringToFront();
this.buttonBottom1.ButtonUp();
this.buttonBottom2.ButtonUp();
this.buttonBottom3.ButtonDown();
this.buttonBottom4.ButtonUp();
break;
default:
break;
}
}
private void SetBottomMenuManual(Define.E_MenuManualStore menu)
{
switch (menu)
{
case Define.E_MenuManualStore._1_IoTest:
this.Child_Manual_IoTest.DisplayRefresh();
this.Child_Manual_IoTest.BringToFront();
this.buttonBottom1.ButtonDown();
this.buttonBottom2.ButtonUp();
this.buttonBottom3.ButtonUp();
this.buttonBottom4.ButtonUp();
break;
case Define.E_MenuManualStore._2_MotorSetting:
this.Child_Manual_MotorSetting.DisplayRefresh();
this.Child_Manual_MotorSetting.BringToFront();
this.buttonBottom1.ButtonUp();
this.buttonBottom2.ButtonDown();
this.buttonBottom3.ButtonUp();
this.buttonBottom4.ButtonUp();
break;
default:
break;
}
}
private void SetBottomMenuLog(Define.E_MenuLogStore menu)
{
switch (menu)
{
case Define.E_MenuLogStore._1_History:
this.Child_Log_History.DisplayRefresh();
this.Child_Log_History.BringToFront();
this.buttonBottom1.ButtonDown();
this.buttonBottom2.ButtonUp();
this.buttonBottom3.ButtonUp();
this.buttonBottom4.ButtonUp();
break;
case Define.E_MenuLogStore._2_Inspection:
this.Child_Log_Inspection.DisplayRefresh();
this.Child_Log_Inspection.BringToFront();
this.buttonBottom1.ButtonUp();
this.buttonBottom2.ButtonDown();
this.buttonBottom3.ButtonUp();
this.buttonBottom4.ButtonUp();
break;
case Define.E_MenuLogStore._3_Alarm:
this.Child_Log_Alarm.DisplayRefresh();
this.Child_Log_Alarm.BringToFront();
this.buttonBottom1.ButtonUp();
this.buttonBottom2.ButtonUp();
this.buttonBottom3.ButtonDown();
this.buttonBottom4.ButtonUp();
break;
default:
break;
}
}
private void SetBottomMenuSystem(Define.E_MenuSystemStore menu)
{
switch (menu)
{
case Define.E_MenuSystemStore._1_Information:
this.Child_System_Information.DisplayRefresh();
this.Child_System_Information.BringToFront();
this.buttonBottom1.ButtonDown();
this.buttonBottom2.ButtonUp();
this.buttonBottom3.ButtonUp();
this.buttonBottom4.ButtonUp();
break;
case Define.E_MenuSystemStore._2_Time:
this.Child_System_Time.DisplayRefresh();
this.Child_System_Time.BringToFront();
this.buttonBottom1.ButtonUp();
this.buttonBottom2.ButtonDown();
this.buttonBottom3.ButtonUp();
this.buttonBottom4.ButtonUp();
break;
case Define.E_MenuSystemStore._3_Equipment:
this.Child_System_Equipment.DisplayRefresh();
this.Child_System_Equipment.BringToFront();
this.buttonBottom1.ButtonUp();
this.buttonBottom2.ButtonUp();
this.buttonBottom3.ButtonDown();
this.buttonBottom4.ButtonUp();
break;
case Define.E_MenuSystemStore._4_Update:
this.Child_System_Update.DisplayRefresh();
this.Child_System_Update.BringToFront();
this.buttonBottom1.ButtonUp();
this.buttonBottom2.ButtonUp();
this.buttonBottom3.ButtonUp();
this.buttonBottom4.ButtonDown();
break;
default:
break;
}
}
// Menu Recipe
public void UpdateDisplayRecipeData(int no)
{
this.Child_Recipe_Setting.UpdateDisplayRecipeData(no);
}
// Menu Equipment
public void UpdateDisplayEquipmentTestInputData(Collection<string> datas)
{
this.Child_Manual_IoTest.UpdateDisplayInputData(datas);
}
public void UpdateDisplayEquipmentTestDispData(Collection<DispData> datas)
{
this.Child_Manual_IoTest.UpdateDisplayDispData(datas);
}
public void UpdateDisplayEquipmentTestDiffData(Collection<DiffData> datas)
{
this.Child_Manual_IoTest.UpdateDisplayDiffData(datas);
}
public void UpdateDisplayEquipmentTestPresData(Collection<PressureData> datas)
{
this.Child_Manual_IoTest.UpdateDisplayPresData(datas);
}
public void DisplayRefresh()
{
this.SelectedTopMenu = Define.E_TopMenuStore.Recipe;
this.SetTopMenu(this.SelectedTopMenu);
}
#endregion
#region Event Handler
private void buttonHome_Click(object sender, EventArgs e)
{
this.ParentForm.ChildFormMainDisplay.DisplayRefresh();
this.ParentForm.FormChange((int)Define.E_FormStore.FormMainDisplay);
}
private void buttonRecipe_Click(object sender, EventArgs e)
{
if (this.SelectedTopMenu != Define.E_TopMenuStore.Recipe)
{
this.SelectedTopMenu = Define.E_TopMenuStore.Recipe;
this.SetTopMenu(this.SelectedTopMenu);
}
}
private void buttonSetting_Click(object sender, EventArgs e)
{
if (this.SelectedTopMenu != Define.E_TopMenuStore.Setting)
{
this.SelectedTopMenu = Define.E_TopMenuStore.Setting;
this.SetTopMenu(this.SelectedTopMenu);
}
}
private void buttonManual_Click(object sender, EventArgs e)
{
if (this.SelectedTopMenu != Define.E_TopMenuStore.Manual)
{
this.SelectedTopMenu = Define.E_TopMenuStore.Manual;
this.SetTopMenu(this.SelectedTopMenu);
}
}
private void buttonLog_Click(object sender, EventArgs e)
{
if (this.SelectedTopMenu != Define.E_TopMenuStore.Log)
{
this.SelectedTopMenu = Define.E_TopMenuStore.Log;
this.SetTopMenu(this.SelectedTopMenu);
}
}
private void buttonSystem_Click(object sender, EventArgs e)
{
if (this.SelectedTopMenu != Define.E_TopMenuStore.System)
{
this.SelectedTopMenu = Define.E_TopMenuStore.System;
this.SetTopMenu(this.SelectedTopMenu);
}
}
private void buttonBottom1_Click(object sender, EventArgs e)
{
switch (this.SelectedTopMenu)
{
case Define.E_TopMenuStore.Recipe:
this.SelectedMenuRecipe = Define.E_MenuRecipeStore._1_Setting;
this.SetBottomMenuRecipe(this.SelectedMenuRecipe);
break;
case Define.E_TopMenuStore.Setting:
this.SelectedMenuSetting = Define.E_MenuSettingStore._1_Configuration;
this.SetBottomMenuSetting(this.SelectedMenuSetting);
break;
case Define.E_TopMenuStore.Manual:
this.SelectedMenuManual = Define.E_MenuManualStore._1_IoTest;
this.SetBottomMenuManual(this.SelectedMenuManual);
break;
case Define.E_TopMenuStore.Log:
this.SelectedMenuLog = Define.E_MenuLogStore._1_History;
this.SetBottomMenuLog(this.SelectedMenuLog);
break;
case Define.E_TopMenuStore.System:
this.SelectedMenuSystem = Define.E_MenuSystemStore._1_Information;
this.SetBottomMenuSystem(this.SelectedMenuSystem);
break;
default:
break;
}
}
private void buttonBottom2_Click(object sender, EventArgs e)
{
switch (this.SelectedTopMenu)
{
case Define.E_TopMenuStore.Recipe:
this.SelectedMenuRecipe = Define.E_MenuRecipeStore._0_None;
this.SetBottomMenuRecipe(this.SelectedMenuRecipe);
break;
case Define.E_TopMenuStore.Setting:
this.SelectedMenuSetting = Define.E_MenuSettingStore._2_Communication;
this.SetBottomMenuSetting(this.SelectedMenuSetting);
break;
case Define.E_TopMenuStore.Manual:
this.SelectedMenuManual = Define.E_MenuManualStore._2_MotorSetting;
this.SetBottomMenuManual(this.SelectedMenuManual);
break;
case Define.E_TopMenuStore.Log:
this.SelectedMenuLog = Define.E_MenuLogStore._2_Inspection;
this.SetBottomMenuLog(this.SelectedMenuLog);
break;
case Define.E_TopMenuStore.System:
this.SelectedMenuSystem = Define.E_MenuSystemStore._2_Time;
this.SetBottomMenuSystem(this.SelectedMenuSystem);
break;
default:
break;
}
}
private void buttonBottom3_Click(object sender, EventArgs e)
{
switch (this.SelectedTopMenu)
{
case Define.E_TopMenuStore.Recipe:
this.SelectedMenuRecipe = Define.E_MenuRecipeStore._0_None;
this.SetBottomMenuRecipe(this.SelectedMenuRecipe);
break;
case Define.E_TopMenuStore.Setting:
this.SelectedMenuSetting = Define.E_MenuSettingStore._3_UserEditor;
this.SetBottomMenuSetting(this.SelectedMenuSetting);
break;
case Define.E_TopMenuStore.Manual:
this.SelectedMenuManual = Define.E_MenuManualStore._0_None;
this.SetBottomMenuManual(this.SelectedMenuManual);
break;
case Define.E_TopMenuStore.Log:
this.SelectedMenuLog = Define.E_MenuLogStore._3_Alarm;
this.SetBottomMenuLog(this.SelectedMenuLog);
break;
case Define.E_TopMenuStore.System:
this.SelectedMenuSystem = Define.E_MenuSystemStore._3_Equipment;
this.SetBottomMenuSystem(this.SelectedMenuSystem);
break;
default:
break;
}
}
private void buttonBottom4_Click(object sender, EventArgs e)
{
switch (this.SelectedTopMenu)
{
case Define.E_TopMenuStore.Recipe:
this.SelectedMenuRecipe = Define.E_MenuRecipeStore._0_None;
this.SetBottomMenuRecipe(this.SelectedMenuRecipe);
break;
case Define.E_TopMenuStore.Setting:
this.SelectedMenuSetting = Define.E_MenuSettingStore._0_None;
this.SetBottomMenuSetting(this.SelectedMenuSetting);
break;
case Define.E_TopMenuStore.Manual:
this.SelectedMenuManual = Define.E_MenuManualStore._0_None;
this.SetBottomMenuManual(this.SelectedMenuManual);
break;
case Define.E_TopMenuStore.Log:
this.SelectedMenuLog = Define.E_MenuLogStore._0_None;
this.SetBottomMenuLog(this.SelectedMenuLog);
break;
case Define.E_TopMenuStore.System:
this.SelectedMenuSystem = Define.E_MenuSystemStore._4_Update;
this.SetBottomMenuSystem(this.SelectedMenuSystem);
break;
default:
break;
}
}
#endregion
}
}