예제 #1
0
        private bool method_0(string string_1, string string_2, bool bool_2)
        {
            IGxObject      obj2 = null;
            IDatasetName   name;
            IWorkspaceName name2;

            switch (string_2)
            {
            case ".bmp":
            case ".jpg":
            case ".tif":
            case ".img":
            case ".png":
                obj2  = new GxRasterDataset();
                name  = new RasterDatasetNameClass();
                name2 = new WorkspaceNameClass
                {
                    WorkspaceFactoryProgID = "esriDataSourcesFile.RasterWorkspaceFactory",
                    PathName = System.IO.Path.GetDirectoryName(string_1)
                };
                name.Name          = System.IO.Path.GetFileName(string_1);
                name.WorkspaceName = name2;
                (obj2 as IGxDataset).DatasetName = name;
                obj2.Attach(this, this.igxCatalog_0);
                if (bool_2)
                {
                    this.igxCatalog_0.ObjectAdded(obj2);
                }
                return(true);

            case ".mdb":
                obj2  = new GxDatabase();
                name2 = new WorkspaceNameClass
                {
                    WorkspaceFactoryProgID = "esriDataSourcesGDB.AccessWorkspaceFactory",
                    PathName = string_1
                };
                (obj2 as IGxDatabase).WorkspaceName = name2;
                obj2.Attach(this, this.igxCatalog_0);
                if (bool_2)
                {
                    this.igxCatalog_0.ObjectAdded(obj2);
                }
                return(true);

            case ".vct":
                obj2 = new GxVCTObject();
                (obj2 as IGxFile).Path = string_1;
                obj2.Attach(this, this.igxCatalog_0);
                if (bool_2)
                {
                    this.igxCatalog_0.ObjectAdded(obj2);
                }
                return(true);

            case ".shp":
                obj2  = new GxShapefileDataset();
                name  = new FeatureClassNameClass();
                name2 = new WorkspaceNameClass
                {
                    WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory",
                    PathName = System.IO.Path.GetDirectoryName(string_1)
                };
                name.Name          = System.IO.Path.GetFileName(string_1);
                name.WorkspaceName = name2;
                (obj2 as IGxDataset).DatasetName = name;
                obj2.Attach(this, this.igxCatalog_0);
                if (bool_2)
                {
                    this.igxCatalog_0.ObjectAdded(obj2);
                }
                return(true);

            case ".dbf":
                if (!File.Exists(string_1.Substring(0, string_1.Length - 3) + "shp"))
                {
                    obj2  = new GxDataset();
                    name  = new TableNameClass();
                    name2 = new WorkspaceNameClass
                    {
                        WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory",
                        PathName = System.IO.Path.GetDirectoryName(string_1)
                    };
                    name.Name          = System.IO.Path.GetFileName(string_1);
                    name.WorkspaceName = name2;
                    (obj2 as IGxDataset).DatasetName = name;
                    obj2.Attach(this, this.igxCatalog_0);
                    if (bool_2)
                    {
                        this.igxCatalog_0.ObjectAdded(obj2);
                    }
                    return(true);
                }
                return(false);

            case ".sde":
                obj2  = new GxDatabase();
                name2 = new WorkspaceNameClass
                {
                    WorkspaceFactoryProgID = "esriDataSourcesGDB.SdeWorkspaceFactory",
                    PathName = string_1
                };
                (obj2 as IGxDatabase).WorkspaceName = name2;
                obj2.Attach(this, this.igxCatalog_0);
                if (bool_2)
                {
                    this.igxCatalog_0.ObjectAdded(obj2);
                }
                return(true);

            case ".lyr":
                obj2 = new GxLayer();
                (obj2 as IGxFile).Path = string_1;
                obj2.Attach(this, this.igxCatalog_0);
                if (bool_2)
                {
                    this.igxCatalog_0.ObjectAdded(obj2);
                }
                return(true);

            case ".dwg":
            case ".dxf":
                obj2  = new GxCadDataset();
                name  = new CadDrawingNameClass();
                name2 = new WorkspaceNameClass
                {
                    WorkspaceFactoryProgID = "esriDataSourcesFile.CadWorkspaceFactory",
                    PathName = System.IO.Path.GetDirectoryName(string_1)
                };
                name.Name          = System.IO.Path.GetFileName(string_1);
                name.WorkspaceName = name2;
                (obj2 as IGxDataset).DatasetName = name;
                obj2.Attach(this, this.igxCatalog_0);
                if (bool_2)
                {
                    this.igxCatalog_0.ObjectAdded(obj2);
                }
                return(true);

            case ".doc":
            case ".xls":
                obj2 = new GxOfficeFile();
                (obj2 as IGxFile).Path = string_1;
                obj2.Attach(this, this.igxCatalog_0);
                if (bool_2)
                {
                    this.igxCatalog_0.ObjectAdded(obj2);
                }
                return(true);
            }
            return(false);
        }
