Commit 6a612838 张东亮

合并分支 'tab栏预加载' 到 'master'

tab栏加载一次

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