コード例 #1
0
ファイル: Form1.cs プロジェクト: simonmoosbrugger/SmartChair
        public Form1()
        {
            foreach (Process p in Process.GetProcessesByName("googleearth"))
            {
                p.Kill();
            }

            InitializeComponent();

            ge = new EARTHLib.ApplicationGE();

            ShowWindowAsync(ge.GetMainHwnd(), 0);
            SetParent(ge.GetRenderHwnd(), this.Handle.ToInt32());

            Wiimote wm = new Wiimote();

            // setup the event to handle state changes
            wm.WiimoteChanged += wm_WiimoteChanged;

            // connect to the Wiimote
            wm.Connect();

            // set the report type to return the IR sensor and accelerometer data (buttons always come back)
            wm.SetReportType(InputReport.IRAccel, true);

            ResizeGoogleControl();
        }
コード例 #2
0
        //重写OnLoad比实现Form_Load更高效
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            //启动GoogleEarth实例
            GEApp = new ApplicationGE();

            GEHMainWnd = (IntPtr)GEApp.GetMainHwnd();
            //隐藏GoogleEarth主窗口
            NativeMethods.SetWindowPos(GEHMainWnd, NativeMethods.HWND_BOTTOM,
                                       0, 0, 0, 0,
                                       NativeMethods.SWP_NOSIZE | NativeMethods.SWP_HIDEWINDOW);

            GEHRenderWnd = (IntPtr)GEApp.GetRenderHwnd();
            //将渲染窗口嵌入到主窗体
            NativeMethods.MoveWindow(GEHRenderWnd, 2, 2, tabPage1.Width - 20, tabPage1.Height - 20, true);
            NativeMethods.SetParent(GEHRenderWnd, tabPage1.Handle);
        }
コード例 #3
0
        private void StartGE()
        {
            if (isGEStarted)
            {
                return;
            }

            try
            {
                //启动GE
                GEApp = (ApplicationGE)Marshal.GetActiveObject("GoogleEarth.ApplicationGE");

                isGEStarted = true;
            }
            catch (Exception e)
            {
                GEApp = new ApplicationGE();

                isGEStarted = true;
            }
        }
コード例 #4
0
 /// <summary>
 /// 功能:尝试关闭GE
 /// </summary>
 private void TryCloseGE()
 {
     try
     {
         //杀掉GoogleEarth进程
         Process[] geProcess = Process.GetProcessesByName("GoogleEarth");
         foreach (var p in geProcess)
         {
             p.Kill();
         }
         //清除内容
         GEApp        = null;
         GEHMainWnd   = (IntPtr)0;
         GEHRenderWnd = (IntPtr)0;
         isGEStarted  = false;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error Shutdown GE");
     }
 }
コード例 #5
0
 /// <summary>
 /// 功能:尝试启动Google Earth实例
 /// </summary>
 /// <param>
 /// 参数:parentDocker
 /// 含义:GE渲染窗口所停靠的父窗口
 /// </param>
 private void TryStartGE(Control parentDocker)
 {
     try
     {
         //创建GE新实例
         GEApp = new ApplicationGE();
         //取得GE主窗口句柄
         GEHMainWnd = (IntPtr)GEApp.GetMainHwnd();
         //隐藏GoogleEarth主窗口
         NativeMethods.SetWindowPos(GEHMainWnd, NativeMethods.HWND_BOTTOM,
                                    0, 0, 0, 0, NativeMethods.SWP_NOSIZE | NativeMethods.SWP_HIDEWINDOW);
         //取得GE的影像窗口(渲染窗口)句柄
         GEHRenderWnd = (IntPtr)GEApp.GetRenderHwnd();
         //调整视图窗口尺寸
         ResizeTabPage(tabGEViewer);
         //启动成功,设置标记
         isGEStarted = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error Starting GE");
     }
 }