From 266dff6e8fa64eb7974abf6be7bde9264c422ddc Mon Sep 17 00:00:00 2001 From: Nicola Carminati Date: Thu, 12 Jul 2018 10:16:41 +0200 Subject: [PATCH] Fix Siemens HN Behaviour --- Client/Browser_Tools/BrowserJSObject.cs | 11 ++++++-- Client/View/MainForm.cs | 35 ++++++++++++++----------- Client/View/NcWindow.cs | 5 ++++ 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/Client/Browser_Tools/BrowserJSObject.cs b/Client/Browser_Tools/BrowserJSObject.cs index e8ac4398..96ffbc7a 100644 --- a/Client/Browser_Tools/BrowserJSObject.cs +++ b/Client/Browser_Tools/BrowserJSObject.cs @@ -151,8 +151,15 @@ namespace CMS_Client.Browser_Tools if (val < 0 || val > (NcWindow.NcWindowCommand.Count - 1)) return; - NcWindow.SendCommandKey(NcWindow.NcWindowCommand[val]); - + NcWindow.SendCommandKey(NcWindow.NcWindowCommand[val]); + + if (NcWindow.State == NcState.SHOW) + { + Thread.Sleep(1000); + mainForm.HideNCWindow(); + mainForm.ShowNCWindow(); + NcWindow.ActivateNcWindow(); + } } //Get command vounts to HMI diff --git a/Client/View/MainForm.cs b/Client/View/MainForm.cs index d0554b96..f67e7371 100644 --- a/Client/View/MainForm.cs +++ b/Client/View/MainForm.cs @@ -87,14 +87,17 @@ namespace CMS_Client.View if (this.WindowState == FormWindowState.Minimized) { NcWindow.ShowTaskBar(); - if (Config.VendorHmiConfig.Enabled) - NcFrm.Hide(); + //if (Config.VendorHmiConfig.Enabled) + //NcFrm.Hide(); } else { NcWindow.ShowNcWindow(); - if (Config.VendorHmiConfig.Enabled) - NcFrm.Show(); + if (Config.VendorHmiConfig.Enabled) + { + HideNCWindow(); + ShowNCWindow(); + } } //Refresh Browser Paint @@ -515,9 +518,9 @@ namespace CMS_Client.View { this.Owner = null; this.NcFrm.Owner = this; - this.NcFrm.TopMost = true; - this.NcFrm.TopMost = false; - } + } + this.NcFrm.TopMost = true; + this.NcFrm.TopMost = false; }); else @@ -526,9 +529,9 @@ namespace CMS_Client.View { this.Owner = null; this.NcFrm.Owner = this; - this.NcFrm.TopMost = true; - this.NcFrm.TopMost = false; - } + } + this.NcFrm.TopMost = true; + this.NcFrm.TopMost = false; } } @@ -551,9 +554,9 @@ namespace CMS_Client.View if (this.NcFrm.Owner != null) { this.NcFrm.Owner = null; - this.TopMost = true; - this.TopMost = false; - } + } + this.TopMost = true; + this.TopMost = false; }); else @@ -561,9 +564,9 @@ namespace CMS_Client.View if (this.NcFrm.Owner != null) { this.NcFrm.Owner = null; - this.TopMost = true; - this.TopMost = false; - } + } + this.TopMost = true; + this.TopMost = false; } } } diff --git a/Client/View/NcWindow.cs b/Client/View/NcWindow.cs index e644b21c..5c554df1 100644 --- a/Client/View/NcWindow.cs +++ b/Client/View/NcWindow.cs @@ -524,6 +524,11 @@ namespace CMS_Client.View SendKeys.SendWait(CMD); } } + public static void ActivateNcWindow() + { + SetForegroundWindow(ncprocess.MainWindowHandle); + } + #endregion ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////