/// <summary>
 /// class constructor
 /// </summary>
 /// <param name="mapControl"></param>
 /// <param name="pageLayoutControl"></param>
 public ControlsSynchronizer(IMapControl3 mapControl, IPageLayoutControl2 pageLayoutControl)
   : this()
 {
   //assign the class members
   m_mapControl = mapControl;
   m_pageLayoutControl = pageLayoutControl;
 }
        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);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="mapControl"></param>
 /// <param name="pageLayoutControl"></param>
 public ControlsSynchronizer(IMapControl3 mapControl, IPageLayoutControl2 pageLayoutControl)
     : this()
 {
     //为类成员赋值
     m_mapControl = mapControl;
     m_pageLayoutControl = pageLayoutControl;
 }
        /// <summary>
        /// �ڹ��캯���д����ͼ�ؼ��Ͳ��ֿؼ�
        /// </summary>
        /// <param name="_MapControl"></param>
        /// <param name="_PageLayoutControl"></param>
        public ControlsSynchronizer(IMapControl3 _MapControl, IPageLayoutControl2 _PageLayoutControl)
            : this()
        {
            //assign the class members
              pMapControl = _MapControl;

              pPageLayoutControl = _PageLayoutControl;
        }
Ejemplo n.º 5
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            //get the MapControl
            m_mapControl = (IMapControl3)axMapControl1.Object;

            //disable the Save menu (since there is no document yet)
            menuSaveDoc.Enabled = false;
        }
Ejemplo n.º 6
0
 public ASCDTForm(IMapControl3 mapControl)
 {
     InitializeComponent();
     m_mapControl = mapControl;
     string fileName = "ASCDT_Cluster.shp";
     m_dataInfo = new DataInformation(mapControl, fileName);
     inputAndOutput.SetValues(mapControl, m_dataInfo);
 }
Ejemplo n.º 7
0
 public DBSCANForm(IMapControl3 mapControl)
 {
     InitializeComponent();
     m_mapControl = mapControl;
     string fileName = "DBSCAN_Cluster.shp";
     m_dataInfo = new DataInformation(mapControl, fileName);
     inputAndOutput.SetValues(mapControl, m_dataInfo);
       //  inputAndOutput.AddLayerNames();
 }
 public FormAttributeTable(AxMapControl pMapControl, IMapControl3 pMapCtrl)
 {
     InitializeComponent();
     _MapControl = pMapControl;
     m_mapControl = pMapCtrl;
     ILayer pLayer = (ILayer)m_mapControl.CustomProperty;
     pFLayer = pLayer as IFeatureLayer;
     pFClass = pFLayer.FeatureClass;
 }
Ejemplo n.º 9
0
 public void SetControls(IMapControl3 map, ITOCControl2 toc)
 {
     _mapControl = map;
     _tocControl = toc;
     _view.SetMapControl(_mapControl);
     _view.SetTocControl(_tocControl);
     //_thematic = new Thematic(_mapControl);
     //_thematic.SetTocControl(_tocControl);
     //_controller = new ThematicController(_thematic, _view);
 }
    private void MainForm_Load(object sender, EventArgs e)
    {
      //get the MapControl
      m_mapControl = (IMapControl3)axMapControl1.Object;

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

      axToolbarControl1.AddItem(new ToggleDynamicDisplayCmd());
      axToolbarControl1.AddItem(new LoadDynamicLayerCmd());
    }
