Ejemplo n.º 1
0
        private void MainFrom_Load(object sender, EventArgs e)
        {
            //将地图控件赋给变量,这样就可以使用接口所暴露的属性和方法了
            //axMapControl1属于主框架的私有控件,外部不能访问,所以采用这种模式可以通过公共变量的形式操作
            m_mapControl  = (IMapControl3)axMapControl1.Object;
            m_pTocControl = (ITOCControl2)axTOCControl1.Object;

            toolComboBox = this.toolStripComboBox2;
            //TOC控件绑定地图控件
            m_pTocControl.SetBuddyControl(m_mapControl);
            //pCurrentTOC = m_pTocControl;
            //构造地图右键菜单
            mapMenu = new ToolbarMenuClass();
            mapMenu.AddItem(new LayerVisibility(), 1, 0, false, esriCommandStyles.esriCommandStyleIconAndText);
            mapMenu.AddItem(new LayerVisibility(), 2, 1, false, esriCommandStyles.esriCommandStyleIconAndText);
            //构造图层右键菜单
            layerMenu = new ToolbarMenuClass();
            //添加“移除图层”菜单项
            layerMenu.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            //添加“放大到整个图层”菜单项
            layerMenu.AddItem(new ZoomToLayer(), -1, 1, true, esriCommandStyles.esriCommandStyleTextOnly);
            //右键菜单绑定
            mapMenu.SetHook(m_mapControl);
            layerMenu.SetHook(m_mapControl);
            // IMap map = MapUtil.OpenMap(Common.MapPath);
            MapUtil.LoadMxd(this.axMapControl1, Common.MapPath);
            ClearNoData();
            //SetInitialRouteNetLayerStyle();
        }
Ejemplo n.º 2
0
        private void ContextMenu_Load(object sender, EventArgs e)
        {
            m_tocControl = (ITOCControl2)axTOCControl1.Object;
            m_mapControl = (IMapControl3)axMapControl1.Object;

            //Set buddy control
            m_tocControl.SetBuddyControl(m_mapControl);
            axToolbarControl1.SetBuddyControl(m_mapControl);

            //Add pre-defined control commands to the ToolbarControl
            axToolbarControl1.AddItem("esriControls.ControlsSelectFeaturesTool", -1, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddToolbarDef("esriControls.ControlsMapNavigationToolbar", 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsOpenDocCommand", -1, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //Add custom commands to the map menu
            m_menuMap = new ToolbarMenuClass();
            m_menuMap.AddItem(new LayerVisibility(), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuMap.AddItem(new LayerVisibility(), 2, 1, false, esriCommandStyles.esriCommandStyleTextOnly);
            //Add pre-defined menu to the map menu as a sub menu
            m_menuMap.AddSubMenu("esriControls.ControlsFeatureSelectionMenu", 2, true);
            //Add custom commands to the map menu
            m_menuLayer = new ToolbarMenuClass();
            m_menuLayer.AddItem(new  RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuLayer.AddItem(new ScaleThresholds(), 1, 1, true, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuLayer.AddItem(new ScaleThresholds(), 2, 2, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuLayer.AddItem(new ScaleThresholds(), 3, 3, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuLayer.AddItem(new LayerSelectable(), 1, 4, true, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuLayer.AddItem(new LayerSelectable(), 2, 5, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuLayer.AddItem(new ZoomToLayer(), -1, 6, true, esriCommandStyles.esriCommandStyleTextOnly);

            //Set the hook of each menu
            m_menuLayer.SetHook(m_mapControl);
            m_menuMap.SetHook(m_mapControl);
        }
        private void ContextMenu_Load(object sender, EventArgs e)
        {
            m_tocControl = (ITOCControl2)axTOCControl1.Object;
            m_mapControl = (IMapControl3)axMapControl1.Object;

            //Set buddy control
            m_tocControl.SetBuddyControl(m_mapControl);
            axToolbarControl1.SetBuddyControl(m_mapControl);

            //Add pre-defined control commands to the ToolbarControl
            axToolbarControl1.AddItem("esriControls.ControlsSelectFeaturesTool", -1, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddToolbarDef("esriControls.ControlsMapNavigationToolbar", 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsOpenDocCommand", -1, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //Add custom commands to the map menu
            m_menuMap = new ToolbarMenuClass();
            m_menuMap.AddItem(new LayerVisibility(), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuMap.AddItem(new LayerVisibility(), 2, 1, false, esriCommandStyles.esriCommandStyleTextOnly);
            //Add pre-defined menu to the map menu as a sub menu 
            m_menuMap.AddSubMenu("esriControls.ControlsFeatureSelectionMenu", 2, true);
            //Add custom commands to the map menu
            m_menuLayer = new ToolbarMenuClass();
            m_menuLayer.AddItem(new  RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuLayer.AddItem(new ScaleThresholds(), 1, 1, true, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuLayer.AddItem(new ScaleThresholds(), 2, 2, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuLayer.AddItem(new ScaleThresholds(), 3, 3, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuLayer.AddItem(new LayerSelectable(), 1, 4, true, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuLayer.AddItem(new LayerSelectable(), 2, 5, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuLayer.AddItem(new ZoomToLayer(), -1, 6, true, esriCommandStyles.esriCommandStyleTextOnly);

            //Set the hook of each menu
            m_menuLayer.SetHook(m_mapControl);
            m_menuMap.SetHook(m_mapControl);
        }
        private void MainForm_Load(object sender, EventArgs e)
        {
            //get the MapControl and tocControl
            m_tocControl = (ITOCControl2)axTOCControl1.Object;
            m_mapControl = (IMapControl3)axMapControl1.Object;

            //Set buddy control for tocControl
            m_tocControl.SetBuddyControl(m_mapControl);
            axToolbarControl2.SetBuddyControl(m_mapControl);

            //disable the Save menu (since there is no document yet)
            menuSaveDoc.Enabled = false;
            axToolbarControl2.Select();

            //Create a SchematicEditor's MenuDef object
            IMenuDef menuDefSchematicEditor = new CreateMenuSchematicEditor();

            //Add SchematicEditor on the ToolBarMenu
            m_CreateMenu.AddItem(menuDefSchematicEditor, 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);

            //Set the ToolbarMenu's hook
            m_CreateMenu.SetHook(axToolbarControl2.Object);

            //Set the ToolbarMenu's caption
            m_CreateMenu.Caption = "SchematicEditor";

            /// Add ToolbarMenu on the ToolBarControl
            axToolbarControl2.AddItem(m_CreateMenu, -1, -1, false, 0, esriCommandStyles.esriCommandStyleMenuBar);

            ///Create a other ToolbarMenu for layer
            m_menuSchematicLayer = new ToolbarMenuClass();
            m_menuLayer          = new ToolbarMenuClass();

            ///Add 3 items on the SchematicLayer properties menu
            m_menuSchematicLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuSchematicLayer.AddItem("esriControls.ControlsSchematicSaveEditsCommand", -1, 1, true, esriCommandStyles.esriCommandStyleIconAndText);
            m_menuSchematicLayer.AddItem("esriControls.ControlsSchematicUpdateDiagramCommand", -1, 2, false, esriCommandStyles.esriCommandStyleIconAndText);

            IMenuDef subMenuDef = new CreateSubMenuSchematic();

            m_menuSchematicLayer.AddSubMenu(subMenuDef, 3, true);
            ////Add the sub-menu as the third item on the Layer properties menu, making it start a new group
            m_menuSchematicLayer.AddItem(new ZoomToLayer(), -1, 4, true, esriCommandStyles.esriCommandStyleTextOnly);

            m_menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
            m_menuLayer.AddItem(new ZoomToLayer(), -1, 1, true, esriCommandStyles.esriCommandStyleTextOnly);

            ////Set the hook of each menu
            m_menuSchematicLayer.SetHook(m_mapControl);
            m_menuLayer.SetHook(m_mapControl);
        }
		private void MainForm_Load(object sender, EventArgs e)
		{
			//get the MapControl and tocControl
			m_tocControl = (ITOCControl2)axTOCControl1.Object;
			m_mapControl = (IMapControl3)axMapControl1.Object;

			//Set buddy control for tocControl
			m_tocControl.SetBuddyControl(m_mapControl);
			axToolbarControl2.SetBuddyControl(m_mapControl);

			//disable the Save menu (since there is no document yet)
			menuSaveDoc.Enabled = false;
			axToolbarControl2.Select();

			//Create a SchematicEditor's MenuDef object
			IMenuDef menuDefSchematicEditor = new CreateMenuSchematicEditor();

			//Add SchematicEditor on the ToolBarMenu
			m_CreateMenu.AddItem(menuDefSchematicEditor, 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText);

			//Set the ToolbarMenu's hook
			m_CreateMenu.SetHook(axToolbarControl2.Object);

			//Set the ToolbarMenu's caption
			m_CreateMenu.Caption = "SchematicEditor";

			/// Add ToolbarMenu on the ToolBarControl
			axToolbarControl2.AddItem(m_CreateMenu, -1, -1, false, 0, esriCommandStyles.esriCommandStyleMenuBar);

			///Create a other ToolbarMenu for layer
			m_menuSchematicLayer = new ToolbarMenuClass();
			m_menuLayer = new ToolbarMenuClass();

			///Add 3 items on the SchematicLayer properties menu 
			m_menuSchematicLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
			m_menuSchematicLayer.AddItem("esriControls.ControlsSchematicSaveEditsCommand", -1, 1, true, esriCommandStyles.esriCommandStyleIconAndText);
			m_menuSchematicLayer.AddItem("esriControls.ControlsSchematicUpdateDiagramCommand", -1, 2, false, esriCommandStyles.esriCommandStyleIconAndText);

			IMenuDef subMenuDef = new CreateSubMenuSchematic();
			m_menuSchematicLayer.AddSubMenu(subMenuDef, 3, true);
			////Add the sub-menu as the third item on the Layer properties menu, making it start a new group
			m_menuSchematicLayer.AddItem(new ZoomToLayer(), -1, 4, true, esriCommandStyles.esriCommandStyleTextOnly);

			m_menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
			m_menuLayer.AddItem(new ZoomToLayer(), -1, 1, true, esriCommandStyles.esriCommandStyleTextOnly);

			////Set the hook of each menu
			m_menuSchematicLayer.SetHook(m_mapControl);
			m_menuLayer.SetHook(m_mapControl);
		}
Ejemplo n.º 6
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            //Get Start up path to set a sample data path and path of temporary folder
            strPath = System.Windows.Forms.Application.StartupPath;
            axMapControl1.ActiveView.FocusMap.Name = "Layers";
            //get the MapControl
            m_mapControl = (IMapControl3)axMapControl1.Object;

            //disable the Save menu (since there is no document yet)
            menuSaveDoc.Enabled = false;

            lstRenderedLayers = new List <clsRenderedLayers>();
            m_pSnippet        = new clsSnippet();
            try
            {
                //Load sample mxd
                //string filePath = strPath + @"\Sample.mxd";
                //string filePath = strPath + @"\SampleData\Sample_plano.mxd";//For Plano
                //string filePath = strPath + @"\SampleData\Classification\Iowa_cnties.mxd";//For Iowa

                //if (axMapControl1.CheckMxFile(filePath))
                //    axMapControl1.LoadMxFile(filePath, Type.Missing, Type.Missing);
                //else
                //    MessageBox.Show("Wrong direction");

                ////Get Envelope of mxd
                //IActiveView pActiveView1 = axMapControl1.ActiveView.FocusMap as IActiveView;
                ////ILayer pLayer1 = pActiveView1.FocusMap.get_Layer(2);
                //ILayer pLayer1 = pActiveView1.FocusMap.get_Layer(0);

                ////adjust extent to fit a screen resolution
                //IFeatureLayer pFLayer1 = pLayer1 as IFeatureLayer;
                //IEnvelope envelope1 = new EnvelopeClass();
                //envelope1.PutCoords(pFLayer1.AreaOfInterest.Envelope.XMin - (pFLayer1.AreaOfInterest.Envelope.XMin * 0.0005), pFLayer1.AreaOfInterest.Envelope.YMin - (pFLayer1.AreaOfInterest.Envelope.YMin * 0.0005), pFLayer1.AreaOfInterest.Envelope.XMax * 1.0005, pFLayer1.AreaOfInterest.Envelope.YMax * 1.0005);
                //axMapControl1.ActiveView.Extent = envelope1;
                //axMapControl1.ActiveView.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error 101: " + ex.Message);
            }

            try
            {
                //R environment setting

                #region Previous Methods
                //var envPath = Environment.GetEnvironmentVariable("PATH");
                //var rBinPath = strPath + @"\R-3.1.2\bin\i386"; // R is copited into startup path
                //Environment.SetEnvironmentVariable("PATH", envPath + System.IO.Path.PathSeparator + rBinPath);
                ////Environment.SetEnvironmentVariable("PATH", rBinPath); //Not working
                //Environment.SetEnvironmentVariable("R_HOME", strPath + @"\R-3.1.2");

                ////Loading REngine
                //pEngine = REngine.CreateInstance(strREngineName);
                //pEngine.Initialize();

                ////string[] strRHOME = pEngine.Evaluate("R.home(component = 'home')").AsCharacter().ToArray(); //For Deburgging
                //LibHome = pEngine.Evaluate(".libPaths()").AsCharacter().ToArray();

                //string strLibPath = strPath.Replace(@"\", @"/") + "/R-3.1.2/library";
                ////pEngine.Evaluate(".libPaths(" + strLibPath + ")");
                ////pEngine.Evaluate(".libPaths(c(" + strLibPath + ", .Library.site, .Library))");//Same results with the above
                ////pEngine.Evaluate(".libPaths(c(" + strLibPath + "))");//Same results with the above
                //pEngine.Evaluate(".Library.site <- file.path('"+strLibPath+"')"); //Same results with the above
                //pEngine.Evaluate("Sys.setenv(R_LIBS_USER='******')");
                ////string[] tempstring1 = pEngine.Evaluate("Sys.getenv('R_LIBS_USER')").AsCharacter().ToArray();
                ////string[] tempstring = pEngine.Evaluate(".Library.site").AsCharacter().ToArray();
                //pEngine.Evaluate(".libPaths(c('" + strLibPath + "', .Library.site, .Library))");

                //LibHome = pEngine.Evaluate(".libPaths()").AsCharacter().ToArray();
                //pEngine.Evaluate("ip <- installed.packages()").AsCharacter();
                //string[] installedPackages = pEngine.Evaluate("ip[,1]").AsCharacter().ToArray(); //To Check Installed Packages in R
                //clsRPackageNames pPckNames = new clsRPackageNames();
                //blnsInstalledPcks = pPckNames.CheckedRequiredPackages(installedPackages);

                #endregion

                //Current version of R is 3.4.4 (03/19/18 HK)
                var envPath  = Environment.GetEnvironmentVariable("PATH");
                var rBinPath = strPath + @"\R-3.4.4\bin\i386"; // R is copited into startup path
                Environment.SetEnvironmentVariable("PATH", envPath + System.IO.Path.PathSeparator + rBinPath);
                Environment.SetEnvironmentVariable("R_HOME", strPath + @"\R-3.4.4");

                //Loading REngine
                pEngine = REngine.CreateInstance(strREngineName);
                pEngine.Initialize();

                //Set Library home and remove local home!
                LibHome = pEngine.Evaluate(".libPaths()").AsCharacter().ToArray();
                string strLibPath = strPath.Replace(@"\", @"/") + "/R-3.4.4/library"; //path for R packages
                pEngine.Evaluate(".Library.site <- file.path('" + strLibPath + "')");
                pEngine.Evaluate("Sys.setenv(R_LIBS_USER='******')");
                pEngine.Evaluate(".libPaths(c('" + strLibPath + "', .Library.site, .Library))");

                //Checked installed packages and R
                LibHome = pEngine.Evaluate(".libPaths()").AsCharacter().ToArray();
                pEngine.Evaluate("ip <- installed.packages()").AsCharacter();
                string[]         installedPackages = pEngine.Evaluate("ip[,1]").AsCharacter().ToArray(); //To Check Installed Packages in R
                clsRPackageNames pPckNames         = new clsRPackageNames();
                blnsInstalledPcks = pPckNames.CheckedRequiredPackages(installedPackages);



                ////Installing Additional Package
                //Currently required pacakges:: MASS, geoR, car, spdep, maptools, deldir, rgeos, e1071
                //package required for Testing: fpc
                //pEngine.Evaluate("install.packages('fpc')");
                //pEngine.Evaluate("install.packages('e1071')");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error 102:" + ex.Message);
            }

            try
            {
                //Toolbar Control, insert new tools here!!
                m_ToolbarControl = (IToolbarControl2)axToolbarControl1.Object;

                int intItemCounts = m_ToolbarControl.Count;
                m_ToolbarControl.AddItem(new toolDenPlot(), -1, intItemCounts, true, 0, esriCommandStyles.esriCommandStyleIconOnly);        //Probability density plot tool
                //m_ToolbarControl.AddItem(new toolUncernFeature(), -1, intItemCounts+1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); // Remove now 07/31/15
                m_ToolbarControl.AddItem(new ToolCumsum(), -1, intItemCounts + 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);    // Empirical cumulative density function
                m_ToolbarControl.AddItem(new toolHistogram(), -1, intItemCounts + 2, false, 0, esriCommandStyles.esriCommandStyleIconOnly); // Histogram tool
                m_ToolbarControl.AddItem(new LinkingTool(), -1, intItemCounts + 3, true, 0, esriCommandStyles.esriCommandStyleIconOnly);    // Histogram tool
                m_ToolbarControl.AddItem(new AddFeatureClass(), -1, 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);               // Histogram tool
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error 103: " + ex.Message);
            }

            try
            {
                //Loading Context menu at TOC
                m_tocControl = axTOCControl1.Object as ITOCControl2;
                m_tocControl.SetBuddyControl(m_mapControl);
                m_menuLayer = new ToolbarMenuClass();
                m_menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
                m_menuLayer.AddItem(new OpenAttriTable(), -1, 1, false, esriCommandStyles.esriCommandStyleTextOnly);
                m_menuLayer.AddItem(new ZoomToLayer(), -1, 2, false, esriCommandStyles.esriCommandStyleTextOnly);
                m_menuLayer.AddItem(new ZoomToSelectedFeatures(), -1, 3, false, esriCommandStyles.esriCommandStyleTextOnly);
                m_menuLayer.AddItem(new SaveLayerFile(), -1, 4, false, esriCommandStyles.esriCommandStyleTextOnly);
                m_menuLayer.AddItem(new LayerSymbology(), -1, 5, false, esriCommandStyles.esriCommandStyleTextOnly);
                m_menuLayer.AddItem(new LayerProperty(), -1, 6, false, esriCommandStyles.esriCommandStyleTextOnly);
                //m_menuLayer.AddItem(new Symbology(), -1, 3, false, esriCommandStyles.esriCommandStyleTextOnly);
                //m_menuLayer.AddItem(new SimpleSymbology(), -1, 3, false, esriCommandStyles.esriCommandStyleTextOnly);
                m_menuLayer.SetHook(m_mapControl);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error 104:" + ex.Message);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Form load event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmMain_Load(object sender, EventArgs e)
        {
            try
            {
                //reference existing map ctrl and toc ctrl
                getSetTocControl = (ITOCControl2)axTOCControl1.Object;
                getSetMapControl = (IMapControl3)axMapControl1.Object;

                //Set buddy control
                getSetTocControl.SetBuddyControl(m_mapControl);
                axToolbarControl1.SetBuddyControl(m_mapControl);

                //Add pre-defined control commands to the ToolbarControl
                axToolbarControl1.AddItem("esriControls.ControlsSelectFeaturesTool", -1, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
                axToolbarControl1.AddToolbarDef("esriControls.ControlsMapNavigationToolbar", 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
                axToolbarControl1.AddItem("esriControls.ControlsOpenDocCommand", -1, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

                //Add custom commands to the map menu
                getSetMenuMap = new ToolbarMenuClass();
                getSetMenuMap.AddItem(new LayerVisibility(), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
                getSetMenuMap.AddItem(new LayerVisibility(), 2, 1, false, esriCommandStyles.esriCommandStyleTextOnly);
                //Add pre-defined menu to the map menu as a sub menu
                getSetMenuMap.AddSubMenu("esriControls.ControlsFeatureSelectionMenu", 2, true);
                //Add custom commands to the map menu
                getSetMenuLayer = new ToolbarMenuClass();
                getSetMenuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
                getSetMenuLayer.AddItem(new ScaleThresholds(), 1, 1, true, esriCommandStyles.esriCommandStyleTextOnly);
                getSetMenuLayer.AddItem(new ScaleThresholds(), 2, 2, false, esriCommandStyles.esriCommandStyleTextOnly);
                getSetMenuLayer.AddItem(new ScaleThresholds(), 3, 3, false, esriCommandStyles.esriCommandStyleTextOnly);
                getSetMenuLayer.AddItem(new LayerSelectable(), 1, 4, true, esriCommandStyles.esriCommandStyleTextOnly);
                getSetMenuLayer.AddItem(new LayerSelectable(), 2, 5, false, esriCommandStyles.esriCommandStyleTextOnly);
                getSetMenuLayer.AddItem(new ZoomToLayer(), -1, 6, true, esriCommandStyles.esriCommandStyleTextOnly);

                //Add Open attribute table command
                getSetMenuLayer.AddItem(new OpenAttributeTable(getSetTocControl), -1, 7, true, esriCommandStyles.esriCommandStyleTextOnly);

                //Set the hook of each menu
                getSetMenuLayer.SetHook(getSetMapControl);
                getSetMenuMap.SetHook(getSetMapControl);
            }
            catch (COMException COMex)
            {
                MessageBox.Show("Error " + COMex.ErrorCode.ToString() + ": " + COMex.Message);

            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }