예제 #1
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            AeUtils.SetMapControl(m_pMapC2);
            AeUtils.SetMapDocument(m_pMapDoc);
            AeUtils.SetAxPageLayoutControl(axPageLayoutControl_Main);

            m_pToolbarMenu.AddItem(new OpenAttributeTable());
            m_pToolbarMenu.SetHook(m_pMapC2);
        }
예제 #2
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            axTOCControl_main.SetBuddyControl(axMapControl_main);
            m_pMapC2  = axMapControl_main.Object as IMapControl2;
            m_pMapDoc = new MapDocumentClass();

            axMapControl_main.OnMouseDown += axMapControl_main_OnMouseDown;

            // 清空地图选择集
            btn_clearselect.Click += (object s, EventArgs ent) => {
                m_pMapC2.Map.ClearSelection();
                (m_pMapC2.Map as IGraphicsContainer).DeleteAllElements();
                m_pMapC2.Refresh();
                m_isIdentify = false;
                m_isDraw     = false;
                m_isAddpoint = false;
            };


            // a. 打开地图文档功能(地图文档位于AirQuality文件夹下)
            LoadMxd();

            // b. 退出程序并保存地图文档功能
            this.FormClosing += (object s, FormClosingEventArgs ent) => {
                m_pMapDoc.Save();
            };

            // c. 在地图上点击,选择一个监测站点,并显示该监测站点的属性信息 第①步
            btn_Identify.Click += Button_Click;
            // e. 在地图上选择一个多边形,统计该多边形内部的监测站点内数量,并高亮显示
            btn_select.Click += Button_Click;
            // f. 将Excel中的数据匹配到监测站点
            btn_link.Click += Button_Click;
            // g. 在地图上显示北京各个区县的名称
            btn_anno.Click += Button_Click;
            // h. 为北京各个区县匹配一个符号
            btn_symbol.Click += Button_Click;
            // i. 导出北京区县图层为一个新的数据
            btn_outlyr.Click += Button_Click;
            // j. 在监测站点图层添加一个新站点
            btn_addpt.Click += Button_Click;

            // d. 在监测站点列表中选择一个监测站点后,在地图上高亮显示,缩放至该监测站点,并显示该监测站点的属性信息 第①步
            setListBox();



            object[] cmds = new object[] {
                new OpenAttriTable()
            };
            m_pToolbarMenu = new ToolbarMenu();
            for (int i = 0; i < cmds.Length; i++)
            {
                m_pToolbarMenu.AddItem(cmds[i]);
            }
            m_pToolbarMenu.SetHook(m_pMapC2);
        }
예제 #3
0
 private void setTOCControl(params object[] cmds)
 {
     axTOCControl_main.SetBuddyControl(axMapControl_main);
     axTOCControl_main.EnableLayerDragDrop = true;
     m_ToolbarMenu = new ToolbarMenuClass();
     for (int i = 0; i < cmds.Length; i++)
     {
         m_ToolbarMenu.AddItem(cmds[i]);
     }
     m_ToolbarMenu.SetHook(m_pMapC2);
 }
예제 #4
0
 private void InitTOCControl()
 {
     object[] cmds = new object[] {
         new Cmds.OpenAttriTable()
     };
     m_pToolbarMenu = new ToolbarMenu();
     for (int i = 0; i < cmds.Length; i++)
     {
         m_pToolbarMenu.AddItem(cmds[i]);
     }
     m_pToolbarMenu.SetHook(m_pMapC2);
 }
예제 #5
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            tabControl1.SelectedIndex = 1;
            tabControl1.SelectedIndex = 0;

            AeUtils.SetMapControl(m_pMapC2);
            AeUtils.SetMapDocument(m_pMapDoc);
            AeUtils.SetPageLayoutControl(axPageLayoutControl1);

            m_pToolbarMenu = new ToolbarMenuClass();
            m_pToolbarMenu.AddItem(new OpenAttributeTable());
            m_pToolbarMenu.SetHook(m_pMapC2);
        }
예제 #6
0
 private void InitTOCControl()
 {
     object[] cmds = new object[] {
         new AeCmd.ShowAttributeTable(),
         new AeCmd.ZoomToLayer(),
         new AeCmd.Label(),
         new AeCmd.SingleSymbology()
     };
     m_pToolbarMenu = new ToolbarMenu();
     for (int i = 0; i < cmds.Length; i++)
     {
         m_pToolbarMenu.AddItem(cmds[i]);
     }
     m_pToolbarMenu.SetHook(m_pMapC2);
 }
예제 #7
0
        private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e)
        {
            IBasicMap pMap = null;
            ILayer    pLayer = null;
            object    unk = null, data = null;

            ESRI.ArcGIS.Controls.esriTOCControlItem pItem = ESRI.ArcGIS.Controls.esriTOCControlItem.esriTOCControlItemNone;
            try
            {
                axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref unk, ref data);
            }
            catch (Exception)
            {
                throw;
            }
            switch (e.button)
            {
            case 2:
                //右键
                if (pItem == ESRI.ArcGIS.Controls.esriTOCControlItem.esriTOCControlItemMap)
                {
                    axTOCControl1.SelectItem(pMap, null);
                }
                else if (pItem == ESRI.ArcGIS.Controls.esriTOCControlItem.esriTOCControlItemLayer)
                {
                    axTOCControl1.SelectItem(pLayer, null);
                }

                axMapControl1.CustomProperty = pLayer;
                if (pItem == ESRI.ArcGIS.Controls.esriTOCControlItem.esriTOCControlItemMap)
                {
                    //
                }
                if (pItem == ESRI.ArcGIS.Controls.esriTOCControlItem.esriTOCControlItemLayer)
                {
                    var m_pMenuLayer = new ToolbarMenu();
                    m_pMenuLayer.AddItem(new BuildLineBuffer(), -1, 0, false, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleTextOnly);
                    m_pMenuLayer.AddItem(new ShowAttribute(), 1, 1, false, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleTextOnly);
                    m_pMenuLayer.SetHook(axMapControl1);
                    m_pMenuLayer.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
                }
                break;

            default:
                break;
            }
        }
예제 #8
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            IBasicMap          pMap         = null;
            ILayer             pLayer       = null;
            object             legendgp     = null;
            object             index        = null;
            ToolbarMenu        m_pMenuLayer = new ToolbarMenu();
            esriTOCControlItem pItem        = esriTOCControlItem.esriTOCControlItemNone;

            try
            {
                axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref legendgp, ref index);
            }
            catch (Exception)
            {
                throw;
            }
            switch (e.button)
            {
            case 2:
                if (pItem == esriTOCControlItem.esriTOCControlItemMap)
                {
                    axTOCControl1.SelectItem(pMap, null);
                }
                else
                {
                    axTOCControl1.SelectItem(pLayer, null);
                }
                axMapControl1.CustomProperty = pLayer;
                if (pItem == esriTOCControlItem.esriTOCControlItemMap)
                {
                    //.............右键map时
                }
                if (pItem == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    m_pMenuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
                    m_pMenuLayer.AddItem(new ZoomToLayer(), -1, 1, false, esriCommandStyles.esriCommandStyleTextOnly);
                    m_pMenuLayer.AddItem(new LayerVisibility(), 1, 2, true, esriCommandStyles.esriCommandStyleTextOnly);
                    m_pMenuLayer.AddItem(new LayerVisibility(), 2, 3, false, esriCommandStyles.esriCommandStyleTextOnly);
                    m_pMenuLayer.AddItem(new OpenAttribute(pLayer), -1, 4, true, esriCommandStyles.esriCommandStyleTextOnly);
                    m_pMenuLayer.SetHook(axMapControl1);
                    m_pMenuLayer.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
                }
                break;
            }
        }
예제 #9
0
        private void Form1_Load(object sender, System.EventArgs e)
        {
            System.Globalization.CultureInfo pCulture;

            //Set the Thread UI Culture manually by uncommenting one of the three cultures
            //that you wish to set below.

            pCulture = System.Globalization.CultureInfo.CreateSpecificCulture("fr-FR");
            //pCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
            //pCulture = System.Globalization.CultureInfo.CreateSpecificCulture("es-ES");

            //Set the UI Culture
            System.Threading.Thread.CurrentThread.CurrentUICulture = pCulture;

            //Confirm that the Thread UI Culture is set.
            lblCulture.Text = "Current Thread UI Culture = " + System.Threading.Thread.CurrentThread.CurrentUICulture.DisplayName;

            //Add command to open an mxd document
            string sProgID;

            sProgID = "esriControls.ControlsOpenDocCommand";
            axToolbarControl1.AddItem(sProgID, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //Add Map navigation commands
            sProgID = "esriControls.ControlsMapZoomInTool";
            axToolbarControl1.AddItem(sProgID, -1, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
            sProgID = "esriControls.ControlsMapZoomOutTool";
            axToolbarControl1.AddItem(sProgID, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            sProgID = "esriControls.ControlsMapPanTool";
            axToolbarControl1.AddItem(sProgID, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            sProgID = "esriControls.ControlsMapFullExtentCommand";
            axToolbarControl1.AddItem(sProgID, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //Add PageLayout navigation commands
            sProgID = "esriControls.ControlsPageZoomInTool";
            axToolbarControl1.AddItem(sProgID, -1, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
            sProgID = "esriControls.ControlsPageZoomOutTool";
            axToolbarControl1.AddItem(sProgID, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            sProgID = "esriControls.ControlsPagePanTool";
            axToolbarControl1.AddItem(sProgID, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            sProgID = "esriControls.ControlsPageZoomWholePageCommand";
            axToolbarControl1.AddItem(sProgID, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            sProgID = "esriControls.ControlsPageZoomPageToLastExtentBackCommand";
            axToolbarControl1.AddItem(sProgID, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            sProgID = "esriControls.ControlsPageZoomPageToLastExtentForwardCommand";
            axToolbarControl1.AddItem(sProgID, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            sProgID = "esriControls.ControlsSelectTool";

            //Add Culture Tool
            axToolbarControl1.AddItem("VBCSharpCultureSample.CultureTool", -1, -1, true, 0, esriCommandStyles.esriCommandStyleIconAndText);

            //Add Culture Command
            axToolbarControl1.AddItem("VBCSharpCultureSample.CultureCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconAndText);

            //Add Culture Menu
            axToolbarControl1.AddItem("VBCSharpCultureSample.CultureMenu", -1, -1, false, 0, esriCommandStyles.esriCommandStyleTextOnly);


            //Add the MenuDef to the ToolbarMenu
            string progID = "VBCSharpCultureSample.CultureMenu";

            m_pToolbarMenu.AddItem(progID, -1, -1, false, esriCommandStyles.esriCommandStyleIconAndText);

            //Set the Toolbarmenu's hook
            m_pToolbarMenu.SetHook(axToolbarControl1);

            //Set Buddy Controls
            axTOCControl1.SetBuddyControl(axPageLayoutControl1);
            axToolbarControl1.SetBuddyControl(axPageLayoutControl1);
        }
예제 #10
0
 private void FormMain_Load(object sender, EventArgs e)
 {
     m_pToolbarMenu.AddItem(new OpenAttributeTable());
     m_pToolbarMenu.SetHook(m_pMapC2);
 }
예제 #11
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            #region  主窗体右键
            /////地图视窗鼠标事件
            IToolbarMenu mapPopMenu = null;
            mapPopMenu = new ToolbarMenu();
            if (e.button == 2)
            {
                /* IMap pMap = axMapControl1.Map;
                 IActiveView pActiveView = pMap as IActiveView;
                 IEnvelope pEnv = axMapControl1.TrackRectangle();
                 pActiveView.Extent = pEnv;
                 pActiveView.Refresh();*/

                //地图视窗右键菜单功能

                mapPopMenu.AddItem(new ControlsSelectTool(), -1, 0, false, esriCommandStyles.esriCommandStyleIconAndText);
                mapPopMenu.AddItem(new ControlsMapPanTool(), -1, 1, false, esriCommandStyles.esriCommandStyleIconAndText);
                mapPopMenu.AddItem(new ControlsMapFullExtentCommand(), -1, 2, false, esriCommandStyles.esriCommandStyleIconAndText);
                mapPopMenu.AddItem(new ControlsMapIdentifyTool(), -1, 3, false, esriCommandStyles.esriCommandStyleIconAndText);//识别工具
                mapPopMenu.AddItem(new ControlsMapZoomInFixedCommand(), -1, 4, false, esriCommandStyles.esriCommandStyleIconAndText);//
                mapPopMenu.AddItem(new ControlsMapZoomInFixedCommand(), -1, 5, false, esriCommandStyles.esriCommandStyleIconAndText);
                mapPopMenu.AddItem(new ControlsSelectFeaturesTool(), -1, 6, false, esriCommandStyles.esriCommandStyleIconAndText);//选择要素工具
                mapPopMenu.AddItem(new ControlsClearSelectionCommand(), -1, 7, false, esriCommandStyles.esriCommandStyleIconAndText);//缩放所选要素
                mapPopMenu.AddItem(new ControlsZoomToSelectedCommand(), -1, 8, false, esriCommandStyles.esriCommandStyleIconAndText);
                mapPopMenu.AddItem(new ControlsMapZoomToLastExtentBackCommand(), -1, 9, false, esriCommandStyles.esriCommandStyleIconAndText);
                mapPopMenu.AddItem(new ControlsMapZoomToLastExtentForwardCommand(), -1, 10, false, esriCommandStyles.esriCommandStyleIconAndText);
                mapPopMenu.SetHook(axMapControl1);//// 得到地图视窗右键菜单
                mapPopMenu.PopupMenu(e.x, e.y, axMapControl1.hWnd);//弹出显示菜单
            }
            /*  if (e.button == 1)//左键因为右键要取消
              {
                  IMap pMap = axMapControl1.Map;
                   IActiveView pActiveView = pMap as IActiveView;
                   IEnvelope pEnv = axMapControl1.TrackRectangle();
                   pActiveView.Extent = pEnv;
                   pActiveView.Refresh();
              }
             * */
            //此事件不会触发
            if (e.button == 3)//如果鼠标中间改为ControlsMapPanTool会更好
            {
                IMap pMap = axMapControl1.Map;
                IActiveView pActiveView = pMap as IActiveView;
                IEnvelope pEnv = axMapControl1.TrackRectangle();
                pActiveView.Extent = pEnv;
                pActiveView.Refresh();
            }
            #endregion

            //if (e.button == 2)
            //{
            //    IMap pMap = axMapControl1.Map;
            //    IActiveView pActiveView = pMap as IActiveView;
            //    IEnvelope pEnv = axMapControl1.TrackRectangle();
            //    pActiveView.Extent = pEnv;
            //    pActiveView.Refresh();
            //}
            //网络分析
            if (clicked != true)
                return;
            IPoint ipNew;
            if (m_ipPoints == null)
            {
                m_ipPoints = new MultipointClass();
            }
            ipNew = m_ipActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
            object o = Type.Missing;
            m_ipPoints.AddPoint(ipNew, ref o, ref o);

            IElement element;
            ITextElement textelement = new TextElementClass();
            element = textelement as IElement;
            clickedcount++;
            textelement.Text = clickedcount.ToString();
            element.Geometry = m_ipActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
            pGC.AddElement(element, 0);
            m_ipActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
예제 #12
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            #region  主窗体右键
            /////地图视窗鼠标事件
            IToolbarMenu mapPopMenu = null;
            mapPopMenu = new ToolbarMenu();
            if (e.button == 2)
            {
                /* IMap pMap = axMapControl1.Map;
                 * IActiveView pActiveView = pMap as IActiveView;
                 * IEnvelope pEnv = axMapControl1.TrackRectangle();
                 * pActiveView.Extent = pEnv;
                 * pActiveView.Refresh();*/

                //地图视窗右键菜单功能

                mapPopMenu.AddItem(new ControlsSelectTool(), -1, 0, false, esriCommandStyles.esriCommandStyleIconAndText);
                mapPopMenu.AddItem(new ControlsMapPanTool(), -1, 1, false, esriCommandStyles.esriCommandStyleIconAndText);
                mapPopMenu.AddItem(new ControlsMapFullExtentCommand(), -1, 2, false, esriCommandStyles.esriCommandStyleIconAndText);
                mapPopMenu.AddItem(new ControlsMapIdentifyTool(), -1, 3, false, esriCommandStyles.esriCommandStyleIconAndText);       //识别工具
                mapPopMenu.AddItem(new ControlsMapZoomInFixedCommand(), -1, 4, false, esriCommandStyles.esriCommandStyleIconAndText); //
                mapPopMenu.AddItem(new ControlsMapZoomInFixedCommand(), -1, 5, false, esriCommandStyles.esriCommandStyleIconAndText);
                mapPopMenu.AddItem(new ControlsSelectFeaturesTool(), -1, 6, false, esriCommandStyles.esriCommandStyleIconAndText);    //选择要素工具
                mapPopMenu.AddItem(new ControlsClearSelectionCommand(), -1, 7, false, esriCommandStyles.esriCommandStyleIconAndText); //缩放所选要素
                mapPopMenu.AddItem(new ControlsZoomToSelectedCommand(), -1, 8, false, esriCommandStyles.esriCommandStyleIconAndText);
                mapPopMenu.AddItem(new ControlsMapZoomToLastExtentBackCommand(), -1, 9, false, esriCommandStyles.esriCommandStyleIconAndText);
                mapPopMenu.AddItem(new ControlsMapZoomToLastExtentForwardCommand(), -1, 10, false, esriCommandStyles.esriCommandStyleIconAndText);
                mapPopMenu.SetHook(axMapControl1);                  //// 得到地图视窗右键菜单
                mapPopMenu.PopupMenu(e.x, e.y, axMapControl1.hWnd); //弹出显示菜单
            }

            /*  if (e.button == 1)//左键因为右键要取消
             * {
             *    IMap pMap = axMapControl1.Map;
             *     IActiveView pActiveView = pMap as IActiveView;
             *     IEnvelope pEnv = axMapControl1.TrackRectangle();
             *     pActiveView.Extent = pEnv;
             *     pActiveView.Refresh();
             * }
             * */
            //此事件不会触发
            if (e.button == 3)//如果鼠标中间改为ControlsMapPanTool会更好
            {
                IMap        pMap        = axMapControl1.Map;
                IActiveView pActiveView = pMap as IActiveView;
                IEnvelope   pEnv        = axMapControl1.TrackRectangle();
                pActiveView.Extent = pEnv;
                pActiveView.Refresh();
            }
            #endregion

            //if (e.button == 2)
            //{
            //    IMap pMap = axMapControl1.Map;
            //    IActiveView pActiveView = pMap as IActiveView;
            //    IEnvelope pEnv = axMapControl1.TrackRectangle();
            //    pActiveView.Extent = pEnv;
            //    pActiveView.Refresh();
            //}
            //网络分析
            if (clicked != true)
            {
                return;
            }
            IPoint ipNew;
            if (m_ipPoints == null)
            {
                m_ipPoints = new MultipointClass();
            }
            ipNew = m_ipActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
            object o = Type.Missing;
            m_ipPoints.AddPoint(ipNew, ref o, ref o);

            IElement     element;
            ITextElement textelement = new TextElementClass();
            element = textelement as IElement;
            clickedcount++;
            textelement.Text = clickedcount.ToString();
            element.Geometry = m_ipActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
            pGC.AddElement(element, 0);
            m_ipActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }