Exemple #1
0
        /// <summary>Move the GoogleEarth's map control to the specified control
        /// Move the GoogleEarth's map control to the specified control
        /// </summary>
        /// <param name="parentControl">The specified control that GoogleEarth's map control will be moved to.</param>
        /// <param name="geApplication">The application which will be moved to the specified control. </param>
        public void SetGEHandlerToControl(System.Windows.Forms.Control parentControl, IApplicationGE geApplication)
        {
            this._parentControl = parentControl;
            this._googleEarth   = geApplication;

            //Get the Handler of the application's MainForm to SetGEHandler._GEMainHandler.
            this._GEMainHandler = (IntPtr)this._googleEarth.GetMainHwnd();

            //Set the Hight of GoogleEarth's MainForm to 0, and hide the Height of GoogleEarth's MainForm.
            GetGEControl.SetWindowPos(this._GEMainHandler, GetGEControl.HWND_BOTTOM, 0, 0, 0, 0, GetGEControl.SWP_NOSIZE + GetGEControl.SWP_HIDEWINDOW);

            // Get the Handler of the application's map control.
            this._GEHandler = (IntPtr)_googleEarth.GetRenderHwnd();

            //Get the Handler of GoogleEarth's parentForm from GoogleEarth's map control.
            this._GEParentHandler = GetGEControl.GetParent(this._GEHandler);

            //将GE地图控件的父窗体设置为不可见
            //Hide the parentForm of GoogleEarth.
            GetGEControl.PostMessage((int)this._GEParentHandler, GetGEControl.WM_HIDE, 0, 0);

            //Set the Handler of GoogleEarth's parentForm to winform's control.
            GetGEControl.SetParent(this._GEHandler, parentControl.Handle);

            //
            ResizeGEControl();
        }
        /// <summary>Move the GoogleEarth's map control to the specified control
        /// Move the GoogleEarth's map control to the specified control
        /// </summary>
        /// <param name="parentControl">The specified control that GoogleEarth's map control will be moved to.</param>
        /// <param name="geApplication">The application which will be moved to the specified control. </param>
        public void SetGEHandlerToControl(System.Windows.Forms.Control parentControl, IApplicationGE geApplication)
        {
            this._parentControl = parentControl;
            this._googleEarth = geApplication;

            //Get the Handler of the application's MainForm to SetGEHandler._GEMainHandler.
            this._GEMainHandler = (IntPtr)this._googleEarth.GetMainHwnd();

            //Set the Hight of GoogleEarth's MainForm to 0, and hide the Height of GoogleEarth's MainForm.
            GetGEControl.SetWindowPos(this._GEMainHandler, GetGEControl.HWND_BOTTOM, 0, 0, 0, 0, GetGEControl.SWP_NOSIZE + GetGEControl.SWP_HIDEWINDOW);

            // Get the Handler of the application's map control.
            this._GEHandler = (IntPtr)_googleEarth.GetRenderHwnd();

            //Get the Handler of GoogleEarth's parentForm from GoogleEarth's map control.
            this._GEParentHandler = GetGEControl.GetParent(this._GEHandler);

            //将GE地图控件的父窗体设置为不可见
            //Hide the parentForm of GoogleEarth.
            GetGEControl.PostMessage((int)this._GEParentHandler, GetGEControl.WM_HIDE, 0, 0);

            //Set the Handler of GoogleEarth's parentForm to winform's control.
            GetGEControl.SetParent(this._GEHandler, parentControl.Handle);

            //
            ResizeGEControl();
        }
Exemple #3
0
        //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();
        }