Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
1069_MIMO_PlUS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 225269da
由
张东亮
编写于
2023-04-20 17:52:26 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
监控相机单独进程嵌入程序
1 个父辈
dcc082d6
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
375 行增加
和
56 行删除
Common/Common.csproj
Common/util/ProcessUtil.cs
Common/util/WindowUtil.cs
DeviceLibrary/DeviceLibrary/Camera.cs
DeviceLibrary/theMachine/RobotManage.cs
TheMachine/Form1.Designer.cs
TheMachine/Form1.cs
TheMachine/TheMachine.csproj
TheMachine/WindowManager.cs
Common/Common.csproj
查看文件 @
225269d
...
...
@@ -73,9 +73,11 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="util\CTcpClient.cs" />
<Compile Include="util\ProcessUtil.cs" />
<Compile Include="util\SMF.cs" />
<Compile Include="util\TcpServer.cs" />
<Compile Include="util\UdpServer.cs" />
<Compile Include="util\WindowUtil.cs" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
...
...
Common/util/ProcessUtil.cs
0 → 100644
查看文件 @
225269d
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
namespace
Common
{
/// <summary>
/// 软件管理工具
/// </summary>
public
class
ProcessUtil
{
/// <summary>
/// 设置自动启动
/// </summary>
/// <param name="strName"></param>
/// <param name="value"></param>
public
static
void
AutoRun
(
string
strName
,
bool
value
)
{
try
{
//创建启动对象
System
.
Diagnostics
.
ProcessStartInfo
startInfo
=
new
System
.
Diagnostics
.
ProcessStartInfo
();
//设置运行文件
startInfo
.
FileName
=
System
.
Windows
.
Forms
.
Application
.
StartupPath
+
"\\AuToRunManager.exe"
;
//设置启动参数
startInfo
.
Arguments
=
String
.
Join
(
" "
,
new
string
[
2
]
{
strName
,
value
.
ToString
()
});
//设置启动动作,确保以管理员身份运行
startInfo
.
Verb
=
"runas"
;
//如果不是管理员,则启动UAC
System
.
Diagnostics
.
Process
.
Start
(
startInfo
);
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
ex
.
ToString
());
}
}
public
static
Process
StartProcess
(
string
appName
,
string
baseDir
=
@".\"
,
int
waitIdle
=
5000
)
{
try
{
Process
process
=
new
Process
();
process
.
StartInfo
=
new
System
.
Diagnostics
.
ProcessStartInfo
();
process
.
StartInfo
.
FileName
=
appName
+
".exe"
;
process
.
StartInfo
.
WorkingDirectory
=
baseDir
;
process
.
Start
();
process
.
WaitForInputIdle
(
waitIdle
);
return
process
;
}
catch
(
Exception
ex
)
{
}
return
null
;
}
public
static
Process
IsRun
(
Process
process
)
{
Process
processRun
=
new
Process
();
try
{
System
.
Diagnostics
.
Process
[]
processList
=
System
.
Diagnostics
.
Process
.
GetProcesses
();
foreach
(
System
.
Diagnostics
.
Process
process2
in
processList
)
{
if
(
process2
.
Id
==
process
.
Id
)
{
processRun
=
process
;
}
}
}
catch
{
}
return
processRun
;
}
public
static
bool
CloseProcess
(
Process
process
)
{
bool
sc
=
false
;
try
{
System
.
Diagnostics
.
Process
[]
processList
=
System
.
Diagnostics
.
Process
.
GetProcesses
();
foreach
(
System
.
Diagnostics
.
Process
process2
in
processList
)
{
if
(
process2
.
Id
==
process
.
Id
)
{
process
.
Kill
();
//结束进程
sc
=
process
.
WaitForExit
(
100000
);
}
}
}
catch
{
sc
=
true
;
}
return
sc
;
}
}
}
Common/util/WindowUtil.cs
0 → 100644
查看文件 @
225269d
using
log4net.Util
;
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Runtime.InteropServices
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
using
System.Xml.Linq
;
namespace
Common
{
public
class
WindowUtil
{
public
const
int
WM_CLOSE
=
0x0010
;
static
List
<
Process
>
SubProcesses
=
new
List
<
Process
>();
public
static
Process
OpenExe
(
Panel
panel
,
string
appName
,
string
titleName
,
string
baseDir
=
@".\"
)
{
if
(
appName
==
null
||
appName
==
string
.
Empty
)
return
null
;
Process
process
=
null
;
IntPtr
appWin
=
IntPtr
.
Zero
;
try
{
process
=
ProcessUtil
.
StartProcess
(
appName
,
baseDir
);
}
catch
(
Exception
ex
)
{
// MessageBox.Show(fm, ex.Message, "Error");
return
process
;
}
return
process
;
}
public
static
IntPtr
PutIntoForm
(
Panel
panel
,
string
titleName
)
{
IntPtr
appWin
=
FindWindow
(
null
,
titleName
);
// Put it into this form
SetParent
(
appWin
,
panel
.
Handle
);
// Remove border and whatnot
// SetWindowLong(appWin, GWL_STYLE, WS_VISIBLE);
// Move the window to overlay it on this window
MoveWindow
(
appWin
,
0
,
0
,
panel
.
Width
+
2
,
panel
.
Height
,
true
);
return
appWin
;
}
public
static
void
Resize
(
Panel
panel
,
string
titleName
)
{
IntPtr
appWin
=
FindWindow
(
null
,
titleName
);
if
(
appWin
!=
IntPtr
.
Zero
)
WindowUtil
.
MoveWindow
(
appWin
,
0
,
0
,
panel
.
Width
,
panel
.
Height
,
true
);
}
public
static
void
RemoveFromForm
(
string
titleName
)
{
IntPtr
appWin
=
FindWindow
(
null
,
titleName
);
// Put it into this form
SetParent
(
appWin
,
IntPtr
.
Zero
);
}
/// <summary>
/// 找到某个窗口与给出的类别名和窗口名相同窗口
/// </summary>
/// <param name="lpClassName">类别名</param>
/// <param name="lpWindowName">窗口名</param>
/// <returns>成功找到返回窗口句柄,否则返回null</returns>
[
DllImport
(
"user32.dll"
)]
public
static
extern
IntPtr
FindWindow
(
string
lpClassName
,
string
lpWindowName
);
/// <summary>
/// 切换到窗口并把窗口设入前台,类似 SetForegroundWindow方法的功能
/// </summary>
/// <param name="hWnd">窗口句柄</param>
/// <param name="fAltTab">True代表窗口正在通过Alt/Ctrl +Tab被切换</param>
[
DllImport
(
"user32.dll "
,
SetLastError
=
true
)]
public
static
extern
void
SwitchToThisWindow
(
IntPtr
hWnd
,
bool
fAltTab
);
/// <summary>
/// 设置窗口的显示状态
/// </summary>
/// <param name="hWnd">窗口句柄</param>
/// <param name="cmdShow">指示窗口如何被显示</param>
/// <returns>如果窗体之前是可见,返回值为非零;如果窗体之前被隐藏,返回值为零</returns>
[
DllImport
(
"user32.dll"
,
EntryPoint
=
"ShowWindow"
,
CharSet
=
CharSet
.
Auto
)]
public
static
extern
int
ShowWindow
(
IntPtr
hwnd
,
int
nCmdShow
);
[
DllImport
(
"user32.dll"
,
SetLastError
=
true
)]
private
static
extern
long
SetParent
(
IntPtr
hWndChild
,
IntPtr
hWndNewParent
);
/// <summary>
/// 改变指定窗口的位置和尺寸
/// </summary>
/// <param name="hwnd">窗口句柄</param>
/// <param name="x">窗口左侧的新位置</param>
/// <param name="y">窗口顶部的新位置</param>
/// <param name="nWidth">窗口的新宽度</param>
/// <param name="nHeight">窗口的新高度</param>
/// <param name="bRepaint">指示是否重新绘制窗口。 如果此参数为 TRUE,窗口将收到消息。 如果参数为 FALSE,则不会重新绘制任何类型的参数。 这适用于工作区、非client 区域 (,包括标题栏和滚动条) ,以及由于移动子窗口而发现父窗口的任何部分</param>
/// <returns>该函数成功,则返回值为非零值</returns>
[
DllImport
(
"user32.dll"
,
SetLastError
=
true
)]
private
static
extern
bool
MoveWindow
(
IntPtr
hwnd
,
int
x
,
int
y
,
int
nWidth
,
int
nHeight
,
bool
bRepaint
);
[
DllImport
(
"user32.dll"
)]
private
static
extern
bool
EnumWindows
(
WNDENUMPROC
lpEnumFunc
,
int
lParam
);
[
DllImport
(
"user32.dll"
,
CharSet
=
CharSet
.
Auto
)]
public
static
extern
int
SendMessage
(
IntPtr
hWnd
,
int
msg
,
int
wParam
,
string
lparam
);
[
DllImport
(
"user32.dll"
,
EntryPoint
=
"PostMessage"
)]
public
static
extern
int
PostMessage
(
IntPtr
hwnd
,
int
Msg
,
int
wParam
,
int
lParam
);
[
DllImport
(
"user32.dll"
)]
public
static
extern
int
GetWindowText
(
IntPtr
hWnd
,
StringBuilder
lpString
,
int
nMaxCount
);
[
DllImport
(
"user32.dll"
)]
private
static
extern
int
GetWindowTextW
(
IntPtr
hWnd
,
[
MarshalAs
(
UnmanagedType
.
LPWStr
)]
StringBuilder
lpString
,
int
nMaxCount
);
[
DllImport
(
"user32.dll"
)]
private
static
extern
int
GetClassNameW
(
IntPtr
hWnd
,
[
MarshalAs
(
UnmanagedType
.
LPWStr
)]
StringBuilder
lpString
,
int
nMaxCount
);
private
delegate
bool
WNDENUMPROC
(
IntPtr
hWnd
,
int
lParam
);
//寻找系统的全部窗口
public
static
WindowInfo
[]
GetAllDesktopWindows
()
{
List
<
WindowInfo
>
wndList
=
new
List
<
WindowInfo
>();
EnumWindows
(
delegate
(
IntPtr
hWnd
,
int
lParam
)
{
WindowInfo
wnd
=
new
WindowInfo
();
StringBuilder
sb
=
new
StringBuilder
(
256
);
//get hwnd
wnd
.
hWnd
=
hWnd
;
//get window name
GetWindowTextW
(
hWnd
,
sb
,
sb
.
Capacity
);
wnd
.
szWindowName
=
sb
.
ToString
();
//get window class
GetClassNameW
(
hWnd
,
sb
,
sb
.
Capacity
);
wnd
.
szClassName
=
sb
.
ToString
();
Console
.
WriteLine
(
"Window handle="
+
wnd
.
hWnd
.
ToString
().
PadRight
(
20
)
+
" szClassName="
+
wnd
.
szClassName
.
PadRight
(
20
)
+
" szWindowName="
+
wnd
.
szWindowName
);
//add it into list
wndList
.
Add
(
wnd
);
return
true
;
},
0
);
return
wndList
.
ToArray
();
}
public
static
IntPtr
GetDesktopWindows
(
string
windowName
,
StringComparison
comparison
=
StringComparison
.
Ordinal
)
{
WindowInfo
[]
allWindow
=
WindowUtil
.
GetAllDesktopWindows
();
var
wnd
=
allWindow
.
FirstOrDefault
(
s
=>
s
.
szWindowName
.
Equals
(
windowName
,
comparison
));
return
wnd
.
hWnd
;
}
}
public
struct
WindowInfo
{
public
IntPtr
hWnd
;
public
string
szWindowName
;
public
string
szClassName
;
}
}
DeviceLibrary/DeviceLibrary/Camera.cs
查看文件 @
225269d
...
...
@@ -73,36 +73,36 @@ public class HIKCamera
bool
camerathreadrun
=
true
;
public
void
startCamera
()
{
if
(!
VideoManager
.
IsRecording
(
Name
))
{
VideoManager
.
StartRecord
(
Name
,
"Auto2"
);
}
//
if(!VideoManager.IsRecording(Name))
//
{
//
VideoManager.StartRecord(Name, "Auto2");
//
}
}
public
void
stopCamera
()
{
VideoManager
.
StopRecord
(
Name
);
VideoManager
.
Close
();
//
VideoManager.StopRecord(Name);
//
VideoManager.Close();
camerathreadrun
=
false
;
}
public
void
CameraGrabOne
(
string
filename
)
{
try
{
LogUtil
.
info
(
Name
+
"库位文件名:"
+
filename
);
VideoManager
.
GrabOneImg
(
Name
,
out
Bitmap
bmp
);
if
(
bmp
!=
null
)
{
if
(
File
.
Exists
(
filename
))
File
.
Delete
(
filename
);
//
try
//
{
//
LogUtil.info(Name + "库位文件名:" + filename);
//
VideoManager.GrabOneImg(Name, out Bitmap bmp);
//
if (bmp != null)
//
{
//
if (File.Exists(filename))
//
File.Delete(filename);
bmp
.
Save
(
filename
,
ImageFormat
.
Jpeg
);
bmp
.
Dispose
();
}
}
catch
(
Exception
e
)
{
LogUtil
.
error
(
Name
+
e
.
ToString
());
}
//
bmp.Save(filename, ImageFormat.Jpeg);
//
bmp.Dispose();
//
}
//
}
//
catch (Exception e)
//
{
//
LogUtil.error(Name + e.ToString());
//
}
}
public
string
GetFixtureStateFilename
(
string
PositionNum
,
string
WareNumber
,
StoreMoveType
storeMoveType
,
FixtureState
fixtureState
)
{
...
...
DeviceLibrary/theMachine/RobotManage.cs
查看文件 @
225269d
...
...
@@ -80,11 +80,11 @@ namespace DeviceLibrary
msg
+=
crc
.
GetString
(
L
.
iocard_init_fail
,
"IO板卡初始化失败"
)+
"\n"
;
}
// IOManager.CloseAllConnection();
if
(!
CameraA
.
LoadCameraConfig
(
out
string
errmsg
,
param
[
0
]))
{
IsLoadOk
=
false
;
msg
+=
errmsg
+
"\r\n"
;
}
//
if (!CameraA.LoadCameraConfig(out string errmsg, param[0]))
//
{
//
IsLoadOk = false;
//
msg += errmsg + "\r\n";
//
}
if
(!
HumitureController
.
Init
(
ConfigHelper
.
Config
.
Get
(
"Device_Humiture_Port"
)))
{
IsLoadOk
=
false
;
msg
+=
crc
.
GetString
(
L
.
tempnhum_sensor_init_fail
,
$
"温湿度传感器初始化失败,端口:"
)+
$
"{ConfigHelper.Config.Get("
Device_Humiture_Port
")}\n"
;
...
...
TheMachine/Form1.Designer.cs
查看文件 @
225269d
...
...
@@ -51,20 +51,19 @@ namespace TheMachine
this
.
cb_IgnoreSafecheck
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
pictureBox2
=
new
System
.
Windows
.
Forms
.
PictureBox
();
this
.
cb_IgnoreGratingSignal
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
pictureBox1
=
new
System
.
Windows
.
Forms
.
PictureBox
();
this
.
cb_EnableBuzzer
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
btn_IgnoreX09
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btn_PauseBuzzer
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
listView1
=
new
System
.
Windows
.
Forms
.
ListView
();
this
.
btn_stop
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btn_run
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
panelVideo
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
menuStrip1
.
SuspendLayout
();
this
.
tabc
.
SuspendLayout
();
this
.
tabP1
.
SuspendLayout
();
this
.
pnl
.
SuspendLayout
();
this
.
groupBox1
.
SuspendLayout
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
pictureBox2
)).
BeginInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
pictureBox1
)).
BeginInit
();
this
.
SuspendLayout
();
//
// menuStrip1
...
...
@@ -196,12 +195,12 @@ namespace TheMachine
//
// pnl
//
this
.
pnl
.
Controls
.
Add
(
this
.
panelVideo
);
this
.
pnl
.
Controls
.
Add
(
this
.
groupBox1
);
this
.
pnl
.
Controls
.
Add
(
this
.
btn_releasestring
);
this
.
pnl
.
Controls
.
Add
(
this
.
cb_IgnoreSafecheck
);
this
.
pnl
.
Controls
.
Add
(
this
.
pictureBox2
);
this
.
pnl
.
Controls
.
Add
(
this
.
cb_IgnoreGratingSignal
);
this
.
pnl
.
Controls
.
Add
(
this
.
pictureBox1
);
this
.
pnl
.
Controls
.
Add
(
this
.
cb_EnableBuzzer
);
this
.
pnl
.
Controls
.
Add
(
this
.
btn_IgnoreX09
);
this
.
pnl
.
Controls
.
Add
(
this
.
btn_PauseBuzzer
);
...
...
@@ -282,19 +281,6 @@ namespace TheMachine
this
.
cb_IgnoreGratingSignal
.
Visible
=
false
;
this
.
cb_IgnoreGratingSignal
.
CheckedChanged
+=
new
System
.
EventHandler
(
this
.
cb_IgnoreGratingSignal_CheckedChanged
);
//
// pictureBox1
//
this
.
pictureBox1
.
BackColor
=
System
.
Drawing
.
Color
.
Gainsboro
;
this
.
pictureBox1
.
Location
=
new
System
.
Drawing
.
Point
(
3
,
258
);
this
.
pictureBox1
.
Name
=
"pictureBox1"
;
this
.
pictureBox1
.
Size
=
new
System
.
Drawing
.
Size
(
451
,
271
);
this
.
pictureBox1
.
SizeMode
=
System
.
Windows
.
Forms
.
PictureBoxSizeMode
.
Zoom
;
this
.
pictureBox1
.
TabIndex
=
271
;
this
.
pictureBox1
.
TabStop
=
false
;
this
.
pictureBox1
.
Visible
=
false
;
this
.
pictureBox1
.
DoubleClick
+=
new
System
.
EventHandler
(
this
.
pictureBox1_DoubleClick
);
this
.
pictureBox1
.
MouseDown
+=
new
System
.
Windows
.
Forms
.
MouseEventHandler
(
this
.
pictureBox1_MouseDown
);
//
// cb_EnableBuzzer
//
this
.
cb_EnableBuzzer
.
AutoSize
=
true
;
...
...
@@ -369,6 +355,13 @@ namespace TheMachine
this
.
btn_run
.
UseVisualStyleBackColor
=
true
;
this
.
btn_run
.
Click
+=
new
System
.
EventHandler
(
this
.
btn_run_Click
);
//
// panelVideo
//
this
.
panelVideo
.
Location
=
new
System
.
Drawing
.
Point
(
21
,
258
);
this
.
panelVideo
.
Name
=
"panelVideo"
;
this
.
panelVideo
.
Size
=
new
System
.
Drawing
.
Size
(
436
,
271
);
this
.
panelVideo
.
TabIndex
=
273
;
//
// Form1
//
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
9F
,
17F
);
...
...
@@ -396,7 +389,6 @@ namespace TheMachine
this
.
pnl
.
PerformLayout
();
this
.
groupBox1
.
ResumeLayout
(
false
);
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
pictureBox2
)).
EndInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
pictureBox1
)).
EndInit
();
this
.
ResumeLayout
(
false
);
this
.
PerformLayout
();
...
...
@@ -424,7 +416,6 @@ namespace TheMachine
private
System
.
Windows
.
Forms
.
CheckBox
cb_EnableBuzzer
;
private
System
.
Windows
.
Forms
.
Button
btn_PauseBuzzer
;
private
System
.
Windows
.
Forms
.
PictureBox
pictureBox2
;
private
System
.
Windows
.
Forms
.
PictureBox
pictureBox1
;
private
System
.
Windows
.
Forms
.
Button
btn_IgnoreX09
;
private
System
.
Windows
.
Forms
.
Button
btn_releasestring
;
private
System
.
Windows
.
Forms
.
Panel
pnl
;
...
...
@@ -432,6 +423,7 @@ namespace TheMachine
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
简体中文
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
日本语
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
englishToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
Panel
panelVideo
;
}
}
TheMachine/Form1.cs
查看文件 @
225269d
using
CodeLibrary
;
using
Common
;
using
ConfigHelper
;
using
DeviceLibrary
;
using
OnlineStore
;
...
...
@@ -129,12 +130,11 @@ namespace TheMachine
RobotManage
.
UserPauseSet
+=
RobotManage_UserPauseSet
;
RobotManage
.
CameraA
.
camera_event
+=
CameraA_camera_event
;
CodeManager
.
camera_event
+=
CameraB_camera_event
;
IntPtr
camAIntptr
=
pictureBox
1
.
Handle
;
IntPtr
camAIntptr
=
pictureBox
2
.
Handle
;
var
loadtask
=
Task
.
Run
(()
=>
{
RobotManage
.
Init
(
camAIntptr
);
RobotManage
.
Init
();
});
ListViewItem
lvi
=
new
ListViewItem
(
new
string
[]
{
""
,
DateTime
.
Now
.
ToString
(),
crc
.
GetString
(
L
.
device_initializing
,
"设备加载中,请稍后..."
)
});
lvi
.
ForeColor
=
Color
.
DarkGreen
;
...
...
@@ -143,16 +143,9 @@ namespace TheMachine
// Thread.Sleep(100);
// Application.DoEvents();
//}
LoadWindow
();
pnl
.
Enabled
=
false
;
}
private
void
CameraA_camera_event
(
object
sender
,
Bitmap
e
)
{
this
.
Invoke
((
EventHandler
<
Bitmap
>)
delegate
{
pictureBox1
.
Visible
=
true
;
pictureBox1
.
Image
=
e
;
},
sender
,
e
);
}
private
void
CameraB_camera_event
(
object
sender
,
Bitmap
e
)
{
this
.
Invoke
((
EventHandler
<
Bitmap
>)
delegate
...
...
@@ -322,6 +315,7 @@ namespace TheMachine
lm
.
Add
(
m
);
}
SetMsg
(
lm
);
WindowManager
.
Show
();
}
void
SetMsg
(
List
<
Msg
>
msgs
)
{
...
...
@@ -676,5 +670,34 @@ namespace TheMachine
Config
.
Set
(
"Device_Default_Language"
,
"en-US"
);
crc
.
LanguageChange
();
}
#
region
窗口管理
void
LoadWindow
()
{
var
ipcamera
=
new
WindInfo
()
{
Parent
=
panelVideo
,
Name
=
WindInfo
.
IPCamera
};
WindowManager
.
windInfos
.
Add
(
ipcamera
);
WindowManager
.
Start
();
}
/// <summary>
/// 销毁窗口
/// </summary>
/// <param name="e"></param>
protected
override
void
OnHandleDestroyed
(
EventArgs
e
)
{
foreach
(
var
wnd
in
WindowManager
.
windInfos
)
{
if
(
wnd
.
WindowHandle
!=
IntPtr
.
Zero
)
{
WindowUtil
.
PostMessage
(
wnd
.
WindowHandle
,
WindowUtil
.
WM_CLOSE
,
0
,
0
);
// Delay for it to get the message
System
.
Threading
.
Thread
.
Sleep
(
1000
);
// Clear internal handle
wnd
.
WindowHandle
=
IntPtr
.
Zero
;
}
}
base
.
OnHandleDestroyed
(
e
);
}
#
endregion
}
}
TheMachine/TheMachine.csproj
查看文件 @
225269d
...
...
@@ -154,6 +154,7 @@
<Compile Include="UC\UC_SetUserPassword.designer.cs">
<DependentUpon>UC_SetUserPassword.cs</DependentUpon>
</Compile>
<Compile Include="WindowManager.cs" />
<EmbeddedResource Include="AboutBox1.resx">
<DependentUpon>AboutBox1.cs</DependentUpon>
</EmbeddedResource>
...
...
TheMachine/WindowManager.cs
0 → 100644
查看文件 @
225269d
using
Common
;
using
OnlineStore.Common
;
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
namespace
TheMachine
{
internal
class
WindowManager
{
public
static
List
<
WindInfo
>
windInfos
=
new
List
<
WindInfo
>();
static
string
baseDir
=
@".\Modules\"
;
public
static
void
Start
()
{
foreach
(
var
item
in
windInfos
)
{
try
{
item
.
ProcessInfo
=
ProcessUtil
.
StartProcess
(
item
.
Name
,
baseDir
+
$
"{item.Name}\\"
,
60000
);
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
$
"程序{item.Name}启动失败"
,
ex
);
}
}
}
public
static
void
Show
()
{
foreach
(
var
item
in
windInfos
)
item
.
WindowHandle
=
WindowUtil
.
PutIntoForm
(
item
.
Parent
,
item
.
Name
);
}
}
class
WindInfo
{
public
string
Name
{
get
;
set
;
}
public
IntPtr
WindowHandle
{
get
;
set
;
}
public
Panel
Parent
{
get
;
set
;
}
public
Process
ProcessInfo
{
get
;
set
;
}
public
const
string
IPCamera
=
"IPCamera"
;
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论