资源简介
Unity3D与c# Winform交互,包含Unity3D Web与Winform交互跟 Winform与Unity3D exe之间的交互
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Drawing.Design;
using System.Windows.Forms;
using System.IO;
using System.Drawing;
namespace SmileWei.embeddedApp
{
///
/// 可以把其他窗体应用程序嵌入此容器
///
[ToolboxBitmap(typeof(AppContainer) “AppControl.bmp“)]
public partial class AppContainer : System.Windows.Forms.Panel
{
Actionject EventArgs> appIdleAction = null;
EventHandler appIdleEvent = null;
public AppContainer()
{
InitializeComponent();
appIdleAction = new Actionject EventArgs>(Application_Idle);
appIdleEvent = new EventHandler(appIdleAction);
}
public AppContainer(IContainer container)
{
container.Add(this);
InitializeComponent();
appIdleAction = new Actionject EventArgs>(Application_Idle);
appIdleEvent = new EventHandler(appIdleAction);
}
///
/// 将属性AppFilename
指向的应用程序打开并嵌入此容器
///
public void Start()
{
if (m_AppProcess != null)
{
Stop();
}
try
{
ProcessStartInfo info = new ProcessStartInfo(this.m_AppFilename);
info.UseShellExecute = true;
info.Windowstyle = ProcessWindowstyle.Minimized;
//info.Windowstyle = ProcessWindowstyle.Hidden;
m_AppProcess = System.Diagnostics.Process.Start(info);
// Wait for process to be created and enter idle condition
m_AppProcess.WaitForInputIdle();
//todo:下面这两句会引发 NullReferenceException 异常,不知道怎么回事
//m_AppProcess.Exited += new EventHandler(m_AppProcess_Exited);
//m_AppProcess.EnableRaisingEvents = true;
Application.Idle += appIdleEvent;
}
catch (Exception ex)
{
MessageBox.Show(this string.Format(“{1}{0}{2}{0}{3}“
Environment.NewLine
“*“ + ex.ToString()
“*StackTrace:“ + ex.StackTrace
“*Source:“+ex.Source
) “内嵌程序加载失败“);
if (m_AppProcess != null)
{
if (!m_AppProcess.HasExited)
m_AppProcess.Kill();
m_AppProcess = null;
}
}
}
///
/// 确保应用程序嵌入此容器
///
///
///
void Application_Idle(object sender EventArgs e)
{
if (this.m_App
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-07-12 21:40 Unity3D与Winform嵌套\
目录 0 2016-06-26 15:41 Unity3D与Winform嵌套\SmileWei.em
目录 0 2016-06-26 15:41 Unity3D与Winform嵌套\SmileWei.em
目录 0 2016-06-26 15:41 Unity3D与Winform嵌套\SmileWei.em
目录 0 2016-06-26 15:41 Unity3D与Winform嵌套\SmileWei.em
文件 95232 2016-07-04 11:39 Unity3D与Winform嵌套\SmileWei.em
目录 0 2016-06-26 15:41 Unity3D与Winform嵌套\SmileWei.em
文件 2644 2012-05-23 20:17 Unity3D与Winform嵌套\SmileWei.em
文件 53760 2012-05-24 20:07 Unity3D与Winform嵌套\SmileWei.em
文件 78848 2015-02-01 21:14 Unity3D与Winform嵌套\SmileWei.em
目录 0 2016-06-28 13:59 Unity3D与Winform嵌套\SmileWei.em
文件 9662 2012-05-09 15:10 Unity3D与Winform嵌套\SmileWei.em
目录 0 2016-06-26 15:41 Unity3D与Winform嵌套\SmileWei.em
目录 0 2016-06-26 15:41 Unity3D与Winform嵌套\SmileWei.em
文件 310 2012-05-09 14:50 Unity3D与Winform嵌套\SmileWei.em
文件 0 2012-05-23 22:17 Unity3D与Winform嵌套\SmileWei.em
文件 0 2012-05-23 22:17 Unity3D与Winform嵌套\SmileWei.em
文件 0 2012-05-09 19:31 Unity3D与Winform嵌套\SmileWei.em
文件 11264 2016-06-27 11:40 Unity3D与Winform嵌套\SmileWei.em
文件 22016 2016-06-27 11:40 Unity3D与Winform嵌套\SmileWei.em
文件 43520 2016-06-27 13:16 Unity3D与Winform嵌套\SmileWei.em
文件 28160 2016-06-27 13:16 Unity3D与Winform嵌套\SmileWei.em
文件 22696 2016-07-04 11:34 Unity3D与Winform嵌套\SmileWei.em
文件 490 2015-06-04 12:48 Unity3D与Winform嵌套\SmileWei.em
目录 0 2012-08-15 00:58 Unity3D与Winform嵌套\SmileWei.em
文件 734 2016-06-27 13:01 Unity3D与Winform嵌套\SmileWei.em
文件 3891 2016-06-27 13:01 Unity3D与Winform嵌套\SmileWei.em
文件 20617 2016-06-27 13:01 Unity3D与Winform嵌套\SmileWei.em
文件 2199 2016-06-28 13:59 Unity3D与Winform嵌套\SmileWei.em
文件 7368 2016-06-28 13:59 Unity3D与Winform嵌套\SmileWei.em
文件 21365 2016-06-28 13:59 Unity3D与Winform嵌套\SmileWei.em
............此处省略192个文件信息
- 上一篇:C#基础知识思维导图最终版
- 下一篇:C#版微信登录--亲测有效.zip
评论
共有 条评论