Commit 225269da 张东亮

监控相机单独进程嵌入程序

1 个父辈 dcc082d6
...@@ -73,9 +73,11 @@ ...@@ -73,9 +73,11 @@
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="util\CTcpClient.cs" /> <Compile Include="util\CTcpClient.cs" />
<Compile Include="util\ProcessUtil.cs" />
<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\" />
......
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;
}
}
}
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;
}
}
...@@ -73,36 +73,36 @@ public class HIKCamera ...@@ -73,36 +73,36 @@ public class HIKCamera
bool camerathreadrun = true; bool camerathreadrun = true;
public void startCamera() public void startCamera()
{ {
if(!VideoManager.IsRecording(Name)) //if(!VideoManager.IsRecording(Name))
{ //{
VideoManager.StartRecord(Name, "Auto2"); // VideoManager.StartRecord(Name, "Auto2");
} //}
} }
public void stopCamera() public void stopCamera()
{ {
VideoManager.StopRecord(Name); //VideoManager.StopRecord(Name);
VideoManager.Close(); //VideoManager.Close();
camerathreadrun = false; camerathreadrun = false;
} }
public void CameraGrabOne(string filename) public void CameraGrabOne(string filename)
{ {
try //try
{ //{
LogUtil.info(Name + "库位文件名:" + filename); // LogUtil.info(Name + "库位文件名:" + filename);
VideoManager.GrabOneImg(Name, out Bitmap bmp); // VideoManager.GrabOneImg(Name, out Bitmap bmp);
if (bmp != null) // if (bmp != null)
{ // {
if (File.Exists(filename)) // if (File.Exists(filename))
File.Delete(filename); // File.Delete(filename);
bmp.Save(filename, ImageFormat.Jpeg); // bmp.Save(filename, ImageFormat.Jpeg);
bmp.Dispose(); // bmp.Dispose();
} // }
} //}
catch (Exception e) //catch (Exception e)
{ //{
LogUtil.error(Name + e.ToString()); // LogUtil.error(Name + e.ToString());
} //}
} }
public string GetFixtureStateFilename(string PositionNum, string WareNumber, StoreMoveType storeMoveType, FixtureState fixtureState) public string GetFixtureStateFilename(string PositionNum, string WareNumber, StoreMoveType storeMoveType, FixtureState fixtureState)
{ {
......
...@@ -80,11 +80,11 @@ namespace DeviceLibrary ...@@ -80,11 +80,11 @@ namespace DeviceLibrary
msg += crc.GetString(L.iocard_init_fail, "IO板卡初始化失败")+ "\n"; msg += crc.GetString(L.iocard_init_fail, "IO板卡初始化失败")+ "\n";
} }
// IOManager.CloseAllConnection(); // IOManager.CloseAllConnection();
if (!CameraA.LoadCameraConfig(out string errmsg, param[0])) //if (!CameraA.LoadCameraConfig(out string errmsg, param[0]))
{ //{
IsLoadOk = false; // IsLoadOk = false;
msg += errmsg + "\r\n"; // msg += errmsg + "\r\n";
} //}
if (!HumitureController.Init(ConfigHelper.Config.Get("Device_Humiture_Port"))) { if (!HumitureController.Init(ConfigHelper.Config.Get("Device_Humiture_Port"))) {
IsLoadOk = false; IsLoadOk = false;
msg += crc.GetString(L.tempnhum_sensor_init_fail, $"温湿度传感器初始化失败,端口:")+ $"{ConfigHelper.Config.Get("Device_Humiture_Port")}\n"; msg += crc.GetString(L.tempnhum_sensor_init_fail, $"温湿度传感器初始化失败,端口:")+ $"{ConfigHelper.Config.Get("Device_Humiture_Port")}\n";
......
...@@ -51,20 +51,19 @@ namespace TheMachine ...@@ -51,20 +51,19 @@ namespace TheMachine
this.cb_IgnoreSafecheck = new System.Windows.Forms.CheckBox(); this.cb_IgnoreSafecheck = new System.Windows.Forms.CheckBox();
this.pictureBox2 = new System.Windows.Forms.PictureBox(); this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.cb_IgnoreGratingSignal = new System.Windows.Forms.CheckBox(); this.cb_IgnoreGratingSignal = new System.Windows.Forms.CheckBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.cb_EnableBuzzer = new System.Windows.Forms.CheckBox(); this.cb_EnableBuzzer = new System.Windows.Forms.CheckBox();
this.btn_IgnoreX09 = new System.Windows.Forms.Button(); this.btn_IgnoreX09 = new System.Windows.Forms.Button();
this.btn_PauseBuzzer = new System.Windows.Forms.Button(); this.btn_PauseBuzzer = new System.Windows.Forms.Button();
this.listView1 = new System.Windows.Forms.ListView(); this.listView1 = new System.Windows.Forms.ListView();
this.btn_stop = new System.Windows.Forms.Button(); this.btn_stop = new System.Windows.Forms.Button();
this.btn_run = new System.Windows.Forms.Button(); this.btn_run = new System.Windows.Forms.Button();
this.panelVideo = new System.Windows.Forms.Panel();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
this.tabc.SuspendLayout(); this.tabc.SuspendLayout();
this.tabP1.SuspendLayout(); this.tabP1.SuspendLayout();
this.pnl.SuspendLayout(); this.pnl.SuspendLayout();
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// menuStrip1 // menuStrip1
...@@ -196,12 +195,12 @@ namespace TheMachine ...@@ -196,12 +195,12 @@ namespace TheMachine
// //
// pnl // pnl
// //
this.pnl.Controls.Add(this.panelVideo);
this.pnl.Controls.Add(this.groupBox1); this.pnl.Controls.Add(this.groupBox1);
this.pnl.Controls.Add(this.btn_releasestring); this.pnl.Controls.Add(this.btn_releasestring);
this.pnl.Controls.Add(this.cb_IgnoreSafecheck); this.pnl.Controls.Add(this.cb_IgnoreSafecheck);
this.pnl.Controls.Add(this.pictureBox2); this.pnl.Controls.Add(this.pictureBox2);
this.pnl.Controls.Add(this.cb_IgnoreGratingSignal); 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.cb_EnableBuzzer);
this.pnl.Controls.Add(this.btn_IgnoreX09); this.pnl.Controls.Add(this.btn_IgnoreX09);
this.pnl.Controls.Add(this.btn_PauseBuzzer); this.pnl.Controls.Add(this.btn_PauseBuzzer);
...@@ -282,19 +281,6 @@ namespace TheMachine ...@@ -282,19 +281,6 @@ namespace TheMachine
this.cb_IgnoreGratingSignal.Visible = false; this.cb_IgnoreGratingSignal.Visible = false;
this.cb_IgnoreGratingSignal.CheckedChanged += new System.EventHandler(this.cb_IgnoreGratingSignal_CheckedChanged); 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 // cb_EnableBuzzer
// //
this.cb_EnableBuzzer.AutoSize = true; this.cb_EnableBuzzer.AutoSize = true;
...@@ -369,6 +355,13 @@ namespace TheMachine ...@@ -369,6 +355,13 @@ namespace TheMachine
this.btn_run.UseVisualStyleBackColor = true; this.btn_run.UseVisualStyleBackColor = true;
this.btn_run.Click += new System.EventHandler(this.btn_run_Click); 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 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 17F); this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 17F);
...@@ -396,7 +389,6 @@ namespace TheMachine ...@@ -396,7 +389,6 @@ namespace TheMachine
this.pnl.PerformLayout(); this.pnl.PerformLayout();
this.groupBox1.ResumeLayout(false); this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
...@@ -424,7 +416,6 @@ namespace TheMachine ...@@ -424,7 +416,6 @@ namespace TheMachine
private System.Windows.Forms.CheckBox cb_EnableBuzzer; private System.Windows.Forms.CheckBox cb_EnableBuzzer;
private System.Windows.Forms.Button btn_PauseBuzzer; private System.Windows.Forms.Button btn_PauseBuzzer;
private System.Windows.Forms.PictureBox pictureBox2; 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_IgnoreX09;
private System.Windows.Forms.Button btn_releasestring; private System.Windows.Forms.Button btn_releasestring;
private System.Windows.Forms.Panel pnl; private System.Windows.Forms.Panel pnl;
...@@ -432,6 +423,7 @@ namespace TheMachine ...@@ -432,6 +423,7 @@ namespace TheMachine
private System.Windows.Forms.ToolStripMenuItem 简体中文ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 简体中文ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem 日本语ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 日本语ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem englishToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem englishToolStripMenuItem;
private System.Windows.Forms.Panel panelVideo;
} }
} }
using CodeLibrary; using CodeLibrary;
using Common;
using ConfigHelper; using ConfigHelper;
using DeviceLibrary; using DeviceLibrary;
using OnlineStore; using OnlineStore;
...@@ -129,12 +130,11 @@ namespace TheMachine ...@@ -129,12 +130,11 @@ namespace TheMachine
RobotManage.UserPauseSet += RobotManage_UserPauseSet; RobotManage.UserPauseSet += RobotManage_UserPauseSet;
RobotManage.CameraA.camera_event += CameraA_camera_event;
CodeManager.camera_event += CameraB_camera_event; CodeManager.camera_event += CameraB_camera_event;
IntPtr camAIntptr = pictureBox1.Handle; IntPtr camAIntptr = pictureBox2.Handle;
var loadtask = Task.Run(() => var loadtask = Task.Run(() =>
{ {
RobotManage.Init(camAIntptr); RobotManage.Init();
}); });
ListViewItem lvi = new ListViewItem(new string[] { "", DateTime.Now.ToString(), crc.GetString(L.device_initializing, "设备加载中,请稍后...") }); ListViewItem lvi = new ListViewItem(new string[] { "", DateTime.Now.ToString(), crc.GetString(L.device_initializing, "设备加载中,请稍后...") });
lvi.ForeColor = Color.DarkGreen; lvi.ForeColor = Color.DarkGreen;
...@@ -143,16 +143,9 @@ namespace TheMachine ...@@ -143,16 +143,9 @@ namespace TheMachine
// Thread.Sleep(100); // Thread.Sleep(100);
// Application.DoEvents(); // Application.DoEvents();
//} //}
LoadWindow();
pnl.Enabled = false; 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) private void CameraB_camera_event(object sender, Bitmap e)
{ {
this.Invoke((EventHandler<Bitmap>)delegate this.Invoke((EventHandler<Bitmap>)delegate
...@@ -322,6 +315,7 @@ namespace TheMachine ...@@ -322,6 +315,7 @@ namespace TheMachine
lm.Add(m); lm.Add(m);
} }
SetMsg(lm); SetMsg(lm);
WindowManager.Show();
} }
void SetMsg(List<Msg> msgs) void SetMsg(List<Msg> msgs)
{ {
...@@ -676,5 +670,34 @@ namespace TheMachine ...@@ -676,5 +670,34 @@ namespace TheMachine
Config.Set("Device_Default_Language", "en-US"); Config.Set("Device_Default_Language", "en-US");
crc.LanguageChange(); 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
} }
} }
...@@ -154,6 +154,7 @@ ...@@ -154,6 +154,7 @@
<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>
......
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!