private void btnOpen_Click(object sender, EventArgs e) { frmOpenFile file = new frmOpenFile(); file.AddFilter(new MyGxFilterTablesAndFeatureClasses(), true); file.AllowMultiSelect = false; this.btnSelectInputFeatures.Enabled = false; if (file.DoModalOpen() == DialogResult.OK) { this.igxDataset_0 = null; if (file.Items.Count != 0) { IGxDataset dataset = file.Items.get_Element(0) as IGxDataset; if (dataset != null) { this.igxDataset_0 = dataset; this.textEdit1.Text = (this.igxDataset_0 as IGxObject).Name; this.btnSelectInputFeatures.Enabled = true; } else { this.igxDataset_0 = null; this.textEdit1.Text = ""; } } } }
private void btnSelectGDB_Click(object sender, EventArgs e) { frmOpenFile file = new frmOpenFile(); file.AddFilter(new MyGxFilterWorkspaces(), true); if (file.ShowDialog() == DialogResult.OK) { IGxDatabase database = file.Items.get_Element(0) as IGxDatabase; if (database != null) { this.txtGDB.Text = (database as IGxObject).FullName; if (!database.IsConnected) { database.Connect(); } IWorkspaceReplicas workspace = database.Workspace as IWorkspaceReplicas; if (workspace != null) { IEnumReplica replicas = workspace.Replicas; replicas.Reset(); IReplica replica2 = replicas.Next(); if (replica2 != null) { this.lblCheckOutName.Text = replica2.Name; this.txtGDB.Tag = database.WorkspaceName; } else { this.txtGDB.Tag = null; } } } } }
private void btnSelectOutLocation_Click(object sender, EventArgs e) { frmOpenFile file = new frmOpenFile { Text = "保存位置" }; file.RemoveAllFilters(); file.AddFilter(new MyGxFilterWorkspaces(), true); if (file.DoModalSaveLocation() == DialogResult.OK) { IArray items = file.Items; if (items.Count != 0) { this.igxObject_0 = items.get_Element(0) as IGxObject; this.iname_0 = this.igxObject_0.InternalObjectName; if (this.igxObject_0 is IGxDatabase) { this.iname_0 = this.igxObject_0.InternalObjectName; } else if (this.igxObject_0 is IGxFolder) { IWorkspaceName name = new WorkspaceNameClass { WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory", PathName = (this.igxObject_0.InternalObjectName as IFileName).Path }; this.iname_0 = name as IName; } this.txtOutLocation.Text = this.igxObject_0.FullName; } } }
private void btnImport_Click(object sender, EventArgs e) { frmOpenFile file = new frmOpenFile(); file.AddFilter(new MyGxFilterDatasets(), true); file.AllowMultiSelect = false; if (file.ShowDialog() == DialogResult.OK) { IGxDataset dataset = file.Items.get_Element(0) as IGxDataset; if (dataset != null) { IGeoDataset dataset2 = dataset.Dataset as IGeoDataset; if (dataset2 != null) { if (dataset2.SpatialReference is IUnknownCoordinateSystem) { this.ispatialReferenceInfo_0 = null; this.textBoxName.Text = "<NONE>"; this.textBoxName.Tag = null; } else { this.ispatialReferenceInfo_0 = (dataset2.SpatialReference as ISpatialReference3).VerticalCoordinateSystem; this.textBoxName.Tag = this.ispatialReferenceInfo_0; this.textBoxName.Text = this.ispatialReferenceInfo_0.Name; } } } } }
private void btnSelectOutLocation_Click(object sender, EventArgs e) { frmOpenFile file = new frmOpenFile { Text = "保存位置" }; file.RemoveAllFilters(); file.AddFilter(new MyGxFilterWorkspaces(), true); if (file.ShowDialog() == DialogResult.OK) { IArray items = file.Items; if (items.Count != 0) { this.cboConfigKey.Properties.Items.Clear(); this.igxObject_0 = items.get_Element(0) as IGxObject; IRasterWorkspaceEx ex = this.igxObject_0.InternalObjectName.Open() as IRasterWorkspaceEx; this.method_1(ex as IGeodatabaseRelease, this.ispatialReference_1); this.method_1(ex as IGeodatabaseRelease, this.ispatialReference_0); this.txtLoaction.Name = this.igxObject_0.FullName; if ((this.igxObject_0 is IGxDatabase) && (this.igxObject_0 as IGxDatabase).IsRemoteDatabase) { this.method_2((this.igxObject_0 as IGxDatabase).Workspace as IWorkspaceConfiguration); } } } }
private void btnTemplateDB_Click(object sender, EventArgs e) { frmOpenFile openFile = new frmOpenFile(); openFile.Text = "选择模板数据库"; openFile.AllowMultiSelect = false; openFile.AddFilter(new MyGxFilterPersonalGeodatabases(), true); openFile.AddFilter(new MyGxFilterFileGeodatabases(), false); openFile.AddFilter(new MyGxFilterEnteripesGeoDatabases(), false); if (openFile.ShowDialog() == DialogResult.OK) { IGxDatabase database = openFile.Items.get_Element(0) as IGxDatabase; if (database != null) { IFeatureWorkspace pWorkspace = Yutai.ArcGIS.Common.Helpers.WorkspaceHelper.GetWorkspace((database as IGxObject).FullName); if (pWorkspace == null) { return; } bool isExists1 = ((IWorkspace2)pWorkspace).get_NameExists(esriDatasetType.esriDTTable, "MAPTEMPLATE"); bool isExists2 = ((IWorkspace2)pWorkspace).get_NameExists(esriDatasetType.esriDTTable, "MAPTEMPLATECLASS"); bool isExists3 = ((IWorkspace2)pWorkspace).get_NameExists(esriDatasetType.esriDTTable, "MAPTEMPLATEELEMENT"); bool isExists4 = ((IWorkspace2)pWorkspace).get_NameExists(esriDatasetType.esriDTTable, "MAPTEMPLATEEPARAM"); if (isExists4 && isExists1 && isExists3 && isExists2) { this.txtDB.Text = BuildConnectionString((database as IGxObject).FullName); } else { MessageService.Current.Warn("该数据库内没有地图制图模板数据!请重新选择!"); } } } }
private void btnImport_Click(object sender, EventArgs e) { frmOpenFile file = new frmOpenFile(); file.AddFilter(new MyGxFilterDatasets(), true); file.AllowMultiSelect = false; if (file.ShowDialog() == DialogResult.OK) { IGxDataset dataset = file.Items.get_Element(0) as IGxDataset; if (dataset != null) { IGeoDataset dataset2 = dataset.Dataset as IGeoDataset; if (dataset2 != null) { this.ispatialReference_0 = dataset2.SpatialReference; TreeNode node = new TreeNode(this.ispatialReference_0.Name, 2, 2) { Tag = this.ispatialReference_0 }; this.treeNode_0.Nodes.Add(node); this.method_4(this.ispatialReference_0); this.method_6(); } } } }
private void btnSelectInputFeatures_Click(object sender, EventArgs e) { frmOpenFile file = new frmOpenFile { Text = "选择要素" }; file.RemoveAllFilters(); file.AddFilter(new MyGxFilterDatasets(), true); if (file.DoModalOpen() == DialogResult.OK) { IArray items = file.Items; if (items.Count == 0) { return; } IGxObject obj2 = items.get_Element(0) as IGxObject; this.txtInputFeatureClass.Text = obj2.FullName; this.txtInputFeatureClass.Tag = obj2; } if (this.txtInputFeatureClass.Text.Length > 0) { this.btnAdd.Enabled = true; } }
private void btnDB_Click(object sender, EventArgs e) { frmOpenFile openFile = new frmOpenFile(); openFile.AllowMultiSelect = false; openFile.AddFilter(new MyGxFilterWorkspaces(), true); openFile.AddFilter(new MyGxFilterFeatureDatasets(), false); if (openFile.ShowDialog() == DialogResult.OK) { IGxObject gxObject = openFile.Items.get_Element(0); if (gxObject is IGxDatabase) { IGxDatabase database = gxObject as IGxDatabase; txtDB.Text = database.WorkspaceName.PathName; txtDB.Tag = database; label1.Tag = "Database"; xtraTabControl1.TabPages[0].PageVisible = true; } else if (gxObject is IGxDataset) { IGxDataset dataset = gxObject as IGxDataset; txtDB.Text = dataset.DatasetName.WorkspaceName.PathName + "\\" + dataset.DatasetName.Name; txtDB.Tag = dataset; label1.Tag = "Dataset"; xtraTabControl1.TabPages[0].PageVisible = false; } } }
private void btnSelectOutLocation_Click(object sender, EventArgs e) { frmOpenFile frmOpenFile = new frmOpenFile(); frmOpenFile.Text = "保存位置"; frmOpenFile.RemoveAllFilters(); frmOpenFile.AddFilter(new MyGxFilterWorkspaces(), true); frmOpenFile.AddFilter(new MyGxFilterRasterCatalogDatasets(), false); if (frmOpenFile.DoModalSaveLocation() == DialogResult.OK) { IArray items = frmOpenFile.Items; if (items.Count != 0) { this.m_pOutGxObject = (items.get_Element(0) as IGxObject); if (this.m_pOutGxObject is IGxDatabase) { this.m_pOutName = this.m_pOutGxObject.InternalObjectName; } else { if (!(this.m_pOutGxObject is IGxDataset)) { return; } if ((this.m_pOutGxObject as IGxDataset).Type != esriDatasetType.esriDTRasterCatalog) { return; } this.m_pOutName = this.m_pOutGxObject.InternalObjectName; } this.txtOutLocation.Text = this.m_pOutGxObject.FullName; } } }
private void btnSelectGDB_Click(object sender, EventArgs e) { frmOpenFile _frmOpenFile = new frmOpenFile(); _frmOpenFile.AddFilter(new MyGxFilterEnteripesGeoDatabases(), true); if (_frmOpenFile.DoModalOpen() == System.Windows.Forms.DialogResult.OK) { this.textBox1.Tag = _frmOpenFile.SelectedItems[0]; this.textBox1.Text = (_frmOpenFile.SelectedItems[0] as IGxObject).FullName; } }
private void btnOpen_Click(object sender, EventArgs e) { switch (ExportType) { case EnumExportType.FeatureClass: { frmOpenFile frm = new frmOpenFile(); frm.AllowMultiSelect = false; frm.AddFilter(new MyGxFilterWorkspaces(), false); frm.AddFilter(new MyGxFilterDatasets(), true); frm.Text = @"选择输出位置"; if (frm.DoModalOpen() == DialogResult.OK) { IGxObject gxObject = frm.Items.get_Element(0) as IGxObject; if (gxObject is IGxDatabase) { IGxDatabase gxDatabase = gxObject as IGxDatabase; _dataset = null; _workspace = gxDatabase.Workspace; _saveType = EnumSaveType.Workspace; } else if (gxObject is IGxDataset) { IGxDataset gxDataset = gxObject as IGxDataset; _dataset = gxDataset.Dataset; _workspace = _dataset.Workspace; _saveType = EnumSaveType.Dataset; } } } break; case EnumExportType.Shapefile: { FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.ShowNewFolderButton = true; if (dialog.ShowDialog() == DialogResult.OK) { this.txtPath.Text = dialog.SelectedPath; Type factoryType = Type.GetTypeFromProgID("esriDataSourcesFile.ShapefileWorkspaceFactory"); IWorkspaceFactory shapefileWorkspaceFactory = Activator.CreateInstance(factoryType) as IWorkspaceFactory; if (shapefileWorkspaceFactory == null) { return; } _dataset = null; _workspace = shapefileWorkspaceFactory.OpenFromFile(dialog.SelectedPath, 0); _saveType = EnumSaveType.Workspace; } } break; } }
private void btnSelectIn_Click(object sender, EventArgs e) { frmOpenFile file = new frmOpenFile { AllowMultiSelect = false, Text = "选择要素" }; file.RemoveAllFilters(); file.AddFilter(new MyGxFilterDatasets(), true); if (file.DoModalOpen() == DialogResult.OK) { IArray items = file.Items; if (items.Count != 0) { this.igxDataset_0 = items.get_Element(0) as IGxDataset; this.idataset_0 = this.igxDataset_0.Dataset; this.txtInputFeat.Text = (this.igxDataset_0 as IGxObject).FullName; this.iworkspace_0 = this.idataset_0.Workspace; string tableName = this.idataset_0.Name + "_Project1"; IFieldChecker checker = new FieldCheckerClass { InputWorkspace = this.iworkspace_0 }; checker.ValidateTableName(tableName, out this.string_0); this.txtOutFeat.Text = this.iworkspace_0.PathName + @"\" + this.string_0; if ((this.iworkspace_0.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace) || (this.iworkspace_0.Type == esriWorkspaceType.esriLocalDatabaseWorkspace)) { if (((IWorkspace2)this.iworkspace_0).get_NameExists(esriDatasetType.esriDTFeatureClass, this.string_0)) { this.bool_0 = true; } else { this.bool_0 = false; } } else if (this.iworkspace_0.Type == esriWorkspaceType.esriFileSystemWorkspace) { if (File.Exists(this.txtOutFeat.Text + ".shp")) { this.bool_0 = true; } else { this.bool_0 = false; } } } } }
private void btnSelectOut_Click(object sender, EventArgs e) { frmOpenFile file = new frmOpenFile { Text = "保存位置" }; file.RemoveAllFilters(); file.AddFilter(new MyGxFilterWorkspaces(), true); file.AddFilter(new MyGxFilterFeatureDatasets(), false); if (file.DoModalSaveLocation() == DialogResult.OK) { IArray items = file.Items; if (items.Count != 0) { this.igxObject_0 = items.get_Element(0) as IGxObject; this.iname_0 = this.igxObject_0.InternalObjectName; if (this.igxObject_0 is IGxDatabase) { this.iname_0 = this.igxObject_0.InternalObjectName; this.iworkspace_0 = this.iname_0.Open() as IWorkspace; this.btnSR.Enabled = true; } else if (this.igxObject_0 is IGxFolder) { IWorkspaceName name = new WorkspaceNameClass { WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory", PathName = (this.igxObject_0.InternalObjectName as IFileName).Path }; this.iname_0 = name as IName; this.iworkspace_0 = this.iname_0.Open() as IWorkspace; this.btnSR.Enabled = true; } else if (this.igxObject_0 is IGxDataset) { IDatasetName internalObjectName = this.igxObject_0.InternalObjectName as IDatasetName; if (internalObjectName.Type != esriDatasetType.esriDTFeatureDataset) { return; } this.iname_0 = internalObjectName as IName; this.btnSR.Enabled = false; IGeoDataset dataset = (internalObjectName as IName).Open() as IGeoDataset; this.iworkspace_0 = (dataset as IDataset).Workspace; this.ispatialReference_0 = dataset.SpatialReference; this.txtOutSR.Text = this.ispatialReference_0.Name; } this.txtOutFeat.Text = this.igxObject_0.FullName; } } }
private void btnImportFC_Click(object sender, EventArgs e) { frmOpenFile frm = new frmOpenFile(); frm.AddFilter(new MyGxFilterFeatureClasses(), true); if (frm.DoModalOpen() != DialogResult.OK) { return; } IGxDataset gxObject = frm.SelectedItems[0] as IGxDataset; if (gxObject == null) { return; } DialogResult result = MessageBox.Show("导入字段时是否清空已有字段?", "询问", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Cancel) { return; } if (result == DialogResult.Yes) { _fieldTable.Rows.Clear(); } IFeatureClass pClass = gxObject.Dataset as IFeatureClass; for (int i = 0; i < pClass.Fields.FieldCount; i++) { IField pField = pClass.Fields.Field[i]; if (pField.Type == esriFieldType.esriFieldTypeGeometry || pField.Type == esriFieldType.esriFieldTypeOID) { continue; } string pFldName = pField.Name; if (_fieldTable.Select("FieldName='" + pFldName + "'").Length > 0) { continue; } DataRow pRow = _fieldTable.NewRow(); pRow["FieldName"] = pField.Name; pRow["AliasName"] = pField.AliasName; pRow["AllowNull"] = pField.IsNullable; pRow["FieldType"] = FieldHelper.ConvertToSimpleString(pField.Type); //pRow["IsKey"] = pField.DefaultValue==null ? "": pField.DefaultValue; pRow["FieldLength"] = pField.Length; pRow["Precision"] = pField.Precision; _fieldTable.Rows.Add(pRow); } }
private void btnOpenTable_Click(object sender, EventArgs e) { frmOpenFile file = new frmOpenFile(); file.AddFilter(new MyGxFilterDatasets(), true); if (file.ShowDialog() == DialogResult.OK) { ITable dataset = (file.Items.get_Element(0) as IGxDataset).Dataset as ITable; if (dataset != null) { this.cboRelatingTable.Properties.Items.Add(new ObjectWrap(dataset)); } } }
private void btnSelectInputFeatures_Click(object sender, EventArgs e) { frmOpenFile file = new frmOpenFile { Text = "选择表" }; file.AddFilter(new MyGxFilterTables(), true); if (file.DoModalOpen() == DialogResult.OK) { IArray items = file.Items; if (items.Count != 0) { IGxObject obj2 = items.get_Element(0) as IGxObject; ITable dataset = (obj2 as IGxDataset).Dataset as ITable; this.txtTable.Tag = dataset; if (dataset != null) { this.txtTable.Text = obj2.FullName; string[] strArray = obj2.Name.Split(new char[] { '.' }); string str = strArray[strArray.Length - 1]; this.txtDomainName.Text = str; IFields fields = dataset.Fields; for (int i = 0; i < fields.FieldCount; i++) { IField field = fields.get_Field(i); if ((((field.Type != esriFieldType.esriFieldTypeBlob) && (field.Type != esriFieldType.esriFieldTypeGeometry)) && (field.Type != esriFieldType.esriFieldTypeRaster)) && (field.Type != esriFieldType.esriFieldTypeOID)) { this.cdoCodeField.Properties.Items.Add(field.AliasName); if (field.Type == esriFieldType.esriFieldTypeString) { this.cboNameField.Properties.Items.Add(field.AliasName); } } } if (this.cdoCodeField.Properties.Items.Count > 0) { this.cdoCodeField.SelectedIndex = 0; } if (this.cboNameField.Properties.Items.Count > 0) { this.cboNameField.SelectedIndex = 0; } } } } }
private void btnImportStruct_Click(object sender, EventArgs e) { frmOpenFile file = new frmOpenFile(); file.AddFilter(new MyGxFilterTablesAndFeatureClasses(), true); file.AllowMultiSelect = false; if ((file.DoModalOpen() == DialogResult.OK) && (file.Items.Count != 0)) { IGxDataset dataset = file.Items.get_Element(0) as IGxDataset; if (dataset != null) { ITable table = dataset.Dataset as ITable; if (table != null) { int num; IField field; for (num = this.ifields_0.FieldCount - 1; num > 1; num--) { field = this.ifields_0.get_Field(num); if ((field.Type != esriFieldType.esriFieldTypeOID) && (field.Type != esriFieldType.esriFieldTypeGeometry)) { (this.ifields_0 as IFieldsEdit).DeleteField(field); if (this.bool_2) { this.ifieldsEdit_1.AddField(field); } } } IFields fields = table.Fields; for (num = 0; num < fields.FieldCount; num++) { field = fields.get_Field(num); if ((field.Type != esriFieldType.esriFieldTypeOID) && (field.Type != esriFieldType.esriFieldTypeGeometry)) { (this.ifields_0 as IFieldsEdit).AddField(field); if (this.bool_2) { this.ifieldsEdit_0.AddField(field); } } } } this.method_2(this.listView2, this.ifields_0); this.method_5(this.listView2.Items[0].Tag as IField, true); } } }
public static IFeatureClass SelectFeatureClassDialog() { frmOpenFile frm = new frmOpenFile(); frm.AllowMultiSelect = false; frm.AddFilter(new MyGxFilterFeatureClasses(), true); frm.Text = @"选择要素类"; if (frm.DoModalOpen() == DialogResult.OK) { IGxObject gxObject = frm.Items.get_Element(0) as ArcGIS.Catalog.IGxObject; IFeatureClassName className = gxObject.InternalObjectName as IFeatureClassName; return(((IName)className).Open() as IFeatureClass); } return(null); }
public override void OnClick() { frmOpenFile frmOpenFile = new frmOpenFile(); frmOpenFile.Text = "添加数据"; frmOpenFile.AllowMultiSelect = true; frmOpenFile.AddFilter(new MyGxFilterDatasets(), true); if (frmOpenFile.DoModalOpen() == System.Windows.Forms.DialogResult.OK) { System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; this.add3DDataHelper_0 = new Add3DDataHelper(this.method_0()); this.ilist_0 = frmOpenFile.SelectedItems; this.add3DDataHelper_0.LoadData(this.ilist_0); System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default; } }
private void AddConnection() { frmOpenFile frm = new frmOpenFile(); frm.AddFilter(new MyGxFilterGeoDatabases(), true); frm.Text = "选择数据库"; if (frm.DoModalOpen() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; IGxDatabase database = frm.Items.get_Element(0) as IGxDatabase; if (database != null) { ITemplateDatabase findDB = _databases.FirstOrDefault(c => c.DatabaseName == (database as IGxObject).FullName); if (findDB != null) { MessageService.Current.Warn("数据库已经连接,无需再次连接!"); return; } IFeatureWorkspace pWorkspace = Yutai.ArcGIS.Common.Helpers.WorkspaceHelper.GetWorkspace((database as IGxObject).FullName); if (pWorkspace == null) { return; } bool isExists1 = ((IWorkspace2)pWorkspace).get_NameExists(esriDatasetType.esriDTTable, "YT_TEMPLATE_FEATURECLASS"); // bool isExists2 = ((IWorkspace2)pWorkspace).get_NameExists(esriDatasetType.esriDTTable, "YT_TEMPLATE_FIELD"); bool isExists3 = ((IWorkspace2)pWorkspace).get_NameExists(esriDatasetType.esriDTTable, "YT_TEMPLATE_DOMAIN"); bool isExists4 = ((IWorkspace2)pWorkspace).get_NameExists(esriDatasetType.esriDTTable, "YT_TEMPLATE_DATASET"); ITemplateDatabase templateDatabase = new TemplateDatabase(); templateDatabase.DatabaseName = (database as IGxObject).FullName; templateDatabase.Workspace = pWorkspace; _databases.Add(templateDatabase); LoadDatabases(); //if (isExists4 && isExists1 && isExists3 && isExists2) //{ // this.txtDB.Text = BuildConnectionString((database as IGxObject).FullName); //} //else //{ // MessageService.Current.Warn("该数据库内没有地图制图模板数据!请重新选择!"); //} } Cursor.Current = Cursors.Default; } // LoadDatabases(); }
private void btnOpen_Click(object sender, EventArgs e) { frmOpenFile file = new frmOpenFile(); file.AddFilter(new MyGxFilterTablesAndFeatureClasses(), true); file.AllowMultiSelect = false; if ((file.DoModalOpen() == DialogResult.OK) && (file.Items.Count != 0)) { IGxDataset dataset = file.Items.get_Element(0) as IGxDataset; if (dataset != null) { if ((this.igxDataset_0.Type == esriDatasetType.esriDTFeatureClass) && (dataset.Type == esriDatasetType.esriDTFeatureClass)) { if ((this.igxDataset_0.Dataset as IFeatureClass).ShapeType == (dataset.Dataset as IFeatureClass).ShapeType) { if ( this.method_0(this.igxDataset_0.DatasetName.WorkspaceName, dataset.DatasetName.WorkspaceName) && (this.igxDataset_0.DatasetName.Name == dataset.DatasetName.Name)) { MessageBox.Show("源对象类和目标对象类必须不同!"); } else { this.igxDataset_1 = dataset; this.textEdit1.Text = (this.igxDataset_1 as IGxObject).Name; } } else { MessageBox.Show("装载数据必须和源数据有相同的几何数据类型!"); } } else { this.igxDataset_1 = dataset; this.textEdit1.Text = (this.igxDataset_1 as IGxObject).Name; } } else { this.textEdit1.Text = ""; } } }
private void btnSelectInputFeatures_Click(object sender, EventArgs e) { frmOpenFile file = new frmOpenFile(); file.AddFilter(new MyGxFilterFeatureClasses(), true); if (file.DoModalSave() == DialogResult.OK) { IArray items = file.Items; if (items.Count != 0) { System.Windows.Forms.Cursor.Current = Cursors.WaitCursor; try { IWorkspaceName name = null; IGxObject obj2 = items.get_Element(0) as IGxObject; string str = ""; string fullName = ""; if (obj2 is IGxDatabase) { BufferHelper.m_BufferHelper.m_pOutFeatureWorksapce = (obj2 as IGxDatabase).Workspace as IFeatureWorkspace; fullName = obj2.FullName; } else if (obj2 is IGxFolder) { name = new WorkspaceNameClass { WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory", PathName = (obj2.InternalObjectName as IFileName).Path }; BufferHelper.m_BufferHelper.m_pOutFeatureWorksapce = (name as IName).Open() as IFeatureWorkspace; fullName = (obj2.InternalObjectName as IFileName).Path; str = ".shp"; } BufferHelper.m_BufferHelper.m_FeatClassName = file.SaveName; this.txtOutName.Text = fullName + @"\" + file.SaveName + str; } catch (Exception exception) { CErrorLog.writeErrorLog(null, exception, ""); } System.Windows.Forms.Cursor.Current = Cursors.Default; } } }
private void cmdLayerBrowse_Click(object sender, EventArgs e) { frmOpenFile frmOpenFile = new frmOpenFile(); frmOpenFile.AddFilter(new MyGxFilterPolygonFeatureClasses(), true); frmOpenFile.Text = "选择要素"; if (frmOpenFile.DoModalOpen() == System.Windows.Forms.DialogResult.OK) { IArray items = frmOpenFile.Items; for (int i = 0; i < items.Count; i++) { IGxDataset gxDataset = items.get_Element(i) as IGxDataset; this.cmbBuildingLayer.Items.Add(new ObjectWrap(gxDataset.Dataset)); } this.cmbBuildingLayer.SelectedIndex = this.cmbBuildingLayer.Items.Count - 1; } }
private void btnSelectWorkspace_Click(object sender, EventArgs e) { frmOpenFile frmOpenFile = new frmOpenFile() { Text = "保存位置", AllowMultiSelect = false }; frmOpenFile.AddFilter(new MyGxFilterGeoDatabases(), true); if (frmOpenFile.DoModalSaveLocation() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; this.txtSaveAt.Text = frmOpenFile.SelectedItems[0].ToString(); _saveWorkspace = ((IGxObject)frmOpenFile.SelectedItems[0]).InternalObjectName.Open() as IWorkspace; Cursor.Current = Cursors.Default; } }
public static IFeatureClass SelectFeatureClassDialog() { frmOpenFile frm = new frmOpenFile() { Text = @"添加数据", AllowMultiSelect = false }; frm.AddFilter(new MyGxFilterFeatureClasses(), true); if (frm.DoModalOpen() == DialogResult.OK) { IGxObject gxObject = frm.Items.get_Element(0) as IGxObject; IFeatureClassName className = gxObject.InternalObjectName as IFeatureClassName; IFeatureClass featureClass = ((IName)className).Open() as IFeatureClass; return(featureClass); } return(null); }
public static IWorkspace SelectWorkspaceDialog() { frmOpenFile frm = new frmOpenFile(); frm.AllowMultiSelect = false; frm.AddFilter(new MyGxFilterWorkspaces(), true); frm.Text = @"选择地理数据库"; if (frm.DoModalOpen() == DialogResult.OK) { IGxObject gxObject = frm.Items.get_Element(0) as ArcGIS.Catalog.IGxObject; if (gxObject is IGxDatabase) { IGxDatabase gxDatabase = gxObject as IGxDatabase; return(gxDatabase.Workspace); } } return(null); }
private void btnOpenFile_Click(object sender, EventArgs e) { frmOpenFile file = new frmOpenFile(); file.AddFilter(new MyGxFilterSurfaceDatasets(), true); if (file.ShowDialog() == DialogResult.OK) { IDataset dataset = (file.Items.get_Element(0) as IGxDataset).Dataset; if (dataset != null) { ISurface surface = this.method_1(dataset); if (surface != null) { this.cboSufer.Items.Add(new SuferWrap(surface)); this.cboSufer.SelectedIndex = this.cboSufer.Items.Count - 1; } } } }
private void btnImport_Click(object sender, EventArgs e) { frmOpenFile file = new frmOpenFile(); file.AddFilter(new MyGxFilterDatasets(), true); file.AllowMultiSelect = false; if (file.ShowDialog() == DialogResult.OK) { IGxDataset dataset = file.Items.get_Element(0) as IGxDataset; if (dataset != null) { IGeoDataset dataset2 = dataset.Dataset as IGeoDataset; if (dataset2 != null) { this.ispatialReference_0 = dataset2.SpatialReference; this.textBoxName.Text = this.ispatialReference_0.Name; this.textBoxName.Tag = this.ispatialReference_0; if (this.ispatialReference_0 is IUnknownCoordinateSystem) { this.btnModify.Enabled = false; } else { this.btnModify.Enabled = true; } IControlPrecision2 precision = this.ispatialReference_0 as IControlPrecision2; if (NewObjectClassHelper.m_pObjectClassHelper.IsHighPrecision != precision.IsHighPrecision) { if (precision.IsHighPrecision) { precision.IsHighPrecision = NewObjectClassHelper.m_pObjectClassHelper.IsHighPrecision; (this.ispatialReference_0 as ISpatialReferenceResolution).ConstructFromHorizon(); } else { precision.IsHighPrecision = NewObjectClassHelper.m_pObjectClassHelper.IsHighPrecision; } } } } } }
private void btnSelectInputFeatures_Click(object sender, EventArgs e) { int num; frmOpenFile file = new frmOpenFile { Text = "添加数据" }; file.RemoveAllFilters(); file.AllowMultiSelect = true; if (this.iarray_0.Count != 0) { for (num = 0; num < this.iarray_0.Count; num++) { if (num == 0) { file.AddFilter(this.iarray_0.get_Element(num) as IGxObjectFilter, true); } else { file.AddFilter(this.iarray_0.get_Element(num) as IGxObjectFilter, false); } } } else { file.AddFilter(new MyGxFilterDatasets(), true); } if (file.DoModalOpen() == DialogResult.OK) { IArray items = file.Items; if (items.Count != 0) { for (num = 0; num < items.Count; num++) { IGxObject obj2 = items.get_Element(num) as IGxObject; this.ilist_0.Add(obj2.InternalObjectName); this.listView1.Items.Add(obj2.FullName); } } } }