using System; using System.Linq; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Windows.Forms; using SmartX; using INT_LKD.Forms; using INT_LKD.DataStore; using INT_LKD.DialogForms; using System.Threading; namespace INT_LKD.Controls { public partial class ControlMenuSystemSetting : UserControl { #region Field private FormMenu m_ParentForm; private string MessageBoxRange; private Collection CollLabel; #endregion #region Constructor public ControlMenuSystemSetting(FormMenu parent) { InitializeComponent(); this.ParentForm = parent; this.Initialize(); this.InitializeDesign(); } #endregion #region Property public FormMenu ParentForm { get { return this.m_ParentForm; } private set { this.m_ParentForm = value; } } #endregion #region Method private void Initialize() { this.MessageBoxRange = ""; this.CollLabel = new Collection(); this.CollLabel.Add(this.labelLcdDataPeriod); this.CollLabel.Add(this.labelChattering); this.CollLabel.Add(this.labelCutWait); this.CollLabel.Add(this.labelBuzzer); this.CollLabel.Add(this.labelSbDiffFilter); this.comboBoxLanguage.SelectedIndexChanged -= new EventHandler(this.comboBoxLanguage_SelectedIndexChanged); this.comboBoxLanguage.Items.Clear(); this.comboBoxLanguage.Items.Add("한국어"); this.comboBoxLanguage.Items.Add("English"); this.comboBoxLanguage.Items.Add("中文"); this.comboBoxLanguage.SelectedIndexChanged += new EventHandler(this.comboBoxLanguage_SelectedIndexChanged); } public void InitializeDesign() { switch (this.ParentForm.ParentForm.SystemConfig.LANGUAGE) { case Define.E_LanguageID.Chinese: this.smartGroupBox1.Text = "系统设定 > 设置"; this.labelTitleEquipmentLane.Text = "设备巷"; this.labelTitleLCDDataPeriod.Text = "数据保存周期"; this.labelTitleChattering.Text = "颤振"; this.labelTitleCutWait.Text = "减少等待"; this.labelTitleCheckLane.Text = "设备检验编号"; this.labelTitleBuzzer.Text = "蜂鸣器"; this.labelTitleSBDiffFilter.Text = "滤波器"; this.labelTitleLanguage.Text = "语言"; break; default: this.smartGroupBox1.Text = "System > Setting"; this.labelTitleEquipmentLane.Text = "Equipment Lane"; this.labelTitleLCDDataPeriod.Text = "LCD data period"; this.labelTitleChattering.Text = "Chattering"; this.labelTitleCutWait.Text = "Cut wait"; this.labelTitleCheckLane.Text = "Check Lane number"; this.labelTitleBuzzer.Text = "Buzzer"; this.labelTitleSBDiffFilter.Text = "SB diff filter"; this.labelTitleLanguage.Text = "Language"; break; } } private void UpdateDisplauUserControls(bool enable) { for (int i = 0; i < this.CollLabel.Count; i++) this.CollLabel[i].Enabled = enable; } private void UpdateDisplayUser(UserItem user) { switch (user.Group) { case Define.E_UserGroup.None: this.UpdateDisplauUserControls(false); break; case Define.E_UserGroup.Level1: this.UpdateDisplauUserControls(this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMenuRecipe); break; case Define.E_UserGroup.Level2: this.UpdateDisplauUserControls(this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMenuRecipe); break; case Define.E_UserGroup.Level3: this.UpdateDisplauUserControls(this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMenuRecipe); break; case Define.E_UserGroup.Admin: this.UpdateDisplauUserControls(this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMenuRecipe); break; case Define.E_UserGroup.Developer: this.UpdateDisplauUserControls(true); break; case Define.E_UserGroup.NotLogin: this.UpdateDisplauUserControls(false); break; case Define.E_UserGroup.LogOut: this.UpdateDisplauUserControls(false); break; default: break; } } private void UpdateDisplayControlData(SystemConfiguration item) { int iValue = 0; string value = ""; // LCD data period value = item.LCD_DATA_PERIOD.ToString(); if (this.labelLcdDataPeriod.Text != value) this.labelLcdDataPeriod.Text = value; // Chattering value = item.CHATTERING.ToString(); if (this.labelChattering.Text != value) this.labelChattering.Text = value; // Cut wait value = item.JUDGMENT_DELAY_MSEC.ToString(); if (this.labelCutWait.Text != value) this.labelCutWait.Text = value; // Buzzer value = item.BUZZER_OP.ToString(); if (this.labelBuzzer.Text != value) this.labelBuzzer.Text = value; // Diff filter value = item.SB_DIFF_FILTER.ToString(); if (this.labelSbDiffFilter.Text != value) this.labelSbDiffFilter.Text = value; // Equipment Lane value = item.EQUIPMENT_LANE.ToString(); if (this.labelEquipmentLane.Text != value) this.labelEquipmentLane.Text = value; // Check Lane value = item.CHECK_LANE.ToString(); if (this.labelCheckLane.Text != value) this.labelCheckLane.Text = value; // 언어 iValue = (int)item.LANGUAGE; if (this.comboBoxLanguage.SelectedIndex != iValue) { this.comboBoxLanguage.SelectedIndexChanged -= new EventHandler(this.comboBoxLanguage_SelectedIndexChanged); this.comboBoxLanguage.SelectedIndex = iValue; this.comboBoxLanguage.SelectedIndexChanged += new EventHandler(this.comboBoxLanguage_SelectedIndexChanged); } } public void DisplayRefresh() { this.ParentForm.ParentForm.SetDisplayMode(Define.E_EquipmentMode.Menu); this.UpdateDisplayControlData(this.ParentForm.ParentForm.SystemConfig); this.UpdateDisplayUser(this.ParentForm.ParentForm.CurrentSystemStatus.CurrentUser); } #endregion #region Event Handler private void labelLcdDataPeriod_Click(object sender, EventArgs e) { string value = "", before = "", after = ""; before = this.labelLcdDataPeriod.Text; DialogFormNumKeyPad myKeypad = new DialogFormNumKeyPad(this.labelTitleLCDDataPeriod.Text, this.labelLcdDataPeriod.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.LANGUAGE); if (myKeypad.ShowDialog() == DialogResult.OK) { if (myKeypad.IntValue < 100 || myKeypad.IntValue > 5000) { this.MessageBoxRange = "100 ~ 5000"; this.labelLcdDataPeriod.Text = before; this.smartTimerMessageShow.Start(); return; } this.labelLcdDataPeriod.Text = myKeypad.StringValue; this.ParentForm.ParentForm.SystemConfig.LCD_DATA_PERIOD = myKeypad.IntValue; this.ParentForm.ParentForm.SaveSystemConfigurationFile(this.ParentForm.ParentForm.SystemConfig); after = myKeypad.StringValue; value = Helper.StringBlankFillDigits4(myKeypad.StringValue); this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._1710_LcdDataPeriod, value); this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.Etc_LcdDataPeriod, "", before, after); } } private void labelChattering_Click(object sender, EventArgs e) { string value = "", before = "", after = ""; before = this.labelChattering.Text; DialogFormNumKeyPad myKeypad = new DialogFormNumKeyPad(this.labelTitleChattering.Text, this.labelChattering.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.LANGUAGE); if (myKeypad.ShowDialog() == DialogResult.OK) { if (myKeypad.IntValue < 50 || myKeypad.IntValue > 500) { this.MessageBoxRange = "50 ~ 500"; this.labelChattering.Text = before; this.smartTimerMessageShow.Start(); return; } this.labelChattering.Text = myKeypad.StringValue; this.ParentForm.ParentForm.SystemConfig.CHATTERING = myKeypad.IntValue; this.ParentForm.ParentForm.SaveSystemConfigurationFile(this.ParentForm.ParentForm.SystemConfig); after = myKeypad.StringValue; value = Helper.StringBlankFillDigits4(myKeypad.StringValue); this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._6006_Chattering, value); this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.Etc_Chattering, "", before, after); } } private void labelCutWait_Click(object sender, EventArgs e) { string value = "", before = "", after = ""; before = this.labelCutWait.Text; DialogFormNumKeyPad myKeypad = new DialogFormNumKeyPad(this.labelTitleCutWait.Text, this.labelCutWait.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.LANGUAGE); if (myKeypad.ShowDialog() == DialogResult.OK) { if (myKeypad.IntValue < 100 || myKeypad.IntValue > 9999) { this.MessageBoxRange = "100 ~ 9999"; this.labelCutWait.Text = before; this.smartTimerMessageShow.Start(); return; } this.labelCutWait.Text = myKeypad.StringValue; this.ParentForm.ParentForm.SystemConfig.JUDGMENT_DELAY_MSEC = myKeypad.IntValue; this.ParentForm.ParentForm.SaveSystemConfigurationFile(this.ParentForm.ParentForm.SystemConfig); after = myKeypad.StringValue; value = Helper.StringBlankFillDigits4(myKeypad.StringValue); this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._5508_CuttingWait, value); this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.Etc_CutWait, "", before, after); } } private void labelBuzzer_Click(object sender, EventArgs e) { string value = "", before = "", after = ""; before = this.labelBuzzer.Text; DialogFormNumKeyPad myKeypad = new DialogFormNumKeyPad(this.labelTitleBuzzer.Text, this.labelBuzzer.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.LANGUAGE); if (myKeypad.ShowDialog() == DialogResult.OK) { if (myKeypad.IntValue < 0 || myKeypad.IntValue > 9999) { this.MessageBoxRange = "0 ~ 9999"; this.labelBuzzer.Text = before; this.smartTimerMessageShow.Start(); return; } this.labelBuzzer.Text = myKeypad.StringValue; this.ParentForm.ParentForm.SystemConfig.BUZZER_OP = myKeypad.IntValue; this.ParentForm.ParentForm.SaveSystemConfigurationFile(this.ParentForm.ParentForm.SystemConfig); after = myKeypad.StringValue; value = Helper.StringBlankFillDigits4(myKeypad.StringValue); this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._6001_BuzzerOP, value); this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.Etc_Buzzer, "", before, after); } } private void labelSbDiffFilter_Click(object sender, EventArgs e) { string value = "", before = "", after = ""; before = this.labelSbDiffFilter.Text; DialogFormNumKeyPad myKeypad = new DialogFormNumKeyPad(this.labelTitleSBDiffFilter.Text, this.labelSbDiffFilter.Text, 2, 0, false, this.ParentForm.ParentForm.SystemConfig.LANGUAGE); if (myKeypad.ShowDialog() == DialogResult.OK) { if (myKeypad.IntValue < 1 || myKeypad.IntValue > 16) { this.MessageBoxRange = "1 ~ 16"; this.labelSbDiffFilter.Text = before; this.smartTimerMessageShow.Start(); return; } this.labelSbDiffFilter.Text = myKeypad.StringValue; this.ParentForm.ParentForm.SystemConfig.SB_DIFF_FILTER = myKeypad.IntValue; this.ParentForm.ParentForm.SaveSystemConfigurationFile(this.ParentForm.ParentForm.SystemConfig); after = myKeypad.StringValue; value = Helper.StringBlankFillDigits4(myKeypad.StringValue); this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._1706_SbDiffFilter, value); this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.Etc_SbDiffFilter, "", before, after); } } private void labelEquipmentLane_Click(object sender, EventArgs e) { string value = "", before = "", after = ""; before = this.labelEquipmentLane.Text; DialogFormNumKeyPad myKeypad = new DialogFormNumKeyPad(this.labelTitleEquipmentLane.Text, this.labelEquipmentLane.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.LANGUAGE); if (myKeypad.ShowDialog() == DialogResult.OK) { if (myKeypad.IntValue < 1 || myKeypad.IntValue > 16) { this.MessageBoxRange = "1 ~ 16"; this.labelEquipmentLane.Text = before; this.smartTimerMessageShow.Start(); return; } this.labelEquipmentLane.Text = myKeypad.StringValue; this.ParentForm.ParentForm.SystemConfig.EQUIPMENT_LANE = myKeypad.IntValue; this.ParentForm.ParentForm.SaveSystemConfigurationFile(this.ParentForm.ParentForm.SystemConfig); after = myKeypad.StringValue; value = Helper.StringBlankFillDigits4(myKeypad.StringValue); this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._1003_EquipmentLane, value); this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.Etc_EquipmentLane, "", before, after); } } private void labelCheckLane_Click(object sender, EventArgs e) { string value = "", before = "", after = ""; before = this.labelCheckLane.Text; DialogFormNumKeyPad myKeypad = new DialogFormNumKeyPad(this.labelTitleCheckLane.Text, this.labelCheckLane.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig.LANGUAGE); if (myKeypad.ShowDialog() == DialogResult.OK) { if (myKeypad.IntValue < 1 || myKeypad.IntValue > this.ParentForm.ParentForm.SystemConfig.EQUIPMENT_LANE) { this.MessageBoxRange = string.Format("1 ~ {0}", this.ParentForm.ParentForm.SystemConfig.EQUIPMENT_LANE); this.labelEquipmentLane.Text = before; this.smartTimerMessageShow.Start(); return; } this.labelCheckLane.Text = myKeypad.StringValue; this.ParentForm.ParentForm.SystemConfig.CHECK_LANE = myKeypad.IntValue; this.ParentForm.ParentForm.SaveSystemConfigurationFile(this.ParentForm.ParentForm.SystemConfig); after = myKeypad.StringValue; value = Helper.StringBlankFillDigits4(myKeypad.StringValue); this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._1711_CheckLane, value); this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.Etc_CheckLane, "", before, after); } } private void comboBoxLanguage_SelectedIndexChanged(object sender, EventArgs e) { string before = "", after = ""; before = this.ParentForm.ParentForm.SystemConfig.LANGUAGE.ToString(); if (this.comboBoxLanguage.SelectedIndex == 0) this.ParentForm.ParentForm.SystemConfig.LANGUAGE = Define.E_LanguageID.Korean; else if (this.comboBoxLanguage.SelectedIndex == 1) this.ParentForm.ParentForm.SystemConfig.LANGUAGE = Define.E_LanguageID.English; else if (this.comboBoxLanguage.SelectedIndex == 2) this.ParentForm.ParentForm.SystemConfig.LANGUAGE = Define.E_LanguageID.Chinese; else this.ParentForm.ParentForm.SystemConfig.LANGUAGE = Define.E_LanguageID.Korean; this.ParentForm.ParentForm.SaveSystemConfigurationFile(this.ParentForm.ParentForm.SystemConfig); after = this.ParentForm.ParentForm.SystemConfig.LANGUAGE.ToString(); if (before != after) this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.Language, "", before, after); SmartSplash.Start(SmartSplash.BuiltInLoadingImages.PROCESSING1, 200); if (this.ParentForm.Child_Log_Alarm != null) this.ParentForm.Child_Log_Alarm.InitializeDesign(); if (this.ParentForm.Child_Log_History != null) this.ParentForm.Child_Log_History.InitializeDesign(); if (this.ParentForm.Child_Log_Inspection != null) this.ParentForm.Child_Log_Inspection.InitializeDesign(); if (this.ParentForm.Child_Manual_IoTest != null) this.ParentForm.Child_Manual_IoTest.InitializeDesign(); Thread.Sleep(50); if (this.ParentForm.Child_Recipe_Setting != null) this.ParentForm.Child_Recipe_Setting.InitializeDesign(); if(this.ParentForm.Child_Recipe_Setting.ChildControlRecipeData1 != null) this.ParentForm.Child_Recipe_Setting.ChildControlRecipeData1.InitializeDesign(); if (this.ParentForm.Child_Recipe_Setting.ChildControlRecipeData2 != null) this.ParentForm.Child_Recipe_Setting.ChildControlRecipeData2.InitializeDesign(); if (this.ParentForm.Child_System_Equipment10_1 != null) this.ParentForm.Child_System_Equipment10_1.InitializeDesign(); Thread.Sleep(50); if (this.ParentForm.Child_System_Ethernet != null) this.ParentForm.Child_System_Ethernet.InitializeDesign(); if (this.ParentForm.Child_System_Information != null) this.ParentForm.Child_System_Information.InitializeDesign(); if (this.ParentForm.Child_System_Setting != null) this.ParentForm.Child_System_Setting.InitializeDesign(); if (this.ParentForm.Child_User_GroupEditor != null) this.ParentForm.Child_User_GroupEditor.InitializeDesign(); if (this.ParentForm.Child_User_MyPage != null) this.ParentForm.Child_User_MyPage.InitializeDesign(); if (this.ParentForm.Child_User_UserEditor != null) this.ParentForm.Child_User_UserEditor.InitializeDesign(); Thread.Sleep(50); if (this.ParentForm.ParentForm.ChildFormMainDisplay != null) this.ParentForm.ParentForm.ChildFormMainDisplay.InitializeDesign(); if (this.ParentForm.ParentForm.ChildFormMainDisplay.ChildMainDisplay10 != null) this.ParentForm.ParentForm.ChildFormMainDisplay.ChildMainDisplay10.InitializeDesign(); if (this.ParentForm.ParentForm.ChildFormMainDisplay.ChildModbus != null) this.ParentForm.ParentForm.ChildFormMainDisplay.ChildModbus.InitializeDesign(); if (this.ParentForm != null) this.ParentForm.InitializeDesign(); SmartSplash.Finish(); } private void smartTimerMessageShow_Tick(object sender, EventArgs e) { this.smartTimerMessageShow.Stop(); DialogFormMessage msg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig.LANGUAGE, this.MessageBoxRange); msg.ShowDialog(); } #endregion } }