Exemple #1
0
        public static Dictionary <string, IFeatureClass> ReadE00Folder(string sPath)
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(sPath);

            FileInfo[] files = directoryInfo.GetFiles("*.e00");
            Dictionary <string, IFeatureClass> result;

            if (files == null || files.Length == 0)
            {
                result = null;
            }
            else
            {
                string     coverageDir = ControlAPI.GetCoverageDir();
                FileInfo[] array       = files;
                for (int i = 0; i < array.Length; i++)
                {
                    FileInfo fileInfo = array[i];
                    EngineAPI.E00ToCoverage(fileInfo.FullName, coverageDir);
                }
                IWorkspace workspace = EngineAPI.OpenWorkspace(coverageDir, DataType.coverage);
                if (workspace == null)
                {
                    result = null;
                }
                else
                {
                    result = ControlAPI.ReadCoverage(workspace);
                }
            }
            return(result);
        }
Exemple #2
0
        public static bool IsExistGDB(string sOutputPath, IEnumerable <string> names, DataType type = DataType.gdb)
        {
            bool          flag          = false;
            string        str           = "";
            DirectoryInfo directoryInfo = new DirectoryInfo(sOutputPath);

            if (type == DataType.gdb)
            {
                DirectoryInfo[] directories = directoryInfo.GetDirectories("*.gdb");
                DirectoryInfo[] array       = directories;
                for (int i = 0; i < array.Length; i++)
                {
                    DirectoryInfo directoryInfo2 = array[i];
                    ControlAPI.GetSameNames(directoryInfo2.Name, names, ref flag, ref str);
                }
            }
            else if (type == DataType.mdb)
            {
                FileInfo[] files  = directoryInfo.GetFiles("*.mdb");
                FileInfo[] array2 = files;
                for (int i = 0; i < array2.Length; i++)
                {
                    FileInfo fileInfo = array2[i];
                    ControlAPI.GetSameNames(fileInfo.Name, names, ref flag, ref str);
                }
            }
            if (flag)
            {
                XtraMessageBox.Show("输出目录中“" + str + "”已经存在!\r\n请重新指定输出目录!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            return(flag);
        }
Exemple #3
0
 public static void AddFeatureClassToListBox(IWorkspace pWorkspace, ImageListBoxControl imageListBoxControl1, DataType dataType, esriGeometryType geometryType)
 {
     if (pWorkspace != null)
     {
         IEnumDatasetName pEnumDatasetName = pWorkspace.get_DatasetNames(esriDatasetType.esriDTFeatureClass);
         ControlAPI.AddFeatureClassToListBox(pEnumDatasetName, imageListBoxControl1, dataType, geometryType);
     }
 }
Exemple #4
0
        public static Dictionary <string, IFeatureClass> ReadCoverage(IWorkspace pWorkspace)
        {
            Dictionary <string, IFeatureClass> dictionary = new Dictionary <string, IFeatureClass>();

            try
            {
                IEnumDataset enumDataset = pWorkspace.get_Datasets(esriDatasetType.esriDTFeatureDataset);
                try
                {
                    enumDataset.Reset();
                    IDataset dataset;
                    while ((dataset = enumDataset.Next()) != null)
                    {
                        string       sPrefix = dataset.Name + "_";
                        IEnumDataset subsets = dataset.Subsets;
                        try
                        {
                            subsets.Reset();
                            IDataset dataset2;
                            while ((dataset2 = subsets.Next()) != null)
                            {
                                IFeatureClass featureClass = dataset2 as IFeatureClass;
                                if (featureClass != null)
                                {
                                    string covOrCadFCName = ControlAPI.GetCovOrCadFCName(sPrefix, dataset2.Name);
                                    if (!(covOrCadFCName == ""))
                                    {
                                        dictionary.Add(covOrCadFCName, featureClass);
                                    }
                                }
                            }
                        }
                        finally
                        {
                            if (subsets != null)
                            {
                                Marshal.ReleaseComObject(subsets);
                            }
                        }
                    }
                }
                finally
                {
                    if (enumDataset != null)
                    {
                        Marshal.ReleaseComObject(enumDataset);
                    }
                }
            }
            finally
            {
                if (pWorkspace != null)
                {
                    Marshal.ReleaseComObject(pWorkspace);
                }
            }
            return(dictionary);
        }
Exemple #5
0
 public static void ListShpFiles(string sPath, ImageListBoxControl imageListBoxControl1, List <WorkspaceInfo> pWorkspaceList, esriGeometryType geometryType)
 {
     string[] files = Directory.GetFiles(sPath, "*.shp");
     if (files != null && files.Length != 0)
     {
         IWorkspace workspace = ControlAPI.GetWorkspace(sPath, DataType.shp, pWorkspaceList);
         ControlAPI.AddFeatureClassToListBox(workspace, imageListBoxControl1, DataType.shp, geometryType);
     }
 }
Exemple #6
0
 public static void AddFeatureDatasetToListBox(IWorkspace pWorkspace, ImageListBoxControl imageListBoxControl1, DataType type)
 {
     if (pWorkspace != null)
     {
         List <string>    list            = new List <string>();
         IEnumDatasetName enumDatasetName = pWorkspace.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
         try
         {
             enumDatasetName.Reset();
             IDatasetName datasetName;
             while ((datasetName = enumDatasetName.Next()) != null)
             {
                 list.Add(datasetName.Name);
             }
         }
         finally
         {
             if (enumDatasetName != null)
             {
                 Marshal.ReleaseComObject(enumDatasetName);
             }
         }
         list.Sort();
         IconType iconType = IconType.FGDBDataset;
         if (type <= DataType.sde)
         {
             if (type != DataType.mdb)
             {
                 if (type == DataType.sde)
                 {
                     iconType = IconType.SDEDataset;
                 }
             }
             else
             {
                 iconType = IconType.PGDBDataset;
             }
         }
         else if (type != DataType.cad)
         {
             if (type == DataType.coverage)
             {
                 iconType = IconType.Coverage;
             }
         }
         else
         {
             iconType = IconType.Cad;
         }
         foreach (string current in list)
         {
             ControlAPI.AddItemToListBox(iconType, current, imageListBoxControl1);
         }
     }
 }
Exemple #7
0
        public static IWorkspace GetWorkspace(string sFilePath, DataType type, List <WorkspaceInfo> pWorkspaceList)
        {
            IWorkspace workspace = ControlAPI.GetOpenedWorkspace(sFilePath, type, pWorkspaceList);

            if (workspace == null)
            {
                workspace = EngineAPI.OpenWorkspace(sFilePath, type);
                if (workspace != null)
                {
                    ControlAPI.AddWorkspaceInfo(sFilePath, type, workspace, pWorkspaceList);
                }
            }
            return(workspace);
        }
Exemple #8
0
        public static void InsertItemToComboBox(IconType iconType, string sValue, string sDesc, ImageComboBoxEdit cmbPath)
        {
            for (int i = cmbPath.Properties.Items.Count - 1; i > cmbPath.SelectedIndex; i--)
            {
                ImageComboBoxItem imageComboBoxItem = cmbPath.Properties.Items[i];
                if (imageComboBoxItem.ImageIndex != 2 && imageComboBoxItem.ImageIndex != 33)
                {
                    cmbPath.Properties.Items.RemoveAt(i);
                }
            }
            ImageComboBoxItem selectedItem = ControlAPI.InsertItemToComboBox(iconType, sValue, sDesc, cmbPath, cmbPath.SelectedIndex + 1);

            cmbPath.SelectedItem = selectedItem;
        }
Exemple #9
0
        public static void ListE00Files(string sPath, ImageListBoxControl imageListBoxControl1)
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(sPath);

            FileInfo[] files = directoryInfo.GetFiles("*.e00");
            if (files != null && files.Length != 0)
            {
                FileInfo[] array = files;
                for (int i = 0; i < array.Length; i++)
                {
                    FileInfo fileInfo = array[i];
                    if (!fileInfo.FullName.Contains(' '))
                    {
                        ControlAPI.AddItemToListBox(IconType.E00, fileInfo.Name, imageListBoxControl1);
                    }
                }
            }
        }
Exemple #10
0
        public static void AddFeatureClassToListBox(IEnumDatasetName pEnumDatasetName, ImageListBoxControl imageListBoxControl1, DataType dataType, esriGeometryType geometryType)
        {
            if (pEnumDatasetName != null)
            {
                IconType value  = IconType.PGDBAnnotation;
                IconType value2 = IconType.PGDBPoint;
                IconType value3 = IconType.PGDBLine;
                IconType value4 = IconType.PGDBPolygon;
                if (dataType <= DataType.gdb)
                {
                    if (dataType != DataType.shp)
                    {
                        if (dataType == DataType.gdb)
                        {
                            value  = IconType.FGDBAnnotation;
                            value2 = IconType.FGDBPoint;
                            value3 = IconType.FGDBLine;
                            value4 = IconType.FGDBPolygon;
                        }
                    }
                    else
                    {
                        value2 = IconType.ShpPoint;
                        value3 = IconType.ShpLine;
                        value4 = IconType.ShpPolygon;
                    }
                }
                else if (dataType != DataType.sde)
                {
                    if (dataType != DataType.cad)
                    {
                        if (dataType == DataType.coverage)
                        {
                            value  = IconType.CovAnnotation;
                            value2 = IconType.CovPoint;
                            value3 = IconType.CovArc;
                            value4 = IconType.CovPolygon;
                        }
                    }
                    else
                    {
                        value  = IconType.CadAnnotation;
                        value2 = IconType.CadPoint;
                        value3 = IconType.CadLine;
                        value4 = IconType.CadPolygon;
                    }
                }
                else
                {
                    value  = IconType.SDEAnnotation;
                    value2 = IconType.SDEPoint;
                    value3 = IconType.SDELine;
                    value4 = IconType.SDEPolygon;
                }
                SortedDictionary <string, IconType> sortedDictionary = new SortedDictionary <string, IconType>();
                try
                {
                    pEnumDatasetName.Reset();
                    IDatasetName datasetName;
                    while ((datasetName = pEnumDatasetName.Next()) != null)
                    {
                        IFeatureClassName featureClassName = datasetName as IFeatureClassName;
                        if (featureClassName != null)
                        {
                            if (geometryType == esriGeometryType.esriGeometryAny || geometryType == featureClassName.ShapeType)
                            {
                                if (featureClassName.FeatureType == esriFeatureType.esriFTAnnotation || featureClassName.FeatureType == esriFeatureType.esriFTCoverageAnnotation)
                                {
                                    sortedDictionary.Add(datasetName.Name, value);
                                }
                                else if (featureClassName.FeatureType == esriFeatureType.esriFTSimple)
                                {
                                    switch (featureClassName.ShapeType)
                                    {
                                    case esriGeometryType.esriGeometryPoint:
                                    case esriGeometryType.esriGeometryMultipoint:
                                        sortedDictionary.Add(datasetName.Name, value2);
                                        break;

                                    case esriGeometryType.esriGeometryPolyline:
                                        sortedDictionary.Add(datasetName.Name, value3);
                                        break;

                                    case esriGeometryType.esriGeometryPolygon:
                                        sortedDictionary.Add(datasetName.Name, value4);
                                        break;

                                    case esriGeometryType.esriGeometryMultiPatch:
                                        sortedDictionary.Add(datasetName.Name, IconType.CadMultiPatch);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                finally
                {
                    if (pEnumDatasetName != null)
                    {
                        Marshal.ReleaseComObject(pEnumDatasetName);
                    }
                }
                foreach (KeyValuePair <string, IconType> current in sortedDictionary)
                {
                    ControlAPI.AddItemToListBox(current.Value, current.Key, imageListBoxControl1);
                }
            }
        }
Exemple #11
0
 public static void InitPathComboBox(string sPath, ImageComboBoxEdit cmbPath, DataType type)
 {
     cmbPath.Properties.BeginUpdate();
     try
     {
         cmbPath.Properties.Items.Clear();
         bool flag = false;
         if (type != DataType.sde)
         {
             ControlAPI.AddItemToComboBox(IconType.Disk, ConstDef.PATH_DESKTOP, "桌面", cmbPath);
             DriveInfo[] drives = DriveInfo.GetDrives();
             DriveInfo[] array  = drives;
             for (int i = 0; i < array.Length; i++)
             {
                 DriveInfo driveInfo = array[i];
                 if (driveInfo.DriveType == DriveType.Fixed || driveInfo.DriveType == DriveType.Removable)
                 {
                     ControlAPI.AddItemToComboBox(IconType.Disk, driveInfo.Name, driveInfo.Name, cmbPath);
                 }
             }
         }
         if (type == DataType.all || (type & DataType.sde) == DataType.sde)
         {
             ImageComboBoxItem selectedItem = ControlAPI.AddItemToComboBox(IconType.SdeConnections, "数据库连接", "数据库连接", cmbPath);
             if (sPath == "数据库连接")
             {
                 cmbPath.SelectedItem = selectedItem;
                 return;
             }
         }
         if (!string.IsNullOrEmpty(sPath))
         {
             if (sPath.StartsWith(ConstDef.PATH_DESKTOP))
             {
                 cmbPath.SelectedIndex = 0;
             }
             else
             {
                 string[] array2 = sPath.Split(new char[]
                 {
                     '\\'
                 });
                 foreach (ImageComboBoxItem imageComboBoxItem in cmbPath.Properties.Items)
                 {
                     if (!(imageComboBoxItem.Description != array2[0] + "\\"))
                     {
                         ImageComboBoxItem imageComboBoxItem2 = imageComboBoxItem;
                         for (int j = 1; j < array2.Length; j++)
                         {
                             if (!string.IsNullOrEmpty(array2[j]))
                             {
                                 string text = array2[0];
                                 for (int k = 1; k <= j; k++)
                                 {
                                     text = text + "\\" + array2[k];
                                 }
                                 if (!Directory.Exists(text))
                                 {
                                     cmbPath.SelectedItem = imageComboBoxItem2;
                                     flag = true;
                                     break;
                                 }
                                 int iIndex = cmbPath.Properties.Items.IndexOf(imageComboBoxItem2) + 1;
                                 imageComboBoxItem2 = ControlAPI.InsertItemToComboBox(IconType.Folder, text, array2[j], cmbPath, iIndex);
                                 if (j == array2.Length - 1)
                                 {
                                     cmbPath.SelectedItem = imageComboBoxItem2;
                                     flag = true;
                                     break;
                                 }
                             }
                         }
                         if (!flag)
                         {
                             cmbPath.SelectedItem = imageComboBoxItem;
                             flag = true;
                         }
                         break;
                     }
                 }
                 if (!flag && cmbPath.Properties.Items.Count > 0)
                 {
                     cmbPath.SelectedIndex = 0;
                 }
             }
         }
     }
     finally
     {
         cmbPath.Properties.EndUpdate();
     }
 }
Exemple #12
0
 public static void OpenFolder(string sPath, ImageListBoxControl imageListBoxControl1, DataType type, List <WorkspaceInfo> pWorkspaceList, esriGeometryType geometryType)
 {
     imageListBoxControl1.BeginUpdate();
     imageListBoxControl1.Items.Clear();
     if (!Directory.Exists(sPath))
     {
         XtraMessageBox.Show("路径不存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
     }
     else
     {
         DirectoryInfo   directoryInfo = new DirectoryInfo(sPath);
         DirectoryInfo[] directories   = directoryInfo.GetDirectories();
         SortedDictionary <string, IconType> sortedDictionary = new SortedDictionary <string, IconType>();
         List <string> list = null;
         if (type == DataType.all || (type & DataType.raster) == DataType.raster)
         {
             list = ControlAPI.GetRasterNames(sPath, pWorkspaceList);
         }
         DirectoryInfo[] array = directories;
         for (int i = 0; i < array.Length; i++)
         {
             DirectoryInfo directoryInfo2 = array[i];
             if ((directoryInfo2.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
             {
                 if (directoryInfo2.Name.EndsWith(".gdb", StringComparison.CurrentCultureIgnoreCase))
                 {
                     if (type == DataType.all || (type & DataType.gdb) == DataType.gdb)
                     {
                         sortedDictionary.Add(directoryInfo2.Name, IconType.FGDB);
                     }
                 }
                 else if (list == null || !list.Contains(directoryInfo2.Name))
                 {
                     ControlAPI.AddItemToListBox(IconType.Folder, directoryInfo2.Name, imageListBoxControl1);
                 }
             }
         }
         if (type == DataType.all || (type & DataType.mdb) == DataType.mdb)
         {
             FileInfo[] files  = directoryInfo.GetFiles("*.mdb");
             FileInfo[] array2 = files;
             for (int i = 0; i < array2.Length; i++)
             {
                 FileInfo fileInfo = array2[i];
                 sortedDictionary.Add(fileInfo.Name, IconType.PGDB);
             }
         }
         foreach (KeyValuePair <string, IconType> current in sortedDictionary)
         {
             ControlAPI.AddItemToListBox(current.Value, current.Key, imageListBoxControl1);
         }
         if (list != null && list.Count > 0)
         {
             foreach (string current2 in list)
             {
                 ControlAPI.AddItemToListBox(IconType.RasterDataset, current2, imageListBoxControl1);
             }
         }
         if (type == DataType.all || (type & DataType.shp) == DataType.shp)
         {
             ControlAPI.ListShpFiles(sPath, imageListBoxControl1, pWorkspaceList, geometryType);
         }
         if (type == DataType.all || (type & DataType.cad) == DataType.cad)
         {
             ControlAPI.OpenGeodatabase(sPath, imageListBoxControl1, DataType.cad, pWorkspaceList, geometryType, true, false);
         }
         imageListBoxControl1.EndUpdate();
     }
 }