diff --git a/Client/Program.cs b/Client/Program.cs index 16bb15bc..e45eb79b 100644 --- a/Client/Program.cs +++ b/Client/Program.cs @@ -209,7 +209,7 @@ namespace CMS_Client #region ALARM_METHODS //Method Used to Show an alarm and close the application - private static void ShowAlarmAndClose(string Message) + public static void ShowAlarmAndClose(string Message) { MessageBox.Show(Message, Application.ProductName, diff --git a/Client/View/MainForm.cs b/Client/View/MainForm.cs index b928d794..a5b1ae48 100644 --- a/Client/View/MainForm.cs +++ b/Client/View/MainForm.cs @@ -119,7 +119,7 @@ namespace CMS_Client.View } else { - if (Config.VendorHmiConfig.Enabled) + if (Config.VendorHmiConfig.Enabled && NcFrm != null) NcFrm.Show(); if (NcWindow.State == NcState.SHOW) @@ -434,6 +434,14 @@ namespace CMS_Client.View private void ShowWindow() { + if(Config.ClientConfig.DeveloperMode && Width < 1920 && Height < 1080) + { + double ratio = (((double)Width) / 1920.0) * 100.0; + //Funzione sperimentale presa da Forum CEF + double delta = 5.46149645 * Math.Log(ratio) - 25.12; + Browser.BrowserHost.ZoomLevel = delta; + } + //Invoke method if is needed or call the method in STD mode if (!IsDisposed) { @@ -583,7 +591,7 @@ namespace CMS_Client.View //Hide NC Method public void HideNCWindow() { - if (!Config.VendorHmiConfig.Enabled) + if (!Config.VendorHmiConfig.Enabled || NcFrm==null) return; //Invoke method if is needed or call the method in STD mode @@ -617,13 +625,55 @@ namespace CMS_Client.View private void CalcWindowPosition() { //Position of the Window + Screen ps = Screen.AllScreens.FirstOrDefault(S => S.Primary == true); + if (Screen.AllScreens.Length > 1 && Config.ClientConfig.RunningOnSecondaryScreen) { - Screen ps = Screen.AllScreens.FirstOrDefault(S => S.Primary == true); Screen ss = Screen.AllScreens.FirstOrDefault(S => S.Primary == false); X = ps.Bounds.Width; if (ss.Bounds.Top != 0) Y = ss.Bounds.Top; + + //Set the Secondary screen Size + if (Config.ClientConfig.DeveloperMode) + { + if (ss.Bounds.Width < 1920 && ss.Bounds.Height < 1080) + { + this.Width = ss.Bounds.Width; + this.Height = ss.Bounds.Height; + } + } + else + { + if (ss.Bounds.Width != 1920 && ss.Bounds.Height != 1080) + { + HideLoadingWindow(); + NcWindow.CloseNcWindow(false); + Program.ShowAlarmAndClose("Screen resolution " + ss.Bounds.Width + "x" + ss.Bounds.Height + " is not supported"); + } + } + } + else + { + if (Config.ClientConfig.DeveloperMode) + { + //Set the Prymary screen Size + if (ps.Bounds.Width < 1920 && ps.Bounds.Height < 1080) + { + this.Width = ps.Bounds.Width; + this.Height = ps.Bounds.Height; + } + + } + else + { + if (ps.Bounds.Width != 1920 && ps.Bounds.Height != 1080) + { + HideLoadingWindow(); + NcWindow.CloseNcWindow(false); + Program.ShowAlarmAndClose("Screen resolution " + ps.Bounds.Width + "x" + ps.Bounds.Height + " is not supported"); + } + } } } @@ -659,7 +709,6 @@ namespace CMS_Client.View } } - #endregion } }