Ejemplo n.º 11
0
        public static void Addtool(AxMapControl axMapControl, IMapControl3 mapControl, IToolbarControl toolbarControl, IWorkspace workSpace)
        {
            //全局变量赋值
            DataEditCommon.g_tbCtlEdit = toolbarControl;
            DataEditCommon.g_pMyMapCtrl = mapControl;
            DataEditCommon.g_pCurrentWorkSpace = workSpace;
            DataEditCommon.g_pAxMapControl = axMapControl;
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicEdit.UndoEdit(), 0, -1, true, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicEdit.RedoEdit(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AttributeQueryEdit(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.MeasureDistance(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.MeasureArea(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicEdit.FeatureSelect(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicEdit.FeatureClearSelect(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.SaveEdit(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);

            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.FixedZoomInCommand(), 0, -1, true, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.FixedZoomOutCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ZoomInTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ZoomOutTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ExtentBackCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ExtentForwardCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.PanTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ZoomToTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.RefreshViewCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.FullExtentTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.MapRotateTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            //Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ToolbarLocalView(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.LocalView(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.View.ClearView(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);

            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.RotateTool(), 0, -1, true, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicModify.FeatureMoveEdit(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.MirrorFeature(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicModify.EditCopyCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicModify.EditCutCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicModify.EditPasteCommand(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.GraphicModify.DeleteFeature(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.ExtendTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.TrimLineTool(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);

            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.BasicGraphic.LayersList(), 0, -1, true, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.BasicGraphic.AddPoint(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddStraightFeatureLine(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.BasicGraphic.AddFeatureLine(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddBezierCurve(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddRectangle(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddText(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddCircle(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddArc(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.AddEllipse(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
            Common.DataEditCommon.g_tbCtlEdit.AddItem(new GIS.BasicGraphic.AddPolygon(), 0, -1, false, 0, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconOnly);
        }
Ejemplo n.º 12
0
 public Thematic(IMapControl3 mapControl)
 {
     if (mapControl != null)
     {
         this._mapControl = mapControl;
     }
     _renderer = new ClassBreaksRendererClass();
     _classify = new QuantileClass();
     _tableHistogram = new BasicTableHistogramClass();
     _colorFrom = new HsvColorClass();
     _colorTo = new HsvColorClass();
     _algClrRamp = new AlgorithmicColorRampClass();
 }
		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)
        {        
            m_mapControl = (IMapControl3) axMapControl1.Object;

            //relative file path to the sample data from EXE location
            string filePath = @"..\..\..\data\USAMajorHighways";
 
            //Add Lakes layer
            IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactoryClass();
            IFeatureWorkspace workspace = (IFeatureWorkspace)workspaceFactory.OpenFromFile(filePath, axMapControl1.hWnd);
            IFeatureLayer featureLayer = new FeatureLayerClass();
            featureLayer.Name = "Lakes";
            featureLayer.Visible = true;
            featureLayer.FeatureClass = workspace.OpenFeatureClass("us_lakes");

            #region create a SimplerRenderer
            IRgbColor color = new RgbColorClass();
            color.Red = 190;
            color.Green = 232;
            color.Blue = 255;

            ISimpleFillSymbol sym = new SimpleFillSymbolClass();
            sym.Color = color;

            ISimpleRenderer renderer = new SimpleRendererClass();
            renderer.Symbol = sym as ISymbol;
            #endregion

            ((IGeoFeatureLayer)featureLayer).Renderer = renderer as IFeatureRenderer;
            axMapControl1.Map.AddLayer((ILayer)featureLayer);

            //Add Highways layer
            featureLayer = new FeatureLayerClass();
            featureLayer.Name = "Highways";
            featureLayer.Visible = true;
            featureLayer.FeatureClass = workspace.OpenFeatureClass("usa_major_highways");
            axMapControl1.Map.AddLayer((ILayer)featureLayer);

            //******** Important *************
            //store a reference to this form (Mainform) using the EditHelper class
            EditHelper.TheMainForm = this;
            EditHelper.IsEditorFormOpen = false;

            //add the EditCmd command to the toolbar
            axEditorToolbar.AddItem("esriControls.ControlsOpenDocCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axEditorToolbar.AddItem("esriControls.ControlsSaveAsDocCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axEditorToolbar.AddItem("esriControls.ControlsAddDataCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axEditorToolbar.AddItem(new EditCmd(), 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
             
        }
Ejemplo n.º 15
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            pEn = axMapControl1.Extent;//鹰眼红框初始化
            CreateOverviewSymbol();
            //get the MapControl
            axMapControl1.KeyIntercept = (int)esriKeyIntercept.esriKeyInterceptArrowKeys;//设定鼠标滚轴缩放地图有效
            axMapControl1.AutoMouseWheel = true;//设定axMapControl1鼠标滚轴缩放地图有效
            axMapControl1.AutoKeyboardScrolling = true;//设定axMapControl1鼠标滚轴缩放地图有效
            axMapControl2.AutoMouseWheel = false;//设定axMapControl2鼠标滚轴缩放地图无效
            axMapControl2.AutoKeyboardScrolling = false;//设定axMapControl2鼠标滚轴缩放地图无效

            m_mapControl = (IMapControl3)axMapControl1.Object;

            //disable the Save menu (since there is no document yet)
            menuSaveDoc.Enabled = false;
            BindRightMenu();
        }
 //加载主界面
 private void MainForm_Load(object sender, EventArgs e)
 {
     this.axMapControl1.Map.Name = "Map"; //修改初始地图名为Map3的bug
     string strInstall = ESRI.ArcGIS.RuntimeManager.ActiveRuntime.Path;
     #region     //右键功能相关设置--添加功能项
     pTocControl = (ITOCControl2)axTOCControl1.Object;
     pMapControl = (IMapControl3)axMapControl1.Object;
     pToolMenuMap = new ToolbarMenuClass(); 
     pToolMenuLayer = new ToolbarMenuClass();
     pToolMenuLayer.AddItem(new RemoveLayerCommand(), 0, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
     pToolMenuLayer.AddItem(new OpenAttributeCommand(this.axMapControl1), 0, 1, false, esriCommandStyles.esriCommandStyleTextOnly);
     pToolMenuLayer.AddItem(new ZoomToLayerCommand(), 0, 2, true, esriCommandStyles.esriCommandStyleTextOnly);
     pToolMenuLayer.AddItem(new ScaleThresholdsCommand(), 1, 3, true, esriCommandStyles.esriCommandStyleTextOnly);
     pToolMenuLayer.AddItem(new ScaleThresholdsCommand(), 2, 4, false, esriCommandStyles.esriCommandStyleTextOnly);
     pToolMenuLayer.AddItem(new ScaleThresholdsCommand(), 3, 5, false, esriCommandStyles.esriCommandStyleTextOnly);
     pToolMenuLayer.AddItem(new LayerSelectableCommand(), 1, 6, true, esriCommandStyles.esriCommandStyleTextOnly);
     pToolMenuLayer.SetHook(pMapControl);
     #endregion
 }
Ejemplo n.º 17
0
        public GIS_ToolbarEdit(AxMapControl axMapControl, IMapControl3 mapControl, IToolbarControl toolbarControl, IWorkspace workSpace)
        {
            //ȫ�ֱ�����ֵ
            DataEditCommon.g_tbCtlEdit = toolbarControl;
            DataEditCommon.g_pMyMapCtrl = mapControl;
            DataEditCommon.g_pCurrentWorkSpace = workSpace;
            DataEditCommon.g_pAxMapControl = axMapControl;

            BeginGroup();
            //AddItem("GIS.GraphicModify.RotateTool");
            AddItem("GIS.GraphicEdit.UndoEdit");
            AddItem("GIS.GraphicEdit.RedoEdit");
            AddItem("GIS.GraphicEdit.AttributeQueryEdit");
            AddItem("GIS.GraphicEdit.MeasureDistance");
            AddItem("GIS.GraphicEdit.MeasureArea");
            //AddItem("GIS.GraphicEdit.MenuFeatureSelect");
            AddItem("GIS.GraphicEdit.FeatureSelect");
            AddItem("GIS.GraphicEdit.FeatureClearSelect");
            //AddItem("GIS.GraphicEdit.SnapSetting");
            AddItem("GIS.GraphicEdit.SaveEdit");
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Occurs when this command is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            if (hook == null)
                return;

            try
            {
                m_mapControl = (IMapControl3)hook;
            }
            catch
            {
                m_hookHelper = null;
            }

            if (m_mapControl == null)
                base.m_enabled = false;
            else
                base.m_enabled = true;

            // TODO:  Add other initialization code
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 导出为图片或PDF
        /// </summary>
        public static void ExportPicPdf(IMapControl3 m_MapControl)
        {
            SaveFileDialog savePrinterFileDialog = new SaveFileDialog();

            savePrinterFileDialog.Title  = "打印成图片";
            savePrinterFileDialog.Filter = "BMP图片(*.bmp)|*.bmp|JPG图片(*.jpg)|*.jpg|PDF 文件(*.pdf)|*.pdf|PNG 图片(*.png)|*.png";
            if (savePrinterFileDialog.ShowDialog() == DialogResult.OK)
            {
                IActiveView activeView = m_MapControl.ActiveView;
                if (activeView == null)
                {
                    return;
                }

                IExport export = null;

                switch (savePrinterFileDialog.FilterIndex)
                {
                case 1:                                  //bmp
                    export = new ExportBMP() as IExport; //输出BMP格式图片
                    export.ExportFileName = savePrinterFileDialog.FileName;
                    break;

                case 2:                                   //jpg
                    export = new ExportJPEG() as IExport; //输出JPG格式图片
                    export.ExportFileName = savePrinterFileDialog.FileName;
                    break;

                case 3:                                  //pdf
                    export = new ExportPDF() as IExport; //输出PDF格式文件
                    ((IExportPDF2)export).ExportMeasureInfo = true;
                    ((IExportPDF2)export).ExportPDFLayersAndFeatureAttributes = esriExportPDFLayerOptions.esriExportPDFLayerOptionsLayersAndFeatureAttributes;
                    export.ExportFileName = savePrinterFileDialog.FileName;
                    break;

                case 4:                                  //png
                    export = new ExportPNG() as IExport; //输出PNG格式图片
                    export.ExportFileName = savePrinterFileDialog.FileName;
                    break;
                }

                if (export == null)
                {
                    MessageBox.Show(@"请选择输出路径。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                int ScreenResolution = 96;
                int OutputResolution = 300;
                export.Resolution = OutputResolution;

                tagRECT exportRECT;
                exportRECT.left   = 0;
                exportRECT.top    = 0;
                exportRECT.right  = activeView.ExportFrame.right * (OutputResolution / ScreenResolution);
                exportRECT.bottom = activeView.ExportFrame.bottom * (OutputResolution / ScreenResolution);

                IEnvelope pixelBoundsEnv = new Envelope() as IEnvelope;
                pixelBoundsEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
                export.PixelBounds = pixelBoundsEnv;
                int hDC = export.StartExporting();
                activeView.Output(hDC, (int)export.Resolution, ref exportRECT, null, null);
                export.FinishExporting();
                export.Cleanup();
            }
        }
Ejemplo n.º 20
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            if (!ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.ArcReader))
            {
                if (!ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop))
                {
                    MessageBox.Show("Unable to bind to ArcGIS runtime. Application will be shut down.");
                    return;
                }
            }
            //get the MapControl
            m_mapControl = (IMapControl3)axMapControl1.Object;

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

            activeview = axMapControl1.Map as IActiveView;
            map = activeview.FocusMap;
            pScreenDisplay = activeview.ScreenDisplay;
            pGraphicsContainer = map as IGraphicsContainer;
            IGraphicsContainerSelect pGraphconSel = map as IGraphicsContainerSelect;
        }
Ejemplo n.º 21
0
 /// <summary>
 /// The hooker
 /// </summary>
 /// <param name="hook"></param>
 public override void OnCreate(object hook)
 {
     getSetMapControl = (IMapControl3)hook;
 }
		public override void OnCreate(object hook)
		{
			// The "hook" was set as a MapControl in formMain_Load
			m_mapControl = hook as IMapControl3;
		}
		private void PopulateInputDataComboBox(IMapControl3 mapControl, IDataLayer dataLayer)
		{
			esriGeometryType targetGeoType = GetDataLayerGeometryType(dataLayer);

			IEnumLayer sourceLayers = null;
			ILayer sourceLayer = null;
			IDisplayTable sourceDisplayTable = null;
			UID searchInterfaceUID = new UID();

			if (targetGeoType != esriGeometryType.esriGeometryNull)
			{
				// Only include layers that are of type IFeatureLayer
				searchInterfaceUID.Value = typeof(IFeatureLayer).GUID.ToString("B");
				sourceLayers = mapControl.Map.get_Layers(searchInterfaceUID, true);

				// iterate over all of the feature layers
				sourceLayer = sourceLayers.Next();
				while (sourceLayer != null)
				{
					// Verify that the layer is a feature layer and a display table
					IFeatureLayer sourceFeatureLayer = sourceLayer as IFeatureLayer;
					sourceDisplayTable = sourceLayer as IDisplayTable;
					if ((sourceFeatureLayer != null) && (sourceDisplayTable != null))
					{
						// Make sure that the geometry of the feature layer matches the geometry
						//   of the class into which we are loading
						IFeatureClass sourceFeatureClass = sourceFeatureLayer.FeatureClass;
						esriGeometryType sourceGeoType = sourceFeatureClass.ShapeType;
						if ((sourceGeoType == targetGeoType) ||
						   (targetGeoType == esriGeometryType.esriGeometryPoint && sourceGeoType == esriGeometryType.esriGeometryMultipoint))
						{
							// Add the layer name to the combobox and the layer to the list
							cboInputData.Items.Add(sourceLayer.Name);
							m_listDisplayTable.Add(sourceDisplayTable);
						}
					}

					sourceLayer = sourceLayers.Next();
				}
			}
			// The layer being loaded into has no geometry type
			else
			{
				// Find all of the standalone table that are not part of an NALayer
				IStandaloneTableCollection sourceStandaloneTables = mapControl.Map as IStandaloneTableCollection;
				IStandaloneTable sourceStandaloneTable = null;
				sourceDisplayTable = null;

				int count = 0;
				if (sourceStandaloneTables != null)
					count = sourceStandaloneTables.StandaloneTableCount;

				for (int i = 0; i < count; ++i)
				{
					sourceStandaloneTable = sourceStandaloneTables.get_StandaloneTable(i);
					sourceDisplayTable = sourceStandaloneTable as IDisplayTable;

					if ((sourceStandaloneTable != null) && (sourceDisplayTable != null))
					{
						// Add the table name to the combobox and the layer to the list
						cboInputData.Items.Add(sourceStandaloneTable.Name);
						m_listDisplayTable.Add(sourceDisplayTable);
					}
				}

				// Find all of the standalone tables that are part of an NALayer
				searchInterfaceUID.Value = typeof(INALayer).GUID.ToString("B");
				sourceLayers = mapControl.Map.get_Layers(searchInterfaceUID, true);

				sourceLayer = sourceLayers.Next();
				while (sourceLayer != null)
				{
					INALayer sourceNALayer = sourceLayer as INALayer;
					if (sourceNALayer != null)
					{
						sourceStandaloneTables = sourceNALayer as IStandaloneTableCollection;
						sourceStandaloneTable = null;
						sourceDisplayTable = null;

						count = 0;
						if (sourceStandaloneTables != null)
							count = sourceStandaloneTables.StandaloneTableCount;

						for (int i = 0; i < count; ++i)
						{
							sourceStandaloneTable = sourceStandaloneTables.get_StandaloneTable(i);
							sourceDisplayTable = sourceStandaloneTable as IDisplayTable;

							if ((sourceStandaloneTable != null) && (sourceDisplayTable != null))
							{
								// Add the table name to the combobox and the layer to the list
								cboInputData.Items.Add(sourceStandaloneTable.Name);
								m_listDisplayTable.Add(sourceDisplayTable);
							}
						}
					}

					sourceLayer = sourceLayers.Next();
				}
			}
		}
Ejemplo n.º 24
0
 public FrmExportRasterBatch(IMapControl3 pMapControl)
 {
     InitializeComponent();
     this.EnableGlass = false;
     m_pMapControl    = pMapControl;
 }
Ejemplo n.º 25
0
 public FrmSetAdjustData(IMapControl3 mapCtrl)
 {
     InitializeComponent();
     this.EnableGlass = false;
     m_mapCtl         = mapCtrl;
 }
 public FrmCenterLineWaijianceAlignment(IMapControl3 mapcontrol)
 {
     InitializeComponent();
     this.EnableGlass = false;
     pMapcontrol      = mapcontrol;
 }
Ejemplo n.º 27
0
 public override void OnCreate(object hook)
 {
     m_mapControl = (IMapControl3)hook;
 }
Ejemplo n.º 28
0
 public void MyClick(IMapControl3 ImapControl3)
 {
     this.OnCreate(ImapControl3);
     this.OnClick();
 }
Ejemplo n.º 29
0
 public frmSampleSummary()
 {
     InitializeComponent();
     _pMapControl = EnviVars.instance.MapControl;
     _pTOCControl = EnviVars.instance.TOCControl;
 }
Ejemplo n.º 30
0
        /// <summary>
        /// 导出为图片或PDF
        /// </summary>
        public static void ExportPicPdf(IMapControl3 m_MapControl)
        {
            SaveFileDialog savePrinterFileDialog = new SaveFileDialog();
            savePrinterFileDialog.Title = "打印成图片";
            savePrinterFileDialog.Filter = "BMP图片(*.bmp)|*.bmp|JPG图片(*.jpg)|*.jpg|PDF 文件(*.pdf)|*.pdf|PNG 图片(*.png)|*.png";
            if (savePrinterFileDialog.ShowDialog() == DialogResult.OK)
            {
                IActiveView activeView = m_MapControl.ActiveView;
                if (activeView == null)
                {
                    return;
                }

                IExport export = null;

                switch (savePrinterFileDialog.FilterIndex)
                {
                    case 1://bmp
                        export = new ExportBMP() as IExport;//输出BMP格式图片
                        export.ExportFileName = savePrinterFileDialog.FileName;
                        break;
                    case 2://jpg
                        export = new ExportJPEG() as IExport;//输出JPG格式图片
                        export.ExportFileName = savePrinterFileDialog.FileName;
                        break;
                    case 3://pdf
                        export = new ExportPDF() as IExport;//输出PDF格式文件
                        ((IExportPDF2)export).ExportMeasureInfo = true;
                        ((IExportPDF2)export).ExportPDFLayersAndFeatureAttributes = esriExportPDFLayerOptions.esriExportPDFLayerOptionsLayersAndFeatureAttributes;
                        export.ExportFileName = savePrinterFileDialog.FileName;
                        break;
                    case 4://png
                        export = new ExportPNG() as IExport;//输出PNG格式图片
                        export.ExportFileName = savePrinterFileDialog.FileName;
                        break;
                }

                if (export == null)
                {
                    MessageBox.Show(@"请选择输出路径。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                int ScreenResolution = 96;
                int OutputResolution = 300;
                export.Resolution = OutputResolution;

                tagRECT exportRECT;
                exportRECT.left = 0;
                exportRECT.top = 0;
                exportRECT.right = activeView.ExportFrame.right * (OutputResolution / ScreenResolution);
                exportRECT.bottom = activeView.ExportFrame.bottom * (OutputResolution / ScreenResolution);

                IEnvelope pixelBoundsEnv = new Envelope() as IEnvelope;
                pixelBoundsEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
                export.PixelBounds = pixelBoundsEnv;
                int hDC = export.StartExporting();
                activeView.Output(hDC, (int)export.Resolution, ref exportRECT, null, null);
                export.FinishExporting();
                export.Cleanup();
            }
        }
 public override void OnCreate(object hook)      //重写 OnCreate 事件响应函数
 {
     m_mapControl = (IMapControl3)hook;
 }
Ejemplo n.º 32
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            IMapControl3 mapControl = null;

            //get the MapControl from the hook in case the container is a ToolbarControl
            if (m_hookHelper.Hook is IToolbarControl)
            {
                mapControl = (IMapControl3)((IToolbarControl)m_hookHelper.Hook).Buddy;
            }
            //In case the container is MapControl
            else if (m_hookHelper.Hook is IMapControl3)
            {
                mapControl = (IMapControl3)m_hookHelper.Hook;
            }
            else
            {
                MessageBox.Show("Active control must be MapControl!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            //check to see if there is an active edit session and whether edits have been made
            DialogResult  result;
            IEngineEditor engineEditor = new EngineEditorClass();

            if ((engineEditor.EditState == esriEngineEditState.esriEngineStateEditing) && (engineEditor.HasEdits() == true))
            {
                result = MessageBox.Show("Would you like to save your edits", "Save Edits", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

                switch (result)
                {
                case DialogResult.Cancel:
                    return;

                case DialogResult.No:
                    engineEditor.StopEditing(false);
                    break;

                case DialogResult.Yes:
                    engineEditor.StopEditing(true);
                    break;
                }
            }

            //allow the user to save the current document
            DialogResult res = MessageBox.Show("Would you like to save the current document?", "AoView", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res == DialogResult.Yes)
            {
                //launch the save command
                ICommand command = new ControlsSaveAsDocCommandClass();
                command.OnCreate(m_hookHelper.Hook);
                command.OnClick();
            }

            //create a new Map
            IMap map = new MapClass();

            map.Name = "Map";

            //assign the new map to the MapControl
            mapControl.DocumentFilename = string.Empty;
            mapControl.Map = map;
        }
Ejemplo n.º 33
0
        private void EditorForm_Load(object sender, EventArgs e)
        {
            //*********  Important *************
            //Obtain a reference to the MainForm using the EditHelper class
            m_mainForm   = EditHelper.TheMainForm;
            m_mapControl = m_mainForm.MapControl;

            //buddy the toolbars with the MapControl
            axBlankToolBar.SetBuddyControl(m_mapControl);
            axModifyToolbar.SetBuddyControl(m_mapControl);
            axReshapeToolbar.SetBuddyControl(m_mapControl);
            axUndoRedoToolbar.SetBuddyControl(m_mapControl);
            axCreateToolbar.SetBuddyControl(m_mapControl);

            //Create and share command pool
            m_pool = new CommandPoolClass();
            axCreateToolbar.CommandPool   = m_pool;
            axBlankToolBar.CommandPool    = m_pool;
            axModifyToolbar.CommandPool   = m_pool;
            axReshapeToolbar.CommandPool  = m_pool;
            axUndoRedoToolbar.CommandPool = m_pool;

            //Create and share operation stack
            m_operationStack = new ControlsOperationStackClass();
            axModifyToolbar.OperationStack   = m_operationStack;
            axReshapeToolbar.OperationStack  = m_operationStack;
            axUndoRedoToolbar.OperationStack = m_operationStack;
            axCreateToolbar.OperationStack   = m_operationStack;

            //load items for the axModifyToolbar
            axModifyToolbar.AddItem("esriControls.ControlsEditingEditTool", 0, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axModifyToolbar.AddItem("VertexCommands_CS.CustomVertexCommands", 1, 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axModifyToolbar.AddItem("VertexCommands_CS.CustomVertexCommands", 2, 2, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //load items for the axReshapeToolbar
            axReshapeToolbar.AddItem("esriControls.ControlsEditingEditTool", 0, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axReshapeToolbar.AddItem("esriControls.ControlsEditingSketchTool", 0, 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //load items for the axCreateToolbar
            axCreateToolbar.AddItem("esriControls.ControlsEditingSketchTool", 0, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //set up the EngineEditor
            m_engineEditor = new EngineEditorClass();
            m_engineEditor.EnableUndoRedo(true);
            ((IEngineEditProperties2)m_engineEditor).StickyMoveTolerance = 10000;
            object     tbr             = (object)axCreateToolbar.Object;
            IExtension engineEditorExt = m_engineEditor as IExtension;

            engineEditorExt.Startup(ref tbr); //ensures that the operationStack will function correctly

            //Listen to OnSketchModified engine editor event
            ((IEngineEditEvents_Event)m_engineEditor).OnSketchModified += new IEngineEditEvents_OnSketchModifiedEventHandler(OnSketchModified);
            //listen to MainForm events in case application is closed while editing
            EditHelper.TheMainForm.FormClosing += new FormClosingEventHandler(TheMainForm_FormClosing);

            #region Form Management
            m_commands = new ArrayList();
            m_commands.Add(cmdModify);
            m_commands.Add(cmdReshape);
            m_commands.Add(cmdCreate);

            DisableButtons();
            txtInfo.Text         = "";
            this.Size            = new Size(242, 208);
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            SetErrorLabel("");
            EditHelper.IsEditorFormOpen = true;
            #endregion
        }
Ejemplo n.º 34
0
 /// <inheritdoc />
 public override void OnCreate(object hook)
 {
     mapControl = hook as IMapControl3;
 }
		public bool ShowModal(IMapControl3 mapControl, IEngineNetworkAnalystEnvironment naEnv)
		{
			// Initialize variables
			m_okClicked = false;
			m_listDisplayTable = new System.Collections.ArrayList();

			var activeCategory = naEnv.NAWindow.ActiveCategory as IEngineNAWindowCategory2;
			if (activeCategory == null)
				return false;

			IDataLayer dataLayer = activeCategory.DataLayer;
			if (dataLayer == null)
				return false;

			// Set up the title of this dialog
			String dataLayerName = GetDataLayerName(dataLayer);
			if (dataLayerName.Length == 0)
				return false;

			this.Text = "Load Items into " + dataLayerName;

			// Make sure the combo box lists only the appropriate possible input data layers
			PopulateInputDataComboBox(mapControl, dataLayer);

			//Select the first display table from the list
			if (cboInputData.Items.Count > 0)
				cboInputData.SelectedIndex = 0;

			// Show the window
			this.ShowDialog();

			// If we selected a layer and clicked OK, load the locations
			if (m_okClicked && (cboInputData.SelectedIndex >= 0))
			{
				try
				{
					// Get a cursor on the source display table (either though the selection set or table)
					// Use IDisplayTable because it accounts for joins, querydefs, etc.
					// IDisplayTable is implemented by FeatureLayers and StandaloneTables.
					//
					IDisplayTable displayTable = m_listDisplayTable[cboInputData.SelectedIndex] as IDisplayTable;
					ICursor cursor;
					if (chkUseSelection.Checked)
					{
						ISelectionSet selSet;
						selSet = displayTable.DisplaySelectionSet;
						selSet.Search(null, false, out cursor);
					}
					else
						cursor = displayTable.SearchDisplayTable(null, false);

					// Get the NAContext from the active analysis layer
					INAContext naContext = naEnv.NAWindow.ActiveAnalysis.Context;

					// Get the dataset for the active NAClass  
					IDataset naDataset = activeCategory.NAClass as IDataset;

					// Setup NAClassLoader and Load Locations
					INAClassLoader2 naClassLoader = new NAClassLoader() as INAClassLoader2;
					naClassLoader.Initialize(naContext, naDataset.Name, cursor);

					// Avoid loading network locations onto non-traversable portions of elements
					INALocator3 locator = naContext.Locator as INALocator3;
					locator.ExcludeRestrictedElements = true;
					locator.CacheRestrictedElements(naContext);

					int rowsIn = 0;
					int rowsLocated = 0;
					naClassLoader.Load(cursor, null, ref rowsIn, ref rowsLocated);

					// Let the user know if some of the rows failed to locate
					if (rowsIn != rowsLocated)
						MessageBox.Show("Out of " + rowsIn + " + rows, " + rowsLocated + " rows were located", 
										"Loading locations", MessageBoxButtons.OK, MessageBoxIcon.Information);
				}
				catch (Exception e)
				{
					MessageBox.Show(e.Message, "Loading locations failure", MessageBoxButtons.OK, MessageBoxIcon.Error );					
				}

				return true;
			}

			return false;
		}
Ejemplo n.º 36
0
        private void addItemToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IMapControl3 mapControl = (IMapControl3)axMapControl1.Object;

            IEngineNAWindowCategory2 activeCategory = m_naWindow.ActiveCategory as IEngineNAWindowCategory2;
            IDataLayer pDataLayer = activeCategory.DataLayer;

            // In order to add an item, we need to create a new row in the class and populate it
            // with the initial default values for that class.
            ITable       table       = pDataLayer as ITable;
            IRow         row         = table.CreateRow();
            IRowSubtypes rowSubtypes = row as IRowSubtypes;

            rowSubtypes.InitDefaultValues();

            IFeatureLayer    ipFeatureLayer    = activeCategory.Layer as IFeatureLayer;
            IStandaloneTable ipStandaloneTable = pDataLayer as IStandaloneTable;
            string           name = "";

            if (ipFeatureLayer != null)
            {
                name = ipFeatureLayer.DisplayField;
            }
            else if (ipStandaloneTable != null)
            {
                name = ipStandaloneTable.DisplayField;
            }

            string currentName = "";
            int    fieldIndex  = row.Fields.FindField(name);

            if (fieldIndex >= 0)
            {
                currentName = row.get_Value(fieldIndex) as string;
                if (currentName.Length <= 0)
                {
                    row.set_Value(fieldIndex, "Item" + ++autogenInt);
                }
            }

            INAClassDefinition naClassDef = activeCategory.NAClass.ClassDefinition;

            if (naClassDef.Name == "OrderPairs")
            {
                fieldIndex = row.Fields.FindField("SecondOrderName");
                if (fieldIndex >= 0)
                {
                    string secondName = row.get_Value(fieldIndex) as string;
                    if (secondName.Length <= 0)
                    {
                        row.set_Value(fieldIndex, "Item" + ++autogenInt);
                    }
                }
            }

            row.Store();

            // notify that the context has changed because we have added an item to a NAClass within it
            INAContextEdit contextEdit = m_naEnv.NAWindow.ActiveAnalysis.Context as INAContextEdit;

            contextEdit.ContextChanged();

            // refresh the NAWindow and the Screen
            INALayer naLayer = m_naWindow.ActiveAnalysis;

            mapControl.Refresh(esriViewDrawPhase.esriViewGeography, naLayer, mapControl.Extent);
            m_naWindow.UpdateContent(m_naWindow.ActiveCategory);
        }
Ejemplo n.º 37
0
 private static ILayer funReturnLayerByLayerName(IMapControl3 mainMap, string strLayerName)
 {
     ILayer pLayer = null;
     ILayer pL = null;
     for (int i = 0; i < mainMap.LayerCount; i++)
     {
         pL = mainMap.get_Layer(i);
         if (pL is IGroupLayer)
         {
             ICompositeLayer pGL = pL as ICompositeLayer;
             for (int j = 0; j < pGL.Count; j++)
             {
                 if (pGL.get_Layer(j).Name == strLayerName)
                 {
                     pLayer = pGL.get_Layer(j);
                 }
             }
         }
         if (pL.Name == strLayerName)
         {
             pLayer = pL;
         }
     }
     return pLayer;
 }
Ejemplo n.º 38
0
 private string m_DocPath          = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "data/doc.gdb"; //文档数据库路径
 /// <summary>
 /// 构造
 /// </summary>
 public AttributionQuery(IMapControl3 mapControl)
 {
     m_MapControl = mapControl;
 }
        /// <summary>
        /// ����¼�
        /// </summary>
        public override void OnClick()
        {
            m_pMapControl = DataEditCommon.g_pMyMapCtrl;

            DataEditCommon.InitEditEnvironment();
            DataEditCommon.CheckEditState();
            ///��ñ༭Ŀ��ͼ��
            m_pCurrentLayer = DataEditCommon.g_pLayer;
            IFeatureLayer featureLayer = m_pCurrentLayer as IFeatureLayer;
            if (featureLayer == null)
            {
                MessageBox.Show(@"��ѡ�����ͼ�㡣", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DataEditCommon.g_pMyMapCtrl.CurrentTool = null;
                return;
            }
            else
            {
                if (featureLayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolyline)
                {
                    MessageBox.Show(@"��ѡ����״ͼ�㡣", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    DataEditCommon.g_pMyMapCtrl.CurrentTool = null;
                    return;
                }
            }

            m_pMap = m_hookHelper.FocusMap;
            m_IsFirstPoint = true;
        }
Ejemplo n.º 40
0
 public EagleEyes(IHookHelper hook)
 {
     InitializeComponent();
     m_mapControl = (IMapControl3)hook.Hook;
     m_map        = m_mapControl.Map;
 }
 public void SetValues(IMapControl3 mapControl, DataInformation dataInfo)
 {
     m_mapControl = mapControl;
     m_dataInfo = dataInfo;
     AddLayerNames();
 }
Ejemplo n.º 42
0
        public bool ShowModal(IMapControl3 mapControl, IEngineNetworkAnalystEnvironment naEnv)
        {
            // Initialize variables
            m_okClicked = false;
            m_lstLayers = new System.Collections.ArrayList();
            this.Text   = "Load Locations into " + naEnv.NAWindow.ActiveCategory.Layer.Name;

            // Loop through all the layers, adding the point feature layers to the combo box and array
            IEnumLayer layers = mapControl.Map.get_Layers(null, true);
            ILayer     layer;

            layer = layers.Next();
            while (layer != null)
            {
                IFeatureLayer fLayer       = layer as IFeatureLayer;
                IDisplayTable displayTable = layer as IDisplayTable;

                if ((fLayer != null) && (displayTable != null))
                {
                    IFeatureClass fClass = fLayer.FeatureClass;
                    if (fClass.ShapeType == esriGeometryType.esriGeometryPoint)
                    {
                        // Add the layer name to the combobox and the layer to the list
                        cboPointLayers.Items.Add(layer.Name);
                        m_lstLayers.Add(layer);
                    }
                }
                layer = layers.Next();
            }
            //Select the first point feature layer from the list
            if (cboPointLayers.Items.Count > 0)
            {
                cboPointLayers.SelectedIndex = 0;
            }

            // Show the window
            this.ShowDialog();

            // If we selected a layer and clicked OK, load the locations
            if (m_okClicked && (cboPointLayers.SelectedIndex >= 0))
            {
                // Get the NALayer and NAContext
                INALayer   naLayer   = naEnv.NAWindow.ActiveAnalysis;
                INAContext naContext = naLayer.Context;

                //Get the active category
                IEngineNAWindowCategory activeCategory = naEnv.NAWindow.ActiveCategory;
                INAClass naClass   = activeCategory.NAClass;
                IDataset naDataset = naClass as IDataset;

                // Get a cursor to the input features (either though the selection set or table)
                // Use IDisplayTable because it accounts for joins, querydefs, etc.
                IDisplayTable displayTable = m_lstLayers[cboPointLayers.SelectedIndex] as IDisplayTable;
                ICursor       cursor;
                if (chkUseSelectedFeatures.Checked)
                {
                    ISelectionSet selSet;
                    selSet = displayTable.DisplaySelectionSet;
                    selSet.Search(null, false, out cursor);
                }
                else
                {
                    cursor = displayTable.SearchDisplayTable(null, false);
                }

                // Setup NAClassLoader and Load Locations
                INAClassLoader2 naClassLoader = new NAClassLoader() as INAClassLoader2;
                naClassLoader.Initialize(naContext, naDataset.Name, cursor);
                int rowsIn      = 0;
                int rowsLocated = 0;
                naClassLoader.Load(cursor, null, ref rowsIn, ref rowsLocated);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 43
0
        private void EditorForm_Load(object sender, EventArgs e)
        {
            //*********  Important *************
            //Obtain a reference to the MainForm using the EditHelper class
            m_mainForm = EditHelper.TheMainForm;
            m_mapControl = m_mainForm.MapControl;

            //buddy the toolbars with the MapControl
            axBlankToolBar.SetBuddyControl(m_mapControl);
            axModifyToolbar.SetBuddyControl(m_mapControl);
            axReshapeToolbar.SetBuddyControl(m_mapControl);
            axUndoRedoToolbar.SetBuddyControl(m_mapControl);
            axCreateToolbar.SetBuddyControl(m_mapControl);

            //Create and share command pool
            m_pool = new CommandPoolClass();
            axCreateToolbar.CommandPool = m_pool;
            axBlankToolBar.CommandPool = m_pool;
            axModifyToolbar.CommandPool = m_pool;
            axReshapeToolbar.CommandPool = m_pool;
            axUndoRedoToolbar.CommandPool = m_pool;

            //Create and share operation stack
            m_operationStack = new ControlsOperationStackClass();
            axModifyToolbar.OperationStack = m_operationStack;
            axReshapeToolbar.OperationStack = m_operationStack;
            axUndoRedoToolbar.OperationStack = m_operationStack;
            axCreateToolbar.OperationStack = m_operationStack;

            //load items for the axModifyToolbar
            axModifyToolbar.AddItem("esriControls.ControlsEditingEditTool", 0, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axModifyToolbar.AddItem("VertexCommands_CS.CustomVertexCommands", 1, 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axModifyToolbar.AddItem("VertexCommands_CS.CustomVertexCommands", 2, 2, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //load items for the axReshapeToolbar
            axReshapeToolbar.AddItem("esriControls.ControlsEditingEditTool", 0, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axReshapeToolbar.AddItem("esriControls.ControlsEditingSketchTool", 0, 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //load items for the axCreateToolbar
            axCreateToolbar.AddItem("esriControls.ControlsEditingSketchTool", 0, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //set up the EngineEditor
            m_engineEditor = new EngineEditorClass();
            m_engineEditor.EnableUndoRedo(true);
            ((IEngineEditProperties2)m_engineEditor).StickyMoveTolerance = 10000;
            object tbr = (object)axCreateToolbar.Object;
            IExtension engineEditorExt = m_engineEditor as IExtension;
            engineEditorExt.Startup(ref tbr); //ensures that the operationStack will function correctly

            //Listen to OnSketchModified engine editor event
            ((IEngineEditEvents_Event)m_engineEditor).OnSketchModified += new IEngineEditEvents_OnSketchModifiedEventHandler(OnSketchModified);
            //listen to MainForm events in case application is closed while editing
            EditHelper.TheMainForm.FormClosing += new FormClosingEventHandler(TheMainForm_FormClosing);

            #region Form Management
            m_commands = new ArrayList();
            m_commands.Add(cmdModify);
            m_commands.Add(cmdReshape);
            m_commands.Add(cmdCreate);

            DisableButtons();
            txtInfo.Text = "";
            this.Size = new Size(242, 208);
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            SetErrorLabel("");
            EditHelper.IsEditorFormOpen = true;
            #endregion
        }
Ejemplo n.º 44
0
 //构造函数
 public FormTable(AxMapControl pAxMapControl, IMapControl3 pMapCtrl)
 {
     InitializeComponent();
     axMapControl1  = pAxMapControl;
     maxMapControl1 = pMapCtrl;
 }
Ejemplo n.º 45
0
 void IGMap.SetHook(object hook)
 {
     this._hook = hook;
     this._mapHook = (IMapControl3)hook;
 }
Ejemplo n.º 46
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add CmdRasterRegister.OnClick implementation
            IMapControl3 pMapCtrl = null;

            if (m_hookHelper.Hook is IToolbarControl)
            {
                if (((IToolbarControl)m_hookHelper.Hook).Buddy is IMapControl3)
                {
                    pMapCtrl = (IMapControl3)((IToolbarControl)m_hookHelper.Hook).Buddy;
                }
            }
            //In case the container is MapControl
            else if (m_hookHelper.Hook is IMapControl3)
            {
                pMapCtrl = (IMapControl3)m_hookHelper.Hook;
            }
            else
            {
                return;
            }

            System.GC.Collect();
            FrmSiftMatching frmSiftMatching = new FrmSiftMatching(pMapCtrl, pRasterLayer);

            if (frmSiftMatching.ShowDialog() == DialogResult.OK)
            {
                ClsSiftMatching pSiftMatching = new ClsSiftMatching();
                double[]        dbMatchPts;
                int             nCount = 0;
                if (pSiftMatching.siftMatching(frmSiftMatching.m_pSiftMatchPara, out dbMatchPts, out nCount))
                {
                    IRaster2     pLeftRaster    = frmSiftMatching.m_pRasterLeft;
                    IRasterProps pLeftProps     = pLeftRaster as IRasterProps;
                    IPoint       pLeftLowerLeft = pLeftProps.Extent.LowerLeft;

                    IRaster2     pRightRaster    = frmSiftMatching.m_pRasterRight;
                    IRasterProps pRightProps     = pRightRaster as IRasterProps;
                    IPoint       pRightLowerLeft = pRightProps.Extent.LowerLeft;

                    //SIFT匹配出来的都是影像坐标,应该先转换成MAPCTRL单位为准
                    for (int i = 0; i < nCount; i++)
                    {
                        int x = (int)dbMatchPts[4 * i];
                        int y = (int)(dbMatchPts[4 * i + 1]);
                        //y = (int)(-1*dbMatchPts[4 * i + 1]);
                        pLeftRaster.PixelToMap(x, y, out dbMatchPts[4 * i], out dbMatchPts[4 * i + 1]);

                        x = (int)dbMatchPts[4 * i + 2];
                        y = (int)(dbMatchPts[4 * i + 3]);
                        //y = (int)(-1*dbMatchPts[4 * i + 3]);
                        pRightRaster.PixelToMap(x, y, out dbMatchPts[4 * i + 2], out dbMatchPts[4 * i + 3]);

                        #region 废弃代码
                        //int x = (int)dbMatchPts[4 * i];
                        //int y = (int)(dbMatchPts[4 * i + 1]);
                        //dbMatchPts[4 * i] = x * pLeftProps.MeanCellSize().X + pLeftLowerLeft.X;
                        //dbMatchPts[4 * i + 1] = y * pLeftProps.MeanCellSize().Y + pLeftLowerLeft.Y;

                        //x = (int)dbMatchPts[4 * i + 2];
                        //y = (int)(dbMatchPts[4 * i + 3]);
                        //dbMatchPts[4 * i + 2] = x * pRightProps.MeanCellSize().X + pRightLowerLeft.X;
                        //dbMatchPts[4 * i + 3] = y * pRightProps.MeanCellSize().Y + pRightLowerLeft.Y;
                        //IPoint ptFrom = pMapCtrl.ToMapPoint(Convert.ToInt32(dbMatchPts[4 * i + 0]), Convert.ToInt32(dbMatchPts[4 * i + 1]));
                        //IPoint ptTo = pMapCtrl.ToMapPoint(Convert.ToInt32(dbMatchPts[4 * i + 2]), Convert.ToInt32(dbMatchPts[4 * i + 3]));

                        //dbMatchPts[4 * i + 0] = ptFrom.X;
                        //dbMatchPts[4 * i + 1] = ptFrom.Y;
                        //dbMatchPts[4 * i + 2] = ptTo.X;
                        //dbMatchPts[4 * i + 3] = ptTo.Y;
                        #endregion
                    }
                    pSiftMatching.outputMatchPointsToFile("d:\\b.txt", dbMatchPts, nCount);

                    //添加到控制点中
                    m_FrmLink.DelAllPoints();
                    for (int i = 0; i < nCount; i++)
                    {
                        IPoint ptOrg = new ESRI.ArcGIS.Geometry.PointClass();
                        ptOrg.PutCoords(dbMatchPts[4 * i], dbMatchPts[4 * i + 1]);
                        m_FrmLink.OriginPoints.AddPoint(ptOrg);

                        IPoint ptTarget = new ESRI.ArcGIS.Geometry.PointClass();
                        ptTarget.PutCoords(dbMatchPts[4 * i + 2], dbMatchPts[4 * i + 3]);
                        m_FrmLink.TargetPoints.AddPoint(ptTarget);
                    }
                    m_FrmLink.RefreshControlAllPoints();
                    m_FrmLink.Show();
                    pMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                    //MessageBox.Show("匹配成功!");
                }
                else
                {
                    MessageBox.Show("匹配失败!");
                }

                //把临时创建的文件删除
                try
                {
                    string szLeftFilename  = frmSiftMatching.m_pSiftMatchPara.szLeftFilename;
                    string szRightFilename = frmSiftMatching.m_pSiftMatchPara.szRightFilename;
                    if (System.IO.File.Exists(szLeftFilename))
                    {
                        System.IO.File.Delete(szLeftFilename);
                    }

                    if (System.IO.File.Exists(szRightFilename))
                    {
                        System.IO.File.Delete(szRightFilename);
                    }
                }
                catch (System.Exception ex)
                {
                    return;
                }
            }
        }