/// <summary>
        /// Method to set the map tool as the active tool for the map
        /// </summary>
        /// <param name="application"></param>
        /// <param name="toolName"></param>
        public void SetToolActiveInToolBar(string toolName)
        {
            if (ArcMap.Application == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(toolName))
            {
                if (ArcMap.Application.CurrentTool != null) // TRICKY: setting current tool to null at startup causes crash so extra check
                {
                    ArcMap.Application.CurrentTool = null;
                }

                return;
            }

            if ((ArcMap.Application.CurrentTool != null) &&
                (ArcMap.Application.CurrentTool.Name.Equals(toolName)))
            {
                // Tricky: Check if tool already active - because setting CurrentTool again will
                //         cause Activate/Deactive to be called by ArcGIS framework
                return;
            }

            ESRI.ArcGIS.Framework.ICommandBars commandBars = ArcMap.Application.Document.CommandBars;
            ESRI.ArcGIS.esriSystem.UID         commandID   = new ESRI.ArcGIS.esriSystem.UIDClass();
            commandID.Value = toolName;
            ESRI.ArcGIS.Framework.ICommandItem commandItem = commandBars.Find(commandID, false, false);

            if (commandItem != null)
            {
                ArcMap.Application.CurrentTool = commandItem;
            }
        }
        public void getXYasValidAdres(Double X, Double Y)
        {
            if (csvDataGrid.RowCount == 0)
            {
                return;
            }

            foreach (DataGridViewRow row in csvDataGrid.SelectedRows)
            {
                DataGridViewComboBoxCell validCel = (DataGridViewComboBoxCell)row.Cells["validAdres"];
                validCel.Items.Clear();
                validCel.Items.Add(string.Format(CultureInfo.InvariantCulture, "{0:F0}|{1:F0}", X, Y));
                validCel.Value = validCel.Items[0];

                Color clr = ColorTranslator.FromHtml("#F1F8E0");
                foreach (DataGridViewCell cel in row.Cells)
                {
                    cel.Style.BackColor = clr;
                }
            }

            if (oldCmd != null)
            {
                ArcMap.Application.CurrentTool = oldCmd;
                oldCmd = null;
            }
            this.WindowState = FormWindowState.Normal;
            this.Focus();
        }
        private void manualLocBtn_Click(object sender, EventArgs e)
        {
            if (mouseCmd == null || csvDataGrid.SelectedRows.Count == 0)
            {
                return;
            }

            oldCmd = ArcMap.Application.CurrentTool;
            ArcMap.Application.CurrentTool = mouseCmd;
        }
Exemple #4
0
        public void SetToolActiveInToolBar(ESRI.ArcGIS.Framework.IApplication application, System.String toolName)
        {
            ESRI.ArcGIS.Framework.ICommandBars commandBars = application.Document.CommandBars;
            ESRI.ArcGIS.esriSystem.UID         commandID   = new ESRI.ArcGIS.esriSystem.UIDClass();
            commandID.Value = toolName; // example: "esriArcMapUI.ZoomInTool";
            ESRI.ArcGIS.Framework.ICommandItem commandItem = commandBars.Find(commandID, false, false);

            if (commandItem != null)
            {
                application.CurrentTool = commandItem;
            }
        }
        private void initGui()
        {
            sepCbx.SelectedIndex = 0;
            sepator = sepCbx.Text;
            encodingCbx.SelectedIndex = 0;

            ESRI.ArcGIS.Framework.ICommandBars commandBars = ArcMap.Application.Document.CommandBars;
            UID toolID = new UIDClass();

            toolID.Value = ThisAddIn.IDs.geopuntBatchGeocodingTool;
            mouseCmd     = commandBars.Find(toolID, false, false);
        }
Exemple #6
0
        private void drawbtn_Click(object sender, EventArgs e)
        {
            if (mouseCmd == null)
            {
                return;
            }

            this.WindowState = FormWindowState.Minimized;

            oldCmd = ArcMap.Application.CurrentTool;
            ArcMap.Application.CurrentTool = mouseCmd;
        }
 protected override void  OnClosing(CancelEventArgs e)
 {
     if (validationWorker.IsBusy)
     {
         validationWorker.CancelAsync();
     }
     clearGraphics();
     if (oldCmd != null)
     {
         ArcMap.Application.CurrentTool = oldCmd;
         oldCmd = null;
     }
     gpExtension.batchGeocodeDlg = null;
     base.OnClosing(e);
 }
Exemple #8
0
        protected override void OnClick()
        {
            bool       Enable     = false;
            IEnumLayer pEnumLayer = ArcMap.Document.FocusMap.get_Layers(null, false);
            ILayer     pLayer     = pEnumLayer.Next();

            //string a = pLayer.Name.Substring(pLayer.Name.LastIndexOf('_') + 1);
            while (null != pLayer)
            {
                if ("TopoCheck" == pLayer.Name.Substring(pLayer.Name.LastIndexOf('_') + 1))
                {
                    Enable = true;
                    break;
                }
                pLayer = pEnumLayer.Next();
            }
            if (null == pLayer)
            {
                Enable = false;
            }
            if (!Enable)
            {
                return;
            }

            ESRI.ArcGIS.Framework.ICommandBars CommandBars = ArcMap.Application.Document.CommandBars;
            UID uid = new UIDClass();

            uid.Value = "esriEditor.StartEditingCommand";
            ESRI.ArcGIS.Framework.ICommandItem CommandItem = CommandBars.Find(uid, false, false);
            try
            {
                if (CommandItem != null)
                {
                    CommandItem.Execute();
                }

                uid.Value   = "esriEditorExt.ErrorWindowCommand";
                CommandItem = CommandBars.Find(uid, false, false);
                if (CommandItem != null)
                {
                    CommandItem.Execute();
                }
            }
            catch
            {
            }
        }
        /// <summary>
        /// Execute the Selection Tool
        /// </summary>
        public void ExecuteSelectionTool()
        {
            ESRI.ArcGIS.Framework.IApplication app = this.Hook as ESRI.ArcGIS.Framework.IApplication;

            // TODO: Handle Engine where the hook is a mapcontrol or toolbar control
            if (null != app)
            {
                ESRI.ArcGIS.esriSystem.UID uid = new ESRI.ArcGIS.esriSystem.UID();
                uid.Value = "esriControls.SelectFeaturesTool";

                ESRI.ArcGIS.Framework.ICommandItem selectCommand = app.Document.CommandBars.Find(uid, false, false);
                if (null != selectCommand)
                {
                    selectCommand.Execute();
                }
            }
        }
        public elevationForm()
        {
            //set global objects
            view = ArcMap.Document.ActiveView;
            map = view.FocusMap;

            lam72 = geopuntHelper.lam72;

            gpExtension = geopunt4arcgisExtension.getGeopuntExtension();
            lineFC = gpExtension.profileLineLayer;
            pointsFC = gpExtension.profilePointsLayer;
            dhm = new dataHandler.dhm(timeout: gpExtension.timeout);

            ESRI.ArcGIS.Framework.ICommandBars commandBars = ArcMap.Application.Document.CommandBars;
            UID toolID = new UIDClass();
            toolID.Value = ThisAddIn.IDs.geopuntElevationTool;
            mouseCmd = commandBars.Find(toolID, false, false);

            InitializeComponent();
            initGui();
        }
