示例#1
0
        public MainGIS()
        {
            InitializeComponent();
            //设置图层控件的同步控件
            axTOCControl.SetBuddyControl(axMapControl);
            //初始化公共变量
            _mapControl        = axMapControl.Object as IMapControlDefault;
            _pageLayoutControl = axPageLayoutControl.Object as IPageLayoutControlDefault;
            _tocControl        = axTOCControl.Object as ITOCControlDefault;
            _DataSet           = new DataSet();
            //初始化主框架
            _App                   = new NBGIS.PluginEngine.Application();
            _App.StatusBar         = this.uiStatusBar;
            _App.MapControl        = _mapControl;
            _App.PageLayoutControl = _pageLayoutControl;
            _App.MainPlatfrom      = this;
            _App.Caption           = this.Text;
            _App.Visible           = this.Visible;
            _App.CurrentTool       = null;
            _App.MainDataSet       = _DataSet;

            //让MapControl和PageLatoutControl保存同步
            m_controlsSynchronizer = new ControlsSynchronizer(_mapControl, _pageLayoutControl);
            m_controlsSynchronizer.BindControls(true);
            m_controlsSynchronizer.AddFrameWorkControl(axTOCControl.Object);

            //TOCControl的esriTOOControlItemMap被右键点击后弹出的快捷菜单
            _mapMenu = new ToolbarMenuClass();
            _mapMenu.AddItem(new MapMenu(), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            _mapMenu.AddItem(new MapMenu(), 2, 1, false, esriCommandStyles.esriCommandStyleTextOnly);
            _mapMenu.SetHook(this._mapControl);
        }
示例#2
0
        public MainGIS()
        {
            InitializeComponent();

            //设置图层控件的同步控件
            //this.axTOCControl1.SetBuddyControl(this.axMapControl1.Object);

            //初始化公共变量
            _mapControl        = axMapControl1.Object as IMapControlDefault;
            _pageLayoutControl = axPageLayoutControl1.Object as IPageLayoutControlDefault;
            _tocControl        = axTOCControl1.Object as ITOCControlDefault;
            _DataSet           = new DataSet();

            //初始化主框架
            _App                   = new MyPluginEngine.Application();
            _App.StatusBar         = this.uiStatusBar;
            _App.MapControl        = _mapControl;
            _App.PageLayoutControl = _pageLayoutControl;
            _App.TOCControl        = _tocControl;
            _App.MainPlatfrom      = this;
            _App.Caption           = this.Text;
            _App.Visible           = this.Visible;
            _App.CurrentTool       = null;
            _App.MainDataSet       = _DataSet;

            //让MapControl和PageLatoutControl保存同步

            m_controlsSynchronizer = new ControlsSynchronizer(_mapControl, _pageLayoutControl);

            //在同步时同时设置好与TOCControl和ToolBarControl的buddy
            m_controlsSynchronizer.AddFrameWorkControl(axTOCControl1.Object);
            m_controlsSynchronizer.AddFrameWorkControl(axToolbarControl1.Object);

            m_controlsSynchronizer.BindControls(true);

            this._App.MainCtrlsSynchronizer = m_controlsSynchronizer;

            //TOCControl的esriTOOControlItemMap被右键点击后弹出的快捷菜单
            _mapMenu = new ToolbarMenuClass();
            //通过自己的 MapMent进行添加功能,这里只有两个功能
            _mapMenu.AddItem(new MapMenu(), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            _mapMenu.AddItem(new MapMenu(), 2, 1, false, esriCommandStyles.esriCommandStyleTextOnly);
            //使用 uid
            //IUID uid = new UIDClass();
            //uid.Value = "esriControlCommands.ControlsMapFullExtentCommand";
            //_mapMenu.AddItem(uid, -1, -1, true, esriCommandStyles.esriCommandStyleIconAndText);
            _mapMenu.AddItem(new ControlsMapFindCommand(), -1, 2, true, esriCommandStyles.esriCommandStyleIconAndText);
            //使用 progid
            string progid = "esriControlCommands.ControlsMapViewMenu";

            _mapMenu.AddItem(progid, -1, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            //使用内置 Command
            _mapMenu.AddItem(new ControlsAddDataCommand(), -1, 2, true, esriCommandStyles.esriCommandStyleIconAndText);
            _mapMenu.SetHook(this._mapControl);


            //2015/7/17
            //TOCControl的esriTOOControlItemLayer被右键点击后弹出的快捷菜单
            _layerMenu = new ToolbarMenuClass();
            // 分别为缩放至图层、删除图层、打开属性表   符号选择器

            //符号选择器
            LayerMenu layerMenuSymbol = new LayerMenu(this._mapControl);

            layerMenuSymbol.SymbolChanged += new LayerMenu.SymbolChangedHandler(layerMenuSymbol_SymbolChanged);
            //layerMenuSymbol.SymbolChanged += new SymbolChangedHandler(layerMenuSymbol_SymbolChanged);
            _layerMenu.AddItem(layerMenuSymbol, 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);

            _layerMenu.AddItem(new LayerMenu(this._mapControl), 2, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            _layerMenu.AddItem(new LayerMenu(this._mapControl), 3, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            _layerMenu.AddItem(new LayerMenu(this._mapControl), 4, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            _layerMenu.SetHook(this._mapControl);
        }
示例#3
0
文件: frmMain.cs 项目: lovelll/DQHP
        private void frmMain_Load(object sender, EventArgs e)
        {
            this.axTOCControlMain.SetBuddyControl(axMapControlMain.Object);

            _mapControl = axMapControlMain.Object as IMapControlDefault;

            _tocControl = axTOCControlMain.Object as ITOCControlDefault;
        }
示例#4
0
        public MainGIS()
        {
            InitializeComponent();

            //设置图层控件的同步控件
            this.axTOCControl1.SetBuddyControl(this.axMapControl1.Object);

            //初始化公共变量
            _mapControl = axMapControl1.Object as IMapControlDefault;
            _pageLayoutControl = axPageLayoutControl1.Object as IPageLayoutControlDefault;
            _tocControl = axTOCControl1.Object as ITOCControlDefault;
            _DataSet = new DataSet();

            //初始化主框架
            _App = new MyPluginEngine.Application();
            _App.StatusBar = this.uiStatusBar;
            _App.MapControl = _mapControl;
            _App.PageLayoutControl = _pageLayoutControl;
            _App.TOCControl = _tocControl;
            _App.MainPlatfrom = this;
            _App.Caption = this.Text;
            _App.Visible = this.Visible;
            _App.CurrentTool = null;
            _App.MainDataSet = _DataSet;

            //让MapControl和PageLatoutControl保存同步
            axTOCControl1.SetBuddyControl(_mapControl);
            m_controlsSynchronizer = new ControlsSynchronizer(_mapControl, _pageLayoutControl);

            //在同步是同时设置好与TOCControl和ToolBarControl的buddy
            m_controlsSynchronizer.AddFrameWorkControl(axTOCControl1.Object);
            m_controlsSynchronizer.AddFrameWorkControl(axToolbarControl1.Object);

            m_controlsSynchronizer.BindControls(true);

            //TOCControl的esriTOOControlItemMap被右键点击后弹出的快捷菜单
            _mapMenu = new ToolbarMenuClass();
            //通过自己的 MapMent进行添加功能,这里只有两个功能
            _mapMenu.AddItem(new MapMenu(), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            _mapMenu.AddItem(new MapMenu(), 2, 1, false, esriCommandStyles.esriCommandStyleTextOnly);
            //使用 uid
            //IUID uid = new UIDClass();
            //uid.Value = "esriControlCommands.ControlsMapFullExtent";
            //_mapMenu.AddItem(uid, -1, -1, true, esriCommandStyles.esriCommandStyleIconAndText);
            _mapMenu.AddItem(new ControlsMapFindCommand(), -1, 2, true, esriCommandStyles.esriCommandStyleIconAndText);
            //使用 progid
            string progid = "esriControlCommands.ControlsMapViewMenu";
            _mapMenu.AddItem(progid, -1, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            //使用内置 Command
            _mapMenu.AddItem(new ControlsAddDataCommand(), -1 , 2, true, esriCommandStyles.esriCommandStyleIconAndText);
            _mapMenu.SetHook(this._mapControl);

            //2015/7/17
            //TOCControl的esriTOOControlItemLayer被右键点击后弹出的快捷菜单
            _layerMenu = new ToolbarMenuClass();
            // 分别为缩放至图层、删除图层、打开属性表   +
            _layerMenu.AddItem(new LayerMenu(this._mapControl), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            _layerMenu.AddItem(new LayerMenu(this._mapControl), 2, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            _layerMenu.AddItem(new LayerMenu(this._mapControl), 3, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            _layerMenu.SetHook(this._mapControl);
        }
示例#5
0
        /// <summary>
        /// 对mapcontrol上的图层进行排序
        /// </summary>
        /// <param name="vAxMapControl"></param>
        public static void LayersCompose(ESRI.ArcGIS.Controls.IMapControlDefault pMapcontrol)
        {
            IMap pMap = pMapcontrol.Map;

            int[] iLayerIndex = new int[2] {
                0, 0
            };
            int[] iFeatureLayerIndex = new int[3] {
                0, 0, 0
            };

            int iCount = pMapcontrol.LayerCount;

            for (int iIndex = 0; iIndex < iCount; iIndex++)
            {
                IFeatureLayer pFeatureLayer  = pMap.get_Layer(iIndex) as IFeatureLayer;
                IGroupLayer   groupTempLayer = pMap.get_Layer(iIndex) as IGroupLayer;
                if (groupTempLayer != null)
                {
                    LayersCompose(groupTempLayer);
                }

                if (pFeatureLayer == null)
                {
                    continue;
                }
                switch (pFeatureLayer.FeatureClass.FeatureType)
                {
                case esriFeatureType.esriFTDimension:
                    pMap.MoveLayer(pFeatureLayer, iLayerIndex[0]);
                    iLayerIndex[0] = iLayerIndex[0] + 1;
                    break;

                case esriFeatureType.esriFTAnnotation:
                    pMap.MoveLayer(pFeatureLayer, iLayerIndex[0] + iLayerIndex[1]);
                    iLayerIndex[1] = iLayerIndex[1] + 1;
                    break;

                case esriFeatureType.esriFTSimple:
                    switch (pFeatureLayer.FeatureClass.ShapeType)
                    {
                    case esriGeometryType.esriGeometryPoint:
                        pMap.MoveLayer(pFeatureLayer, iLayerIndex[0] + iLayerIndex[1] + iFeatureLayerIndex[0]);
                        iFeatureLayerIndex[0] = iFeatureLayerIndex[0] + 1;
                        break;

                    case esriGeometryType.esriGeometryLine:
                    case esriGeometryType.esriGeometryPolyline:
                        pMap.MoveLayer(pFeatureLayer, iLayerIndex[0] + iLayerIndex[1] + iFeatureLayerIndex[0] + iFeatureLayerIndex[1]);
                        iFeatureLayerIndex[1] = iFeatureLayerIndex[1] + 1;
                        break;

                    case esriGeometryType.esriGeometryPolygon:
                        pMap.MoveLayer(pFeatureLayer, iLayerIndex[0] + iLayerIndex[1] + iFeatureLayerIndex[0] + iFeatureLayerIndex[1] + iFeatureLayerIndex[2]);
                        iFeatureLayerIndex[2] = iFeatureLayerIndex[2] + 1;
                        break;
                    }
                    break;
                }
            }
        }
示例#6
0
        public static void DealOrderOfNewLayer(ESRI.ArcGIS.Controls.IMapControlDefault pMapcontrol, ILayer pLayer)
        {
            int    intOrderID    = -1;
            int    intDataTypeID = -1;//为不同的数据类型分配不同的整数,用来排序
            string strOrderID    = GetOrderIDofLayer(pLayer);

            intDataTypeID = GetDataTypeIDofLayer(pLayer);
            if (!strOrderID.Equals(""))
            {
                intOrderID = int.Parse(strOrderID);
            }

            if (pLayer is IGroupLayer)
            {
                LayersComposeEx(pMapcontrol.Map, pLayer as IGroupLayer);
            }
            int IndexOfNewLayer = -1;

            for (int i = 0; i < pMapcontrol.Map.LayerCount; i++)
            {
                ILayer pTmpLayer = pMapcontrol.Map.get_Layer(i);
                if (pTmpLayer.Equals(pLayer))
                {
                    if ((pTmpLayer as ILayerGeneralProperties).LayerDescription == (pLayer as ILayerGeneralProperties).LayerDescription)
                    {
                        IndexOfNewLayer = i;
                        break;
                    }
                }
            }
            for (int i = 0; i < pMapcontrol.Map.LayerCount; i++)
            {
                ILayer pCurLayer     = pMapcontrol.Map.get_Layer(i);
                string strCurOrderID = GetOrderIDofLayer(pCurLayer);
                int    intCurOrderID = -1;
                if (!strCurOrderID.Equals(""))
                {
                    intCurOrderID = int.Parse(strCurOrderID);
                }
                if (intOrderID > 0 && intCurOrderID > 0)
                {
                    if (intOrderID < intCurOrderID)
                    {
                        if (IndexOfNewLayer > i)
                        {
                            pMapcontrol.Map.MoveLayer(pLayer, i);
                            IndexOfNewLayer = i;
                            break;
                        }
                    }
                    else if (intOrderID > intCurOrderID)
                    {
                        if (IndexOfNewLayer < i)
                        {
                            pMapcontrol.Map.MoveLayer(pLayer, i);
                            IndexOfNewLayer = i;
                        }
                    }
                }
                else
                {
                    int intCurDataTypeID = GetDataTypeIDofLayer(pCurLayer);
                    if (intDataTypeID < intCurDataTypeID)
                    {
                        if (IndexOfNewLayer > i)
                        {
                            pMapcontrol.Map.MoveLayer(pLayer, i);
                            IndexOfNewLayer = i;
                            break;
                        }
                    }
                    else if (intDataTypeID > intCurDataTypeID)
                    {
                        if (IndexOfNewLayer < i)
                        {
                            pMapcontrol.Map.MoveLayer(pLayer, i);
                            IndexOfNewLayer = i;
                        }
                    }
                }
            }
        }