예제 #2
0
        private void method_0()
        {
            int             featureCount = this.icoConvert_0.FeatureCount;
            GxVCTObject     parent       = this.Parent as GxVCTObject;
            frmProgressBar1 bar          = new frmProgressBar1();

            try
            {
                IFeatureLayer layer;
                IFeatureClass class2    = null;
                CoLayerType   layerType = this.icoConvert_0.XpgisLayer.LayerType;
                string        str       = "Point";
                switch (layerType)
                {
                case CoLayerType.Point:
                    str = "Point";
                    break;

                case CoLayerType.Line:
                    str = "line";
                    break;

                case CoLayerType.Region:
                    str = "Polygon";
                    break;

                case CoLayerType.Annotation:
                    str = "Text";
                    break;
                }
                ICoConvert convert = null;
                if (str != "Text")
                {
                    convert =
                        new ShapeLayerClass(
                            parent.GetTemplatePath() + @"\" + this.icoConvert_0.XpgisLayer.Name + ".shp", str,
                            this.icoConvert_0.XpgisLayer);
                }
                else
                {
                    IFieldsEdit edit = null;
                    edit = new FieldsClass();
                    foreach (ICoField field in this.icoConvert_0.XpgisLayer.Fields)
                    {
                        IFieldEdit field1 = new Field() as IFieldEdit;
                        field1.Name_2         = field.Name;
                        field1.AliasName_2    = field.AliasName;
                        field1.DefaultValue_2 = field.DefaultValue;
                        field1.Editable_2     = field.Enable;
                        IFieldEdit  edit2 = field1 as IFieldEdit;
                        CoFieldType type  = field.Type;
                        switch (type)
                        {
                        case CoFieldType.整型:
                            edit2.Type_2 = esriFieldType.esriFieldTypeInteger;
                            break;

                        case ((CoFieldType)2):
                        case ((CoFieldType)6):
                        case ((CoFieldType)7):
                            break;

                        case CoFieldType.浮点型:
                            edit2.Type_2      = esriFieldType.esriFieldTypeSingle;
                            edit2.Precision_2 = field.Precision;
                            edit2.Scale_2     = field.Length;
                            break;

                        case CoFieldType.字符型:
                            edit2.Type_2   = esriFieldType.esriFieldTypeString;
                            edit2.Length_2 = field.Length;
                            break;

                        case CoFieldType.日期型:
                            edit2.Type_2 = esriFieldType.esriFieldTypeDate;
                            break;

                        case CoFieldType.二进制:
                            edit2.Type_2 = esriFieldType.esriFieldTypeBlob;
                            break;

                        default:
                            if (type == CoFieldType.布尔型)
                            {
                                edit2.Type_2 = esriFieldType.esriFieldTypeInteger;
                            }
                            break;
                        }
                        edit.AddField(edit2);
                    }
                    class2 = this.method_2(parent.GetTemplateTextWorksoace() as IFeatureWorkspace,
                                           this.icoConvert_0.XpgisLayer.Name, esriFeatureType.esriFTAnnotation,
                                           esriGeometryType.esriGeometryPolygon, edit);
                    convert = new GeodatabaseLayerClass(class2);
                }
                ConvertHander hander = new ConvertHander();
                bar.Text = "打开数据";
                bar.Show();
                bar.progressBar1.Maximum = featureCount;
                bar.progressBar1.Value   = 0;
                bar.Caption1.Text        = "正在载入图层:" + this.icoConvert_0.XpgisLayer.AliasName + " [要素总数:" +
                                           featureCount.ToString() + "]";
                hander.Convert(this.icoConvert_0, convert, bar.progressBar1);
                string name = this.icoConvert_0.XpgisLayer.Name;
                convert.Dispose();
                if (class2 == null)
                {
                    class2 = (parent.GetTemplateShapefile() as IFeatureWorkspace).OpenFeatureClass(name);
                }
                if (class2.FeatureType == esriFeatureType.esriFTAnnotation)
                {
                    FDOGraphicsLayerClass class3 = new FDOGraphicsLayerClass
                    {
                        Cached = true
                    };
                    layer = class3;
                    layer.FeatureClass = class2;
                    layer.Name         = class2.AliasName;
                }
                else if (class2.FeatureType == esriFeatureType.esriFTDimension)
                {
                    DimensionLayerClass class4 = new DimensionLayerClass
                    {
                        Cached = true
                    };
                    layer = class4;
                    layer.FeatureClass = class2;
                    layer.Name         = class2.AliasName;
                }
                else
                {
                    FeatureLayerClass class5 = new FeatureLayerClass
                    {
                        Cached = true
                    };
                    layer = class5;
                    layer.FeatureClass = class2;
                    layer.Name         = class2.AliasName;
                }
                this.ilayer_0 = layer;
                bar.Close();
            }
            catch (Exception)
            {
            }
        }