Exemple #11
0
        public elevationForm()
        {
            //set global objects
            view = ArcMap.Document.ActiveView;
            map  = view.FocusMap;

            lam72 = geopuntHelper.lam72;

            gpExtension = geopunt4arcgisExtension.getGeopuntExtension();
            lineFC      = gpExtension.profileLineLayer;
            pointsFC    = gpExtension.profilePointsLayer;
            dhm         = new dataHandler.dhm(timeout: gpExtension.timeout);

            ESRI.ArcGIS.Framework.ICommandBars commandBars = ArcMap.Application.Document.CommandBars;
            UID toolID = new UIDClass();

            toolID.Value = ThisAddIn.IDs.geopuntElevationTool;
            mouseCmd     = commandBars.Find(toolID, false, false);

            InitializeComponent();
            initGui();
        }
        protected override void OnClosed(EventArgs e)
        {
            if (adresLocation.client.IsBusy)
            {
                adresLocation.client.CancelAsync();
            }
            gpExtension.reverseDlg = null;

            ESRI.ArcGIS.Framework.ICommandBars commandBars = ArcMap.Application.Document.CommandBars;
            UID toolID = new UIDClass();

            toolID.Value = "esriArcMapUI.SelectTool"; // example: "esriArcMapUI.ZoomInTool";
            ESRI.ArcGIS.Framework.ICommandItem commandItem = commandBars.Find(toolID, false, false);

            if (commandItem != null)
            {
                ArcMap.Application.CurrentTool = commandItem;
            }

            clearGraphics();
            view.Refresh();
            base.OnClosed(e);
        }
        private void drawbtn_Click(object sender, EventArgs e)
        {
            if (mouseCmd == null)  return;

            this.WindowState = FormWindowState.Minimized;

            oldCmd = ArcMap.Application.CurrentTool;
            ArcMap.Application.CurrentTool = mouseCmd;
        }
        private void initGui()
        {
            sepCbx.SelectedIndex = 0;
            sepator = sepCbx.Text;
            encodingCbx.SelectedIndex = 0;

            ESRI.ArcGIS.Framework.ICommandBars commandBars = ArcMap.Application.Document.CommandBars;
            UID toolID = new UIDClass();
            toolID.Value = ThisAddIn.IDs.geopuntBatchGeocodingTool;
            mouseCmd = commandBars.Find(toolID, false, false);
        }
        public void getXYasValidAdres(Double X, Double Y)
        {
            if (csvDataGrid.RowCount == 0) return;

            foreach (DataGridViewRow row in csvDataGrid.SelectedRows)
            {
                DataGridViewComboBoxCell validCel = (DataGridViewComboBoxCell) row.Cells["validAdres"];
                validCel.Items.Clear();
                validCel.Items.Add(string.Format(CultureInfo.InvariantCulture, "{0:F0}|{1:F0}", X, Y));
                validCel.Value = validCel.Items[0];

                Color clr = ColorTranslator.FromHtml("#F1F8E0");
                foreach (DataGridViewCell cel in row.Cells)
                {
                    cel.Style.BackColor = clr;
                }
            }

            if (oldCmd != null)
            {
                ArcMap.Application.CurrentTool = oldCmd;
                oldCmd = null;
            }
            this.WindowState = FormWindowState.Normal;
            this.Focus();
        }
        private void manualLocBtn_Click(object sender, EventArgs e)
        {
            if (mouseCmd == null || csvDataGrid.SelectedRows.Count == 0)
                return;

            oldCmd = ArcMap.Application.CurrentTool;
            ArcMap.Application.CurrentTool = mouseCmd;
        }
Exemple #17
0
        protected override void OnClick()
        {
            IEnumLayer   EnumLayer    = ArcMap.Document.FocusMap.get_Layers(null, false);
            ILayer       pLayer       = EnumLayer.Next();
            ProgressForm progressForm = new ProgressForm();

            progressForm.Show();


            while (null != pLayer)
            {
                //string b = pLayer.Name.Substring(pLayer.Name.LastIndexOf('_') + 1);
                if ("Point" == pLayer.Name.Substring(pLayer.Name.LastIndexOf('_') + 1) ||
                    "Line" == pLayer.Name.Substring(pLayer.Name.LastIndexOf('_') + 1) ||
                    "Polygon" == pLayer.Name.Substring(pLayer.Name.LastIndexOf('_') + 1)
                    )
                {
                    break;
                }
                pLayer = EnumLayer.Next();
            }//加入的图层中至少有点线面中的一个,点线面图层中有DWG字段,表明了shp的来源

            progressForm.AddProgress(10);
            IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
            IFeature      pfeature      = pFeatureLayer.Search(null, false).NextFeature();

            IDataLayer   DataLayer       = pLayer as IDataLayer;
            IDatasetName tem_DatasetName = DataLayer.DataSourceName as IDatasetName;

            string PathName = tem_DatasetName.WorkspaceName.PathName;

            string DatasetName  = pfeature.get_Value(pfeature.Fields.FindField("DWG")) as string;//获取生成shp的DWG文件名称
            string MDB_FullName = PathName;

            //*******************************************开 始 拓 扑 检 查*****************************************************
            IWorkspaceFactory iwsf             = new AccessWorkspaceFactoryClass();
            IFeatureWorkspace ifws             = (IFeatureWorkspace)iwsf.OpenFromFile(MDB_FullName, 0);
            IFeatureDataset   topocheckDataset = ifws.OpenFeatureDataset(DatasetName);

            IFeatureClassContainer MyFeatureClassContainer = topocheckDataset as IFeatureClassContainer;


#if true
            TopologyChecker topocheck = new TopologyChecker(topocheckDataset);
            topocheck.PUB_TopoBuild(DatasetName + "_TopoCheck");//创建拓扑层
            progressForm.AddProgress(20);

            List <IFeatureClass> allFeatureClass_tem = topocheck.PUB_GetAllFeatureClass();
            //List<IFeatureClass> TopoClass;
            List <IFeatureClass> allFeatureClass = new List <IFeatureClass>();

            IFeatureClass topocheckFeatureClass_Point   = null;
            IFeatureClass topocheckFeatureClass_Line    = null;
            IFeatureClass topocheckFeatureClass_Polygon = null;

            foreach (IFeatureClass tem in allFeatureClass_tem)
            {
                switch (tem.AliasName.Substring(tem.AliasName.LastIndexOf('_') + 1))
                {
                case "Point":
                    allFeatureClass.Add(tem);
                    topocheckFeatureClass_Point = tem;
                    break;

                case "Line":
                    allFeatureClass.Add(tem);
                    topocheckFeatureClass_Line = tem;
                    break;

                case "Polygon":
                    allFeatureClass.Add(tem);
                    topocheckFeatureClass_Polygon = tem;
                    break;

                default:

                    break;
                }
            }//只对点线面图层进行拓扑检查

            topocheck.PUB_AddFeatureClass(allFeatureClass);
            progressForm.AddProgress(10);

            List <string> ErrorInfo = null;
            topocheck.PUB_AddRuleToTopology(TopologyChecker.TopoErroType.线要素不能自相交, topocheckFeatureClass_Line, out ErrorInfo);
            progressForm.AddProgress(10);
            topocheck.PUB_AddRuleToTopology(TopologyChecker.TopoErroType.线要素之间不能相交, topocheckFeatureClass_Line, out ErrorInfo);
            progressForm.AddProgress(10);
            topocheck.PUB_AddRuleToTopology(TopologyChecker.TopoErroType.点要素之间不相交, topocheckFeatureClass_Point, out ErrorInfo);
            progressForm.AddProgress(10);
            topocheck.PUB_AddRuleToTopology(TopologyChecker.TopoErroType.面要素间无重叠, topocheckFeatureClass_Polygon, out ErrorInfo);
            progressForm.AddProgress(10);
            System.IO.File.WriteAllLines(MDB_FullName.Substring(0, MDB_FullName.LastIndexOf('\\')) + "\\拓扑错误报告.txt", ErrorInfo.ToArray());
            //生成检查报告
            progressForm.AddProgress(10);

            //----------------------------------------------打 开 错 误 报 告 器------------------------------------------------------
            EnumLayer = ArcMap.Document.FocusMap.get_Layers(null, false);

            ArcMap.Document.FocusMap.ClearLayers();
            ArcMap.Document.FocusMap.AddLayers(EnumLayer, true);
            pLayer = EnumLayer.Next();

            while (null != pLayer)
            {
                if ((DatasetName + "_Polygon") == pLayer.Name)
                {
                    pLayer = EnumLayer.Next();
                    continue;
                }
                DirectRender(pLayer);
                pLayer = EnumLayer.Next();
            }

            ESRI.ArcGIS.Framework.ICommandBars CommandBars = ArcMap.Application.Document.CommandBars;
            UID uid = new UIDClass();
            uid.Value = "esriEditor.StartEditingCommand";
            //bool isEditable = true;
            try
            {
                ESRI.ArcGIS.Framework.ICommandItem CommandItem = CommandBars.Find(uid, false, false);
                if (CommandItem != null)
                {
                    CommandItem.Execute();
                }

                uid.Value   = "esriEditorExt.ErrorWindowCommand";
                CommandItem = CommandBars.Find(uid, false, false);
                if (CommandItem != null)
                {
                    CommandItem.Execute();
                }
            }
            catch
            {
                //isEditable = false;//如果初次打开出现不可编辑的错误,下面将尝试重新添加图层并打开错误编辑器
            }

            /*
             * if (!isEditable)
             * {
             *  try
             *  {
             *      ESRI.ArcGIS.Framework.ICommandItem CommandItem = CommandBars.Find(uid, false, false);
             *      if (CommandItem != null)
             *      {
             *          CommandItem.Execute();
             *      }
             *
             *      uid.Value = "esriEditorExt.ErrorWindowCommand";
             *      CommandItem = CommandBars.Find(uid, false, false);
             *      if (CommandItem != null)
             *      {
             *          CommandItem.Execute();
             *      }
             *
             *  }catch{}
             *
             *
             * }*/
            //------------------------------------------完成打开错误报告器---------------------------------------------
            progressForm.Close();
#endif
        }
 protected override void OnClosing(CancelEventArgs e)
 {
     if (validationWorker.IsBusy)
     {
         validationWorker.CancelAsync();
     }
     clearGraphics();
     if (oldCmd != null)
     {
         ArcMap.Application.CurrentTool = oldCmd;
         oldCmd = null;
     }
     gpExtension.batchGeocodeDlg = null;
     base.OnClosing(e);
 }