Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
1069_MIMO_PlUS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit a10b0e99
由
张东亮
编写于
2024-01-16 09:09:04 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
监控软件进程显示问题
1 个父辈
fb278a4d
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
95 行增加
和
65 行删除
Common/Common.csproj
Common/util/ProcessUtil.cs
DeviceLibrary/DeviceLibrary.csproj
Common/util/WindowUtil.cs → DeviceLibrary/WindowManager.cs
TheMachine/TheMachine.csproj
TheMachine/WindowManager.cs
Common/Common.csproj
查看文件 @
a10b0e9
...
@@ -77,7 +77,6 @@
...
@@ -77,7 +77,6 @@
<Compile Include="util\SMF.cs" />
<Compile Include="util\SMF.cs" />
<Compile Include="util\TcpServer.cs" />
<Compile Include="util\TcpServer.cs" />
<Compile Include="util\UdpServer.cs" />
<Compile Include="util\UdpServer.cs" />
<Compile Include="util\WindowUtil.cs" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
<WCFMetadata Include="Service References\" />
...
...
Common/util/ProcessUtil.cs
查看文件 @
a10b0e9
...
@@ -38,13 +38,13 @@ namespace Common
...
@@ -38,13 +38,13 @@ namespace Common
MessageBox
.
Show
(
ex
.
ToString
());
MessageBox
.
Show
(
ex
.
ToString
());
}
}
}
}
public
static
Process
StartProcess
(
string
appName
,
string
baseDir
=
@".\"
,
int
waitIdle
=
5000
)
public
static
Process
StartProcess
(
string
appName
,
string
baseDir
=
@".\"
,
int
waitIdle
=
5000
)
{
{
try
try
{
{
Process
process
=
new
Process
();
Process
process
=
new
Process
();
process
.
StartInfo
=
new
System
.
Diagnostics
.
ProcessStartInfo
();
process
.
StartInfo
=
new
System
.
Diagnostics
.
ProcessStartInfo
();
process
.
StartInfo
.
FileName
=
appName
+
".exe"
;
process
.
StartInfo
.
FileName
=
appName
+
".exe"
;
process
.
StartInfo
.
WorkingDirectory
=
baseDir
;
process
.
StartInfo
.
WorkingDirectory
=
baseDir
;
process
.
Start
();
process
.
Start
();
process
.
WaitForInputIdle
(
waitIdle
);
process
.
WaitForInputIdle
(
waitIdle
);
...
@@ -78,6 +78,26 @@ namespace Common
...
@@ -78,6 +78,26 @@ namespace Common
return
processRun
;
return
processRun
;
}
}
public
static
bool
IsRun
(
string
process
)
{
bool
processRun
=
false
;
try
{
System
.
Diagnostics
.
Process
[]
processList
=
System
.
Diagnostics
.
Process
.
GetProcesses
();
foreach
(
System
.
Diagnostics
.
Process
process2
in
processList
)
{
if
(
process2
.
ProcessName
==
process
)
{
processRun
=
true
;
}
}
}
catch
{
}
return
processRun
;
}
public
static
bool
CloseProcess
(
Process
process
)
public
static
bool
CloseProcess
(
Process
process
)
{
{
bool
sc
=
false
;
bool
sc
=
false
;
...
@@ -97,5 +117,23 @@ namespace Common
...
@@ -97,5 +117,23 @@ namespace Common
catch
{
sc
=
true
;
}
catch
{
sc
=
true
;
}
return
sc
;
return
sc
;
}
}
public
static
bool
CloseProcess
(
string
process
)
{
bool
sc
=
false
;
try
{
System
.
Diagnostics
.
Process
[]
processList
=
System
.
Diagnostics
.
Process
.
GetProcesses
();
foreach
(
System
.
Diagnostics
.
Process
process2
in
processList
)
{
if
(
process2
.
ProcessName
==
process
)
{
process2
.
Kill
();
sc
=
process2
.
WaitForExit
(
100000
);
}
}
}
catch
{
sc
=
true
;
}
return
sc
;
}
}
}
}
}
DeviceLibrary/DeviceLibrary.csproj
查看文件 @
a10b0e9
...
@@ -132,6 +132,7 @@
...
@@ -132,6 +132,7 @@
<Compile Include="userControl\ToucDownBtn.cs">
<Compile Include="userControl\ToucDownBtn.cs">
<SubType>Component</SubType>
<SubType>Component</SubType>
</Compile>
</Compile>
<Compile Include="WindowManager.cs" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<EmbeddedResource Include="userControl\AxisMoveControl.resx">
<EmbeddedResource Include="userControl\AxisMoveControl.resx">
...
...
Common/util/WindowUtil
.cs
→
DeviceLibrary/WindowManager
.cs
查看文件 @
a10b0e9
using
log4net.Util
;
using
Common
;
using
OnlineStore.Common
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Linq
;
using
System.Runtime.InteropServices
;
using
System.Runtime.InteropServices
;
using
System.Text
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
using
System.Windows.Forms
;
using
System.Xml.Linq
;
namespace
Common
namespace
TheMachine
{
{
public
class
WindowManager
{
public
static
List
<
WindInfo
>
windInfos
=
new
List
<
WindInfo
>();
static
string
baseDir
=
Application
.
StartupPath
+
@"\Modules\"
;
public
static
void
Start
()
{
foreach
(
var
item
in
windInfos
)
{
try
{
if
(
ProcessUtil
.
IsRun
(
item
.
Name
))
{
ProcessUtil
.
CloseProcess
(
item
.
Name
);
Thread
.
Sleep
(
2000
);
}
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
);
}
public
static
void
Hide
()
{
foreach
(
var
item
in
windInfos
)
{
if
(
item
.
WindowHandle
!=
IntPtr
.
Zero
)
{
item
.
WindowHandle
=
IntPtr
.
Zero
;
WindowUtil
.
RemoveFromForm
(
item
.
Name
);
}
}
}
}
public
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"
;
}
public
class
WindowUtil
public
class
WindowUtil
{
{
public
const
int
WM_CLOSE
=
0x0010
;
public
const
int
WM_CLOSE
=
0x0010
;
...
...
TheMachine/TheMachine.csproj
查看文件 @
a10b0e9
...
@@ -166,7 +166,6 @@
...
@@ -166,7 +166,6 @@
<Compile Include="UC\UC_SetUserPassword.designer.cs">
<Compile Include="UC\UC_SetUserPassword.designer.cs">
<DependentUpon>UC_SetUserPassword.cs</DependentUpon>
<DependentUpon>UC_SetUserPassword.cs</DependentUpon>
</Compile>
</Compile>
<Compile Include="WindowManager.cs" />
<EmbeddedResource Include="AboutBox1.resx">
<EmbeddedResource Include="AboutBox1.resx">
<DependentUpon>AboutBox1.cs</DependentUpon>
<DependentUpon>AboutBox1.cs</DependentUpon>
</EmbeddedResource>
</EmbeddedResource>
...
...
TheMachine/WindowManager.cs
deleted
100644 → 0
查看文件 @
fb278a4
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
=
Application
.
StartupPath
+
@"\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
);
}
public
static
void
Hide
()
{
foreach
(
var
item
in
windInfos
)
{
if
(
item
.
WindowHandle
!=
IntPtr
.
Zero
)
{
item
.
WindowHandle
=
IntPtr
.
Zero
;
WindowUtil
.
RemoveFromForm
(
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
请
注册
或
登录
后发表评论