예제 #1
0
        public void ReplaceMap(IMap newMap)
        {
            if (newMap == null)
                throw new Exception("ControlsSynchronizer::ReplaceMap\r\n��Mapû�г�ʼ��!");
            if (m_pageLayoutControl == null || m_mapControl == null)
                throw new Exception("ControlsSynchronizer::ReplaceMap:\r\nMapControl��PageLayoutControlû�г�ʼ��!");

            //����һ����ͼ����IMaps����
            IMaps maps = new Maps();
            //����Map��ӵ�Maps����
            maps.Add(newMap);

            bool bIsMapActive = m_IsMapCtrlactive;

            //ʹPageLayoutControl���ڼ���״̬���ܵ���ReplaceMaps����
            this.ActivatePageLayout();
            m_pageLayoutControl.PageLayout.ReplaceMaps(maps);

            //��Map���ݸ�MapControl
            m_mapControl.Map = newMap;

            //��֤һ����ؼ����ڼ���״̬
            if (bIsMapActive)
            {
                this.ActivateMap();
                m_mapControl.ActiveView.Refresh();
            }
            else
            {
                this.ActivatePageLayout();
                m_pageLayoutControl.ActiveView.Refresh();
            }
        }
예제 #2
0
        /// <summary>
        /// ��MapControl��PageLayoutControlͨ��ͬһ������Map���а�
        /// </summary>
        /// <param name="activateMapFirst">���MapControl��ΪĬ�ϻ�ؼ�����ΪTrue</param>
        public void BindControls(bool activateMapFirst)
        {
            if (m_pageLayoutControl == null || m_mapControl == null)
                throw new Exception("ControlsSynchronizer::BindControls:\r\nMapControl��PageLayoutControlû�г�ʼ��!");

            if (m_mapControl.Map.LayerCount == 0)
            {
                //����һ��Map����
                IMap newMap = new MapClass();
                newMap.Name = "��ͼ";
                //����һ����ͼ����IMaps����
                IMaps maps = new Maps();

                maps.Add(newMap);

                m_pageLayoutControl.PageLayout.ReplaceMaps(maps);
                m_mapControl.Map = newMap;

                if (activateMapFirst)
                    this.ActivateMap();
                else
                    this.ActivatePageLayout();
            }
            else
            {
                //����һ��Map����
                IMap newMap = new MapClass();
                newMap.Name = "��ͼ";

                for (int i = 0; i < m_mapControl.Map.LayerCount; i++)
                {
                    newMap.AddLayer(m_mapControl.Map.get_Layer(i));
                }
                //m_mapControl.Map = null;
                //����һ����ͼ����IMaps����
                IMaps maps = new Maps();

                maps.Add(newMap);

                m_pageLayoutControl.PageLayout.ReplaceMaps(maps);
                m_mapControl.Map = newMap;

                if (activateMapFirst)
                    this.ActivateMap();
                else
                    this.ActivatePageLayout();
            }
        }