• 大小: 44.34MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-09
  • 语言: C#
  • 标签: Unity3D与c#  

资源简介

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.embeddedApp\
     目录           0  2016-06-26 15:41  Unity3D与Winform嵌套\SmileWei.embeddedApp\.vs\
     目录           0  2016-06-26 15:41  Unity3D与Winform嵌套\SmileWei.embeddedApp\.vs\SmileWei.embeddedApp\
     目录           0  2016-06-26 15:41  Unity3D与Winform嵌套\SmileWei.embeddedApp\.vs\SmileWei.embeddedApp\v14\
     文件       95232  2016-07-04 11:39  Unity3D与Winform嵌套\SmileWei.embeddedApp\.vs\SmileWei.embeddedApp\v14\.suo
     目录           0  2016-06-26 15:41  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp\
     文件        2644  2012-05-23 20:17  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.sln
     文件       53760  2012-05-24 20:07  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.suo
     文件       78848  2015-02-01 21:14  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.v12.suo
     目录           0  2016-06-28 13:59  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.WinForm\
     文件        9662  2012-05-09 15:10  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.WinForm\appIcon.ico
     目录           0  2016-06-26 15:41  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.WinForm\bin\
     目录           0  2016-06-26 15:41  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.WinForm\bin\Debug\
     文件         310  2012-05-09 14:50  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.WinForm\bin\Debug\AppContainer.bmp
     文件           0  2012-05-23 22:17  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.WinForm\bin\Debug\lspost.cfile
     文件           0  2012-05-23 22:17  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.WinForm\bin\Debug\lspost.msg
     文件           0  2012-05-09 19:31  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.WinForm\bin\Debug\lspp_output.txt
     文件       11264  2016-06-27 11:40  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.WinForm\bin\Debug\SmileWei.embeddedApp.dll
     文件       22016  2016-06-27 11:40  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.WinForm\bin\Debug\SmileWei.embeddedApp.pdb
     文件       43520  2016-06-27 13:16  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.WinForm\bin\Debug\SmileWei.embeddedApp.WinForm.exe
     文件       28160  2016-06-27 13:16  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.WinForm\bin\Debug\SmileWei.embeddedApp.WinForm.pdb
     文件       22696  2016-07-04 11:34  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.WinForm\bin\Debug\SmileWei.embeddedApp.WinForm.vshost.exe
     文件         490  2015-06-04 12:48  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.WinForm\bin\Debug\SmileWei.embeddedApp.WinForm.vshost.exe.manifest
     目录           0  2012-08-15 00:58  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.WinForm\bin\Release\
     文件         734  2016-06-27 13:01  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.WinForm\FormHandle.cs
     文件        3891  2016-06-27 13:01  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.WinForm\FormHandle.Designer.cs
     文件       20617  2016-06-27 13:01  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.WinForm\FormHandle.resx
     文件        2199  2016-06-28 13:59  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.WinForm\FormMain.cs
     文件        7368  2016-06-28 13:59  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.WinForm\FormMain.Designer.cs
     文件       21365  2016-06-28 13:59  Unity3D与Winform嵌套\SmileWei.embeddedApp\SmileWei.embeddedApp.WinForm\FormMain.resx
............此处省略192个文件信息

评论

共有 条评论

相关资源