Beispiel #1
0
        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();
        }
Beispiel #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);
        }
Beispiel #3
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");
     }
 }