Ejemplo n.º 1
0
        public void ActivatePageLayout()
        {
            try
            {
                if (m_mapControl == null || m_pageLayoutControl == null)
                {
                    throw new Exception("ControlsSynchronizer::ActivatePageLayout:/r/nMapControl or PageLayoutControl is not initialized");
                }

                if (m_mapControl.CurrentTool != null)
                {
                    m_mapActiveTool = m_mapControl.CurrentTool;
                }
                m_mapControl.ActiveView.Deactivate();


                m_pageLayoutControl.ActiveView.Activate(m_pageLayoutControl.hWnd);
                if (m_pageLayoutActiveTool != null)
                {
                    m_pageLayoutControl.CurrentTool = m_pageLayoutActiveTool;
                }


                m_IsMapControlActive = false;

                this.SetBuddies(m_pageLayoutControl.Object);
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("ControlsSynchronizer::ActivatePageLayout:/r/n", ex.Message));
            }
        }
Ejemplo n.º 2
0
        public void ActivateMapControl()
        {
            try
            {
                if (m_mapControl == null || m_pageLayoutControl == null)
                {
                    throw new Exception("ControlsSynchronizer::ActivateMap:/n/r MapControl or PageLayoutControl is not initialized");
                }

                //保存PageLayoutControl最后使用的工具并停用
                if (m_pageLayoutControl.CurrentTool != null)
                {
                    m_pageLayoutActiveTool = m_pageLayoutControl.CurrentTool;
                }
                m_pageLayoutControl.ActiveView.Deactivate();

                //激活MapControl并分配预先保留的工具
                m_mapControl.ActiveView.Activate(m_mapControl.hWnd);

                if (m_mapActiveTool != null)
                {
                    m_mapControl.CurrentTool = m_mapActiveTool;
                }

                //指示器
                m_IsMapControlActive = true;

                //设置MapControl的Buddies
                this.SetBuddies(m_mapControl.Object);
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("ControlsSynchronizer::ActivateMap:/r/n", ex.Message));
            }
        }
Ejemplo n.º 3
0
 public void OnCreate(NBGIS.PluginEngine.IApplication hook)
 {
     if (hook != null)
     {
         this.m_Application = hook;
         tool = new ESRI.ArcGIS.Controls.ControlsMapZoomInToolClass();
         cmd  = tool as ESRI.ArcGIS.SystemUI.ICommand;
         cmd.OnCreate(this.m_Application.MapControl);
     }
 }
Ejemplo n.º 4
0
        public void ReplaceMap(ESRI.ArcGIS.Carto.IMap newMap)
        {
            if (newMap == null)
            {
                throw new Exception("ControlsSynchronizer::ReplaceMap:/r/n New Map is not initialized");
            }

            if (m_mapControl == null || m_pageLayoutControl == null)
            {
                throw new Exception("ControlsSynchronzier::ReplaceMap:\r\n MapControl or PageLayoutControl is not initialized");
            }

            ESRI.ArcGIS.Carto.IMaps maps = new Maps();
            maps.Add(newMap);

            bool IsMapActive = m_IsMapControlActive;

            this.ActivatePageLayout();
            m_pageLayoutControl.PageLayout.ReplaceMaps(maps);

            m_mapControl.Map = newMap;

            m_mapActiveTool        = null;
            m_pageLayoutActiveTool = null;

            if (IsMapActive)
            {
                this.ActivateMapControl();
                m_mapControl.ActiveView.Refresh();
            }
            else
            {
                this.ActivatePageLayout();
                m_pageLayoutControl.ActiveView.Refresh();
            }
        }