private void barButtonItem101_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (this.mainMapControl.LayerCount > 0)
     {
         DialogResult result = MessageBox.Show("是否保存当前地图?", "警告", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
         if (result == DialogResult.Cancel)
         {
             return;
         }
         //if (result == DialogResult.Yes) this.btnSaveDoc_Click(null, null);
     }
     this.openFileDialog.Title            = "请选择地图文件";
     this.openFileDialog.Filter           = "MXD地图文件|*.mxd";
     this.openFileDialog.Multiselect      = false;
     this.openFileDialog.RestoreDirectory = true;
     if (this.openFileDialog.ShowDialog() == DialogResult.OK)
     {
         Application.DoEvents();
         string docName = this.openFileDialog.FileName;
         try
         {
             this.pMapDocument = new MapDocumentClass();
             if (pMapDocument.get_IsPresent(docName) && !pMapDocument.get_IsPasswordProtected(docName))
             {
                 pMapDocument.Open(docName, null);
                 IMap pMap = pMapDocument.get_Map(0);
                 m_controlsSynchronizer.ReplaceMap(pMap);
                 this.mainMapControl.DocumentFilename = docName;
                 this.Text = System.IO.Path.GetFileName(this.openFileDialog.FileName) + " - " + "LinGIS - LinInfo";
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         finally
         {
             System.Runtime.InteropServices.Marshal.ReleaseComObject(this.pMapDocument);
             Application.DoEvents();
             this.pMapDocument = null;
         }
     }
 }
Beispiel #2
0
        public MXD(string mxdPath)
        {
            path = mxdPath;
            // GUIDs finden: http://support.esri.com/index.cfm?fa=knowledgebase.techarticles.articleShow&d=31115
            LayerTypeUIDs[0] = "{EDAD6644-1810-11D1-86AE-0000F8751720}";
            LayerTypeUIDs[1] = "{5CEAE408-4C0A-437F-9DB3-054D83919850}";
            LayerTypeUIDs[2] = "{DBCA59AC-6771-4408-8F48-C7D53389440C}";
            LayerTypeUIDs[3] = "{D02371C7-35F7-11D2-B1F2-00C04F8EDEFF}";
            LayerTypeUIDs[4] = "{605BC37A-15E9-40A0-90FB-DE4CC376838C}";
            LayerTypeUIDs[5] = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}";
            LayerTypeUIDs[6] = "";

            if (InitializeLicense() == esriLicenseStatus.esriLicenseCheckedOut)
            {
                mapDoc = new MapDocumentClass();
                if (mapDoc.get_IsPresent(path))
                {
                    if (mapDoc.get_IsMapDocument(path))
                    {
                        mapDoc.Open(path, null);
                        if (mapDoc.DocumentType == esriMapDocumentType.esriMapDocumentTypeMxd)
                        {
                            activateMapDocument();

                            // alle Layer holen
                            layerList = getLayerList(null);

                            // alle GroupLayer holen
                            processLayer(LayerTypes.GroupLayer);

                            // alle AnnotationLayer holen
                            processLayer(LayerTypes.AnnotationLayer);

                            // alle AnnotationSubLayer holen
                            processLayer(LayerTypes.AnnotationSubLayer);

                            // alle RasterLayer holen
                            processLayer(LayerTypes.RasterLayer);

                            // alle RasterCatalogLayer holen
                            processLayer(LayerTypes.RasterCatalogLayer);

                            // alle FeatureLayer holen
                            processLayer(LayerTypes.FeatureLayer);

                            // übrige Layer holen
                            foreach (ILayer lyr in layerList)
                            {
                                if (!processedLayers.Contains(lyr))
                                {
                                    LayerInfo lyrInfo = new LayerInfo(mapDoc);
                                    lyrInfo.processOtherLayer(lyr);
                                    lyrInfos.Add(lyrInfo);
                                    processedLayers.Add(lyr);
                                }
                            }

                            // Resultate ausgeben
                            foreach (LayerInfo info in lyrInfos)
                            {
                                Console.WriteLine(info.writeCSV());
                            }

                            // Dokument schliessen
                            mapDoc.Close();

                        } else {
                            Console.Error.WriteLine("FEHLER: kein gültiges MXD-File");
                        }
                    } else {
                        Console.Error.WriteLine("FEHLER: kein gültiges MXD-File");
                    }
                } else {
                    Console.Error.WriteLine("FEHLER: Angegebenes File nicht gefunden");
                }

            } else
            {
                Console.Error.WriteLine("FEHLER: Keine ArcView-Lizenz verfügbar");
            }

            // Lizenz zurückgeben
            TerminateLicense();
        }
Beispiel #3
0
 private void btnOpenDoc_Click(object sender, EventArgs e)
 {
     if (this.mainMapControl.LayerCount > 0)
     {
         DialogResult result = MessageBox.Show("是否保存当前地图?", "警告", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
         if (result == DialogResult.Cancel) return;
         if (result == DialogResult.Yes) this.btnSaveDoc_Click(null, null);
     }
     this.openFileDialog.Title = "请选择地图文件";
     this.openFileDialog.Filter = "MXD地图文件|*.mxd";
     this.openFileDialog.Multiselect = false;
     this.openFileDialog.RestoreDirectory = true;
     if (this.openFileDialog.ShowDialog() == DialogResult.OK)
     {
         Application.DoEvents();
         string docName = this.openFileDialog.FileName;
         try
         {
             this.pMapDocument = new MapDocumentClass();
             if (pMapDocument.get_IsPresent(docName) && !pMapDocument.get_IsPasswordProtected(docName))
             {
                 pMapDocument.Open(docName, null);
                 IMap pMap = pMapDocument.get_Map(0);
                 m_controlsSynchronizer.ReplaceMap(pMap);
                 this.mainMapControl.DocumentFilename = docName;
                 this.Text = System.IO.Path.GetFileName(this.openFileDialog.FileName) + " - " + "LinGIS - LinInfo";
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         finally
         {
             System.Runtime.InteropServices.Marshal.ReleaseComObject(this.pMapDocument);
             Application.DoEvents();
             this.pMapDocument = null;
         }
     }
 }
Beispiel #4
0
        public MXD(string mxdPath)
        {
            path = mxdPath;
            // GUIDs finden: http://support.esri.com/index.cfm?fa=knowledgebase.techarticles.articleShow&d=31115
            LayerTypeUIDs[0] = "{EDAD6644-1810-11D1-86AE-0000F8751720}";
            LayerTypeUIDs[1] = "{5CEAE408-4C0A-437F-9DB3-054D83919850}";
            LayerTypeUIDs[2] = "{DBCA59AC-6771-4408-8F48-C7D53389440C}";
            LayerTypeUIDs[3] = "{D02371C7-35F7-11D2-B1F2-00C04F8EDEFF}";
            LayerTypeUIDs[4] = "{605BC37A-15E9-40A0-90FB-DE4CC376838C}";
            LayerTypeUIDs[5] = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}";
            LayerTypeUIDs[6] = "";

            if (InitializeLicense() == esriLicenseStatus.esriLicenseCheckedOut)
            {
                mapDoc = new MapDocumentClass();
                if (mapDoc.get_IsPresent(path))
                {
                    if (mapDoc.get_IsMapDocument(path))
                    {
                        mapDoc.Open(path, null);
                        if (mapDoc.DocumentType == esriMapDocumentType.esriMapDocumentTypeMxd)
                        {
                            activateMapDocument();

                            // alle Layer holen
                            layerList = getLayerList(null);

                            // alle GroupLayer holen
                            processLayer(LayerTypes.GroupLayer);

                            // alle AnnotationLayer holen
                            processLayer(LayerTypes.AnnotationLayer);

                            // alle AnnotationSubLayer holen
                            processLayer(LayerTypes.AnnotationSubLayer);

                            // alle RasterLayer holen
                            processLayer(LayerTypes.RasterLayer);

                            // alle RasterCatalogLayer holen
                            processLayer(LayerTypes.RasterCatalogLayer);

                            // alle FeatureLayer holen
                            processLayer(LayerTypes.FeatureLayer);

                            // übrige Layer holen
                            foreach (ILayer lyr in layerList)
                            {
                                if (!processedLayers.Contains(lyr))
                                {
                                    LayerInfo lyrInfo = new LayerInfo(mapDoc);
                                    lyrInfo.processOtherLayer(lyr);
                                    lyrInfos.Add(lyrInfo);
                                    processedLayers.Add(lyr);
                                }
                            }

                            // Resultate ausgeben
                            foreach (LayerInfo info in lyrInfos)
                            {
                                Console.WriteLine(info.writeCSV());
                            }

                            // Dokument schliessen
                            mapDoc.Close();
                        }
                        else
                        {
                            Console.Error.WriteLine("FEHLER: kein gültiges MXD-File");
                        }
                    }
                    else
                    {
                        Console.Error.WriteLine("FEHLER: kein gültiges MXD-File");
                    }
                }
                else
                {
                    Console.Error.WriteLine("FEHLER: Angegebenes File nicht gefunden");
                }
            }
            else
            {
                Console.Error.WriteLine("FEHLER: Keine ArcView-Lizenz verfügbar");
            }

            // Lizenz zurückgeben
            TerminateLicense();
        }