Revert "First Commit (not clean, only for test)"
This reverts commit 931f595f3e.
This commit is contained in:
+63
-56
@@ -123,16 +123,26 @@ namespace Active_Client.View
|
||||
NcWindow.ShowTaskBar();
|
||||
|
||||
NcWindow.MinimizeNcWindow();
|
||||
//if (Config.VendorHmiConfig.Type == 3)
|
||||
// NcWindow.HideNcWindow();
|
||||
if (Config.VendorHmiConfig.Type == 3)
|
||||
NcWindow.HideNcWindow();
|
||||
NcWindow.MinimizeProdWindow();
|
||||
}
|
||||
else
|
||||
{
|
||||
NcWindow.ShowNcWindow();
|
||||
//NcWindow.ShowProdWindow();
|
||||
NcWindow.ShowProdWindow();
|
||||
|
||||
|
||||
if (NcWindow.State == NcState.SHOW)
|
||||
{
|
||||
ShowNCWindow();
|
||||
}
|
||||
else if(NcWindow.State == NcState.SHOWPROD)
|
||||
{
|
||||
ShowProdWindow();
|
||||
}
|
||||
else
|
||||
HideAUXWindow();
|
||||
|
||||
}
|
||||
|
||||
@@ -590,37 +600,36 @@ namespace Active_Client.View
|
||||
if (!Config.VendorHmiConfig.Enabled)
|
||||
return;
|
||||
|
||||
NcWindow.ShowNcWindow();
|
||||
//Invoke method if is needed or call the method in STD mode
|
||||
//if (!IsDisposed)
|
||||
//{
|
||||
// if (InvokeRequired)
|
||||
// Invoke((MethodInvoker)delegate ()
|
||||
// {
|
||||
// if (NcFrm.Owner == null)
|
||||
// {
|
||||
// Owner = null;
|
||||
// NcFrm.Owner = this;
|
||||
// if (ProdFrm != null)
|
||||
// ProdFrm.Owner = null;
|
||||
// }
|
||||
// NcFrm.TopMost = true;
|
||||
// NcFrm.TopMost = false;
|
||||
// });
|
||||
if (!IsDisposed)
|
||||
{
|
||||
if (InvokeRequired)
|
||||
Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
if (NcFrm.Owner == null)
|
||||
{
|
||||
Owner = null;
|
||||
NcFrm.Owner = this;
|
||||
if (ProdFrm != null)
|
||||
ProdFrm.Owner = null;
|
||||
}
|
||||
NcFrm.TopMost = true;
|
||||
NcFrm.TopMost = false;
|
||||
});
|
||||
|
||||
// else
|
||||
// {
|
||||
// if (NcFrm.Owner == null)
|
||||
// {
|
||||
// Owner = null;
|
||||
// NcFrm.Owner = this;
|
||||
// if (ProdFrm != null)
|
||||
// ProdFrm.Owner = null;
|
||||
// }
|
||||
// NcFrm.TopMost = true;
|
||||
// NcFrm.TopMost = false;
|
||||
// }
|
||||
//}
|
||||
else
|
||||
{
|
||||
if (NcFrm.Owner == null)
|
||||
{
|
||||
Owner = null;
|
||||
NcFrm.Owner = this;
|
||||
if (ProdFrm != null)
|
||||
ProdFrm.Owner = null;
|
||||
}
|
||||
NcFrm.TopMost = true;
|
||||
NcFrm.TopMost = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Show NC Method
|
||||
@@ -670,32 +679,30 @@ namespace Active_Client.View
|
||||
if ((!Config.VendorHmiConfig.Enabled && !Config.ProdSoftwareConfig.Enabled) || (NcFrm==null && ProdFrm == null))
|
||||
return;
|
||||
|
||||
//NcWindow.HideNcWindow();
|
||||
NcWindow.HideNcWindow();
|
||||
//Invoke method if is needed or call the method in STD mode
|
||||
//if (!IsDisposed)
|
||||
//{
|
||||
// if (InvokeRequired)
|
||||
// Invoke((MethodInvoker)delegate ()
|
||||
// {
|
||||
// if (NcFrm != null && NcFrm.Owner != null)
|
||||
// NcFrm.Owner = null;
|
||||
// if (ProdFrm != null && ProdFrm.Owner != null)
|
||||
// ProdFrm.Owner = null;
|
||||
// TopMost = true;
|
||||
// TopMost = false;
|
||||
// });
|
||||
if (!IsDisposed)
|
||||
{
|
||||
if (InvokeRequired)
|
||||
Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
if (NcFrm != null && NcFrm.Owner != null)
|
||||
NcFrm.Owner = null;
|
||||
if (ProdFrm != null && ProdFrm.Owner != null)
|
||||
ProdFrm.Owner = null;
|
||||
TopMost = true;
|
||||
TopMost = false;
|
||||
});
|
||||
|
||||
// else
|
||||
// {
|
||||
// if (NcFrm != null && NcFrm.Owner != null)
|
||||
// NcFrm.Owner = null;
|
||||
// if (ProdFrm != null && ProdFrm.Owner != null)
|
||||
// ProdFrm.Owner = null;
|
||||
// TopMost = true;
|
||||
// TopMost = false;
|
||||
// }
|
||||
//}
|
||||
else
|
||||
{
|
||||
if (NcFrm != null && NcFrm.Owner != null)
|
||||
NcFrm.Owner = null;
|
||||
if (ProdFrm != null && ProdFrm.Owner != null)
|
||||
ProdFrm.Owner = null;
|
||||
TopMost = true;
|
||||
TopMost = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+52
-13
@@ -479,8 +479,8 @@ namespace Active_Client.View
|
||||
//Hide Nc Window
|
||||
public static void HideNcWindow()
|
||||
{
|
||||
if (windowstarted)
|
||||
ResizeAndMoveNcWindow(ncWindowX, ncWindowY, 0, 0);
|
||||
if (windowstarted)
|
||||
ShowWindow(ncprocess.MainWindowHandle, WS_HIDE);
|
||||
}
|
||||
|
||||
//Hide Prod Window
|
||||
@@ -604,11 +604,11 @@ namespace Active_Client.View
|
||||
|
||||
//Set the parent of the window
|
||||
if (windowstarted)
|
||||
SetParent(ncprocess.MainWindowHandle, MainViewHandle);
|
||||
SetParent(ncprocess.MainWindowHandle, NcHandle);
|
||||
|
||||
//Set the parent of the window
|
||||
if (prodwindowstarted)
|
||||
SetParent(prodprocess.MainWindowHandle, MainViewHandle);
|
||||
SetParent(prodprocess.MainWindowHandle, ProdHandle);
|
||||
|
||||
//Get the Process-Id
|
||||
GetWindowThreadProcessId(MainViewHandle, out MainProcessPID);
|
||||
@@ -1026,7 +1026,7 @@ namespace Active_Client.View
|
||||
//if it has the border and a title execute focus
|
||||
if (ActiveNCWindowStyle != 0 && ActiveNCWindowBorder == WS_BORDER && ReadWindowTitle(hwnd) != "" && hwnd != ncprocess.MainWindowHandle)
|
||||
{
|
||||
//SetWindowPos(ncprocess.MainWindowHandle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_SHOWWINDOW);
|
||||
SetWindowPos(ncprocess.MainWindowHandle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_SHOWWINDOW);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1117,7 +1117,50 @@ namespace Active_Client.View
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#region PRIVATE_CUSTOM_METHODS
|
||||
|
||||
|
||||
//Resize out of Bound window
|
||||
private static void ResizeOutofBoundWindow(IntPtr ParentHandle, IntPtr WindowHandle)
|
||||
{
|
||||
RECT MainRct;
|
||||
RECT ParentRct;
|
||||
int width;
|
||||
int height;
|
||||
int width2;
|
||||
int height2;
|
||||
int newX;
|
||||
int newY;
|
||||
bool move = false;
|
||||
bool resize = false;
|
||||
|
||||
if (GetWindowRect(WindowHandle, out MainRct) && GetWindowRect(ParentHandle, out ParentRct))
|
||||
{
|
||||
//Setup resize and move variables
|
||||
width = (MainRct.Right - MainRct.Left + 1);
|
||||
height = (MainRct.Bottom - MainRct.Top + 1);
|
||||
width2 = (ParentRct.Right - ParentRct.Left + 1);
|
||||
height2 = (ParentRct.Bottom - ParentRct.Top + 1);
|
||||
newX = width2 / 2 - width / 2 + ParentRct.Left;
|
||||
newY = height2 / 2 - height / 2 + ParentRct.Top;
|
||||
|
||||
//Check if i need to resize
|
||||
if (width > width2 || height > height2)
|
||||
resize = true;
|
||||
|
||||
//Check if i need to move
|
||||
if (MainRct.Left < ParentRct.Left || MainRct.Top < ParentRct.Top || MainRct.Right > ParentRct.Right || MainRct.Bottom > ParentRct.Bottom)
|
||||
move = true;
|
||||
|
||||
//Move or Resize the Window
|
||||
if (move & !resize)
|
||||
MoveWindow(WindowHandle, newX, newY, width, height, true);
|
||||
else if (resize)
|
||||
MoveWindow(WindowHandle, ParentRct.Left, ParentRct.Top, LastWidth, LastHeight, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Read Window Title
|
||||
private static string ReadWindowTitle(IntPtr hwnd)
|
||||
{
|
||||
int length = GetWindowTextLength(hwnd);
|
||||
@@ -1134,11 +1177,11 @@ namespace Active_Client.View
|
||||
LastY = Y;
|
||||
LastWidth = width;
|
||||
LastHeight = height;
|
||||
bool repaint = Config.VendorHmiConfig.Type == 1;
|
||||
|
||||
//Win32 Method
|
||||
if (ncprocess != null && windowstarted)
|
||||
{
|
||||
MoveWindow(ncprocess.MainWindowHandle, LastX, LastY, LastWidth, LastHeight, repaint);
|
||||
MoveWindow(ncprocess.MainWindowHandle, LastX, LastY, LastWidth, LastHeight, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1358,9 +1401,7 @@ namespace Active_Client.View
|
||||
{
|
||||
uint process = 0;
|
||||
try
|
||||
{
|
||||
Process[] pr = Process.GetProcessesByName(processname);
|
||||
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
|
||||
@@ -1372,9 +1413,7 @@ namespace Active_Client.View
|
||||
else if (state == NcState.SHOW && process == ProdProcessPID && windowstarted)
|
||||
mainFrm.ShowNCWindow();
|
||||
|
||||
pr = Process.GetProcessesByName(processname);
|
||||
|
||||
if (pr.Length == 0)
|
||||
if (Process.GetProcessesByName(processname).Length == 0)
|
||||
{
|
||||
//Un-parent the window
|
||||
if (ncprocess.MainWindowHandle != IntPtr.Zero)
|
||||
|
||||
Reference in New Issue
Block a user