Commit 3a0534d0 张东亮

tab栏加载一次

1 个父辈 1a885adb
......@@ -92,6 +92,14 @@ namespace DeviceLibrary
CodeManager.LoadConfig();
mainMachine = new MainMachine(RobotManage.Config);
//Thread.Sleep(5000);
if (string.IsNullOrEmpty(msg))
{
DataInitEvent?.Invoke(true, "");
}
else
{
DataInitEvent?.Invoke(false, msg);
}
if (!IOManager.ConnectionIOList(new List<string>()))
{
IsLoadOk = false;
......
......@@ -26,7 +26,7 @@ namespace TheMachine
crc.OpenResourceLog = true;
InitializeComponent();
this.FormClosing += Form1_FormClosing;
this.Text =Setting_Init.App_Title + " " + Setting_Init.App_CID;
this.Text = Setting_Init.App_Title + " " + Setting_Init.App_CID;
crc.GetLanguageEvent += Crc_GetLanguageEvent;
crc.LanguageChangeEvent += Crc_LanguageChangeEvent;
crc.CurrLanguage = Crc_GetLanguageEvent();
......@@ -38,8 +38,13 @@ namespace TheMachine
private void Crc_LanguageChangeEvent(object sender, EventArgs e)
{
if (tabc.TabCount > tabpagecount)
addTablePage();
if (RobotManage.IsConfigMode)
{
showDebugTabPages(true);
}
//if (tabc.TabCount > tabpagecount)
// addTablePage();
LanguageProcess();
......@@ -173,10 +178,13 @@ namespace TheMachine
const int tabpagecount = 4;
void addTablePage()
{
this.SuspendLayout();
AddForm("tab_io", crc.GetString(L.tab_io, "IO调试"), ioc);
AddForm("tab_axis", crc.GetString(L.tab_axis, "伺服调试"), ac);
AddForm("tab_store", crc.GetString(L.tab_store, "库位调试"), bd);
AddForm("tab_setting", crc.GetString(L.tab_setting, "相关设置"), sc);
this.ResumeLayout(true);
this.PerformLayout();
crc.LanguageProcess(this);
}
......@@ -208,6 +216,32 @@ namespace TheMachine
this.ResumeLayout(true);
}
List<TabPage> tabPages = new List<TabPage>();
void showDebugTabPages(bool show)
{
if (this.InvokeRequired)
{
this.Invoke((EventHandler)delegate
{
showDebugTabPages(show);
});
return;
}
foreach (var item in tabPages)
{
if (show)
{
item.Parent = tabc;
}
else
{
item.Parent = null;
}
}
crc.LanguageProcess(this);
}
private void AddForm(string id, string text, UserControl form)
{
foreach (TabPage tp in tabc.TabPages)
......@@ -229,6 +263,7 @@ namespace TheMachine
linePan.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left)));
form.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left)));
form.Show();
tabPages.Add(lineTabPage);
tabc.TabPages.Add(lineTabPage);
}
......@@ -240,22 +275,22 @@ namespace TheMachine
RobotManage.IsConfigMode = RobotManage.IsConfigMode ? false : true;
(sender as ToolStripMenuItem).Text = !RobotManage.IsConfigMode ? crc.GetString(L.enable_config_mode, "启用配置模式") : crc.GetString(L.disable_config_mode, "停用配置模式");
showDebugTabPages(RobotManage.IsConfigMode);
if (RobotManage.IsConfigMode)
{
//RobotManage.Config = (Robot_Config)CSVConfigReader.LoadConfig(RobotManage.Config);
addTablePage();
RobotManage.LoadDebug();
}
else
{
var tc = tabc.TabPages.Count;
for (int i = 1; i <= tabpagecount; i++)
{
tabc.TabPages[tc - i].Parent = null;
}
}
//if (RobotManage.IsConfigMode)
//{
// //RobotManage.Config = (Robot_Config)CSVConfigReader.LoadConfig(RobotManage.Config);
// // addTablePage();
// //RobotManage.LoadDebug();
//}
//else
//{
// var tc = tabc.TabPages.Count;
// for (int i = 1; i <= tabpagecount; i++)
// {
// tabc.TabPages[tc - i].Parent = null;
// }
//}
}
public delegate void setmsgdelegate(List<Msg> msgs);
......@@ -283,8 +318,10 @@ namespace TheMachine
});
return;
}
ioc.Config = RobotManage.Config;
bd.Config = RobotManage.Config;
addTablePage();
}
private void RobotManage_LoadFinishEvent(bool state, string msg)
{
......@@ -296,6 +333,7 @@ namespace TheMachine
});
return;
}
showDebugTabPages(false);
启用调试模式ToolStripMenuItem.Enabled = true;
pnl.Enabled = true;
tabc.Enabled = true;
......@@ -320,9 +358,6 @@ namespace TheMachine
//btn_stop.Enabled = true;
RobotManage.mainMachine.ProcessMsgEvent += MainMachine_ProcessMsgEvent;
}
ioc.Config = RobotManage.Config;
bd.Config = RobotManage.Config;
var lm = new List<Msg>();
foreach (string ms in msg.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries))
{
......@@ -338,14 +373,6 @@ namespace TheMachine
object showMsgLoc = new object();
void SetMsg(List<Msg> msgs)
{
//if (this.InvokeRequired)
//{
// this.Invoke((EventHandler)delegate
// {
// SetMsg(msgs);
// });
// return;
//}
if (Monitor.TryEnter(showMsgLoc))
{
try
......@@ -548,7 +575,7 @@ namespace TheMachine
private void cb_EnableBuzzer_CheckedChanged(object sender, EventArgs e)
{
Setting_Init.Enable_Buzzer= cb_EnableBuzzer.Checked;
Setting_Init.Enable_Buzzer = cb_EnableBuzzer.Checked;
AlarmBuzzer.Enable = cb_EnableBuzzer.Checked;
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!