Fix Client Behaviour
This commit is contained in:
@@ -178,7 +178,7 @@ namespace Active_Client.Browser_Tools
|
||||
|
||||
public void setNcWindowState(object sender, CfrV8HandlerExecuteEventArgs e)
|
||||
{
|
||||
if (e.Arguments.Count() == 0)
|
||||
if (e == null || e.Arguments == null || e.Arguments.Count() == 0)
|
||||
return;
|
||||
|
||||
NcWindow.SetState((NcState)e.Arguments[0].IntValue);
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace Active_Client.View
|
||||
private static IntPtr ProdHandle;
|
||||
private int X = 0, Y = 0;
|
||||
private string BrokenUrl;
|
||||
private Boolean closeRight = false;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#region WINDOW_START_&_BEHAVIOUR_METHOD
|
||||
@@ -178,8 +179,9 @@ namespace Active_Client.View
|
||||
|
||||
//Show Taskbar
|
||||
NcWindow.ShowTaskBar();
|
||||
|
||||
|
||||
//Close Chromium Runtime
|
||||
closeRight = true;
|
||||
Close();
|
||||
try
|
||||
{
|
||||
@@ -195,6 +197,8 @@ namespace Active_Client.View
|
||||
|
||||
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if(!closeRight)
|
||||
e.Cancel = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -821,12 +825,6 @@ namespace Active_Client.View
|
||||
//Work only if is a Developer mode
|
||||
if (Config.ClientConfig.DeveloperMode && altPressed)
|
||||
{
|
||||
if (key == (int)Keys.F1)
|
||||
Browser.GoBack();
|
||||
|
||||
if (key == (int)Keys.F2)
|
||||
Browser.GoForward();
|
||||
|
||||
if (key == (int)Keys.F5)
|
||||
{
|
||||
if (Browser.Url.AbsoluteUri != Constants.errorPageUrl)
|
||||
|
||||
Generated
+1
@@ -43,6 +43,7 @@
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
||||
this.Text = "NcForm";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.NcForm_FormClosing);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,12 @@ namespace Active_Client.View
|
||||
Params.ExStyle |= 0x80;
|
||||
return Params;
|
||||
}
|
||||
}
|
||||
|
||||
private void NcForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if(e.CloseReason == CloseReason.UserClosing)
|
||||
e.Cancel = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+29
-7
@@ -218,7 +218,7 @@ namespace Active_Client.View
|
||||
while ((processes.Length <= 0 || (processes[0].MainWindowHandle == IntPtr.Zero) || !isWindowReady(processes[0].MainWindowTitle)) && TriedTimes < TimesToTryOpen)
|
||||
{
|
||||
processes = Process.GetProcessesByName(processname);
|
||||
if (processes.Length <= 0 || (processes[0].MainWindowHandle == IntPtr.Zero))
|
||||
if (processes.Length <= 0 || (processes[0].MainWindowHandle == IntPtr.Zero) || !isWindowReady(processes[0].MainWindowTitle))
|
||||
{
|
||||
Thread.Sleep(WaitingMs);
|
||||
TriedTimes++;
|
||||
@@ -292,7 +292,7 @@ namespace Active_Client.View
|
||||
|
||||
//Wait until the process is started
|
||||
TriedTimes = 1;
|
||||
while ((processes[0].MainWindowHandle == IntPtr.Zero || !isWindowReady(processes[0].MainWindowTitle)) && TriedTimes < TimesToTryKill)
|
||||
while (processes[0].MainWindowHandle == IntPtr.Zero && TriedTimes < TimesToTryKill)
|
||||
{
|
||||
processes = Process.GetProcessesByName(EXEname);
|
||||
if (processes[0].MainWindowHandle == IntPtr.Zero)
|
||||
@@ -330,7 +330,7 @@ namespace Active_Client.View
|
||||
|
||||
//Wait until the process is started
|
||||
TriedTimes = 1;
|
||||
while ((processes.Length <= 0 || (processes[0].MainWindowHandle == IntPtr.Zero) || !isWindowReady(processes[0].MainWindowTitle)) && TriedTimes < TimesToTryOpen)
|
||||
while ((processes.Length <= 0 || (processes[0].MainWindowHandle == IntPtr.Zero)) && TriedTimes < TimesToTryOpen)
|
||||
{
|
||||
processes = Process.GetProcessesByName(EXEname);
|
||||
if (processes.Length <= 0 || (processes[0].MainWindowHandle == IntPtr.Zero))
|
||||
@@ -690,7 +690,10 @@ namespace Active_Client.View
|
||||
UnhookWinEvent(hhookWindow);
|
||||
|
||||
if (keybhook != IntPtr.Zero)
|
||||
UnhookWindowsHookEx(keybhook);
|
||||
UnhookWindowsHookEx(keybhook);
|
||||
|
||||
if (FollowNCThread != null)
|
||||
FollowNCThread.Abort();
|
||||
|
||||
//Un-parent the window
|
||||
if ((Config.VendorHmiConfig.Type == 2) && ncprocess.MainWindowHandle != IntPtr.Zero)
|
||||
@@ -1085,7 +1088,7 @@ namespace Active_Client.View
|
||||
//Hook Keyboard Handle
|
||||
private static void KeybEventProc(int nCode, IntPtr wParam, IntPtr lParam)
|
||||
{
|
||||
int Key = Marshal.ReadInt32(lParam);
|
||||
int Key = Marshal.ReadInt32(lParam);
|
||||
|
||||
//Elaborate Hotkey
|
||||
if (wParam == HWND_KEYDOWN || wParam == HWND_SYSKEYDOWN)
|
||||
@@ -1114,9 +1117,24 @@ namespace Active_Client.View
|
||||
if (KeybPID == MainProcessPID || KeybPID == NcProcessPID || KeybPID == ProdProcessPID)
|
||||
{
|
||||
//Filter if is keydown
|
||||
if (wParam == HWND_SYSKEYDOWN)
|
||||
if (wParam == HWND_SYSKEYDOWN || wParam == HWND_KEYDOWN)
|
||||
mainFrm.keyPressedHandler(altPressed, ctrlPressed, shiftPressed, Key);
|
||||
}
|
||||
if((wParam == HWND_SYSKEYDOWN || wParam == HWND_KEYDOWN) && !altPressed && (KeybPID == MainProcessPID || KeybPID == ProdProcessPID) && state == NcState.SHOW)
|
||||
{
|
||||
//IF Siemens
|
||||
if (Config.VendorHmiConfig.Type == 2)
|
||||
{
|
||||
if (Key >= 0x70 && Key <= 0x87)
|
||||
SetForegroundWindow(ncprocess.MainWindowHandle);
|
||||
}
|
||||
//IF Fanuc
|
||||
else if (Config.VendorHmiConfig.Type == 1)
|
||||
{
|
||||
if ((Key >= 0x70 && Key <= 0x87) || Key == 0xA2 || Key == 0xA3)
|
||||
SetForegroundWindow(ncprocess.MainWindowHandle);
|
||||
}
|
||||
}
|
||||
|
||||
//Call Newx System Hook
|
||||
CallNextHookEx(keybhook, nCode, wParam, lParam);
|
||||
@@ -1436,7 +1454,11 @@ namespace Active_Client.View
|
||||
CaptureThread.Abort();
|
||||
|
||||
//Show Task Bar
|
||||
ShowTaskBar();
|
||||
ShowTaskBar();
|
||||
|
||||
//If the mainform is disposed do nothing
|
||||
if (mainFrm.IsDisposed)
|
||||
return;
|
||||
|
||||
//Exit from Application
|
||||
if (mainFrm.InvokeRequired)
|
||||
|
||||
Generated
+1
@@ -42,6 +42,7 @@
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
||||
this.Text = "ProdForm";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ProdForm_FormClosing);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
@@ -34,5 +34,11 @@ namespace Active_Client.View
|
||||
return Params;
|
||||
}
|
||||
}
|
||||
|
||||
private void ProdForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if (e.CloseReason == CloseReason.UserClosing)
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user