private void earthWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (GeApp != null) { NativeMethods.PostMessage((IntPtr)GeApp.GetMainHwnd(), WM_QUIT, 0, 0); } Process[] localByNameApp = Process.GetProcessesByName("googleearth"); foreach (Process process in localByNameApp) { if (!process.HasExited) { process.Kill(); } } }
//private void image_ManipulationStarting(object sender, ManipulationStartingEventArgs e) //{ // e.ManipulationContainer = touchPad; // e.Mode = ManipulationModes.All; //} //private void image_ManipulationDelta(object sender, ManipulationDeltaEventArgs e) //{ // FrameworkElement element = (FrameworkElement)e.Source; // element.Opacity = 0.5; // Matrix matrix = ((MatrixTransform)element.RenderTransform).Matrix; // var deltaManipulation = e.DeltaManipulation; // Point center = new Point(element.ActualWidth / 2, element.ActualHeight / 2); // center = matrix.Transform(center); // matrix.ScaleAt(deltaManipulation.Scale.X, deltaManipulation.Scale.Y, center.X, center.Y); // matrix.RotateAt(e.DeltaManipulation.Rotation, center.X, center.Y); // matrix.Translate(e.DeltaManipulation.Translation.X, e.DeltaManipulation.Translation.Y); // ((MatrixTransform)element.RenderTransform).Matrix = matrix; //} ////private void image_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e) ////{ //// FrameworkElement element = (FrameworkElement)e.Source; //// element.Opacity = 1; ////} ///// <summary> ///// 按钮手势开始 ///// </summary> ///// <param name="sender"></param> ///// <param name="e"></param> ////private void button_ManipulationStarting(object sender, ManipulationStartingEventArgs e) ////{ //// e.ManipulationContainer = touchPad; //// e.Mode = ManipulationModes.Scale; ////} /// <summary> /// 按钮手势操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> //private void button_ManipulationDelta(object sender, ManipulationDeltaEventArgs e) //{ // FrameworkElement element = (FrameworkElement)e.Source; // element.Opacity = 0.5; // Matrix matrix = ((MatrixTransform)element.RenderTransform).Matrix; // var deltaManipulation = e.DeltaManipulation; // Point center = new Point(element.ActualWidth / 2, element.ActualHeight / 2); // center = matrix.Transform(center); // matrix.ScaleAt(deltaManipulation.Scale.X, deltaManipulation.Scale.Y, center.X, center.Y); // //matrix.RotateAt(e.DeltaManipulation.Rotation, center.X, center.Y); // //matrix.Translate(e.DeltaManipulation.Translation.X, e.DeltaManipulation.Translation.Y); // // ((MatrixTransform)element.RenderTransform).Matrix = matrix; // Console.WriteLine("scrae" + deltaManipulation.Scale.X + "-" + deltaManipulation.Scale.Y); //} /// <summary> /// 按钮手势操作结束 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> //private void button_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e) //{ // FrameworkElement element = (FrameworkElement)e.Source; // element.Opacity = 1; //} /// <summary> /// 图片上面 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> //private void Image_TouchMove(object sender, TouchEventArgs e) //{ // FrameworkElement element = (FrameworkElement)e.Source; // Matrix matrix = ((MatrixTransform)element.RenderTransform).Matrix; // TouchPoint touchPoint = e.GetTouchPoint(touchPad); // Point center = new Point(element.ActualWidth / 2, element.ActualHeight / 2); // center = matrix.Transform(center); // //matrix.ScaleAt(deltaManipulation.Scale.X, deltaManipulation.Scale.Y, center.X, center.Y); // Console.WriteLine("touchpoint.Bounds.Left" + touchPoint.Bounds.Left); //} #region GE地图 /// <summary> /// 加载GE地图 /// </summary> /// <summary> /// 加载Google Earth /// </summary> private void LoadGE() { if (isGeStarted) { return; } try { GeApp = (ApplicationGEClass)Activator.CreateInstance(Type.GetTypeFromProgID("GoogleEarth.Application")); isGeStarted = true; } catch { GeApp = new ApplicationGEClass(); // 30%; ///progress.WorkDown = 30; isGeStarted = true; } GEHWnd = (IntPtr)GeApp.GetMainHwnd(); //隐藏主窗口 //NativeMethods.SetWindowPos(GEHWnd, NativeMethods.HWND_BOTTOM, 0, 0, 0, 0, NativeMethods.SWP_HIDEWINDOW); NativeMethods.ShowWindowAsync((int)GEHWnd, 0); // 40%; //progress.WorkDown = 40; _GEHrender = (IntPtr)GeApp.GetRenderHwnd(); _GEParentHrender = (IntPtr)NativeMethods.GetParent(_GEHrender); NativeMethods.SetParent(_GEHrender, this.Control.Handle); // 50%; //progress.WorkDown = 50; ResizeGoogleControl(); }
/// <summary> /// 加载GE地图 /// </summary> /// <summary> /// 加载Google Earth /// </summary> private void LoadGE() { if (isGeStarted) { return; } try { GeApp = (ApplicationGEClass)Activator.CreateInstance(Type.GetTypeFromProgID("GoogleEarth.Application")); isGeStarted = true; } catch { GeApp = new ApplicationGEClass(); // 30%; ///progress.WorkDown = 30; isGeStarted = true; } GEHWnd = (IntPtr)GeApp.GetMainHwnd(); //隐藏主窗口 //NativeMethods.SetWindowPos(GEHWnd, NativeMethods.HWND_BOTTOM, 0, 0, 0, 0, NativeMethods.SWP_HIDEWINDOW); NativeMethods.ShowWindowAsync((int)GEHWnd, 0); // 40%; //progress.WorkDown = 40; _GEHrender = (IntPtr)GeApp.GetRenderHwnd(); _GEParentHrender = (IntPtr)NativeMethods.GetParent(_GEHrender); NativeMethods.SetParent(_GEHrender, this.Control.Handle); // 50%; //progress.WorkDown = 50; ResizeGoogleControl(); }