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 btnSelectOut_Click(object sender, EventArgs e) { frmOpenFile file = new frmOpenFile { Text = "保存位置" }; file.RemoveAllFilters(); file.AddFilter(new MyGxFilterFeatureClasses(), true); if (file.DoModalSave() == DialogResult.OK) { IArray items = file.Items; if (items.Count != 0) { IGxObject obj2 = items.get_Element(0) as IGxObject; if (obj2 is IGxDatabase) { this.iname_0 = obj2.InternalObjectName; } else if (obj2 is IGxFolder) { IWorkspaceName name = new WorkspaceNameClass { WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory", PathName = (obj2.InternalObjectName as IFileName).Path }; this.iname_0 = name as IName; } else if (obj2 is IGxDataset) { return; } this.iworkspace_0 = this.iname_0.Open() as IWorkspace; string saveName = file.SaveName; IFieldChecker checker = new FieldCheckerClass { InputWorkspace = this.iworkspace_0 }; checker.ValidateTableName(saveName, 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; } } } } }
public override void OnDblClick() { if (!this.bool_0) { this.idisplayFeedback_0 = null; } else { IGeometry geometry = (this.idisplayFeedback_0 as INewPolygonFeedback).Stop(); this.bool_0 = false; this.idisplayFeedback_0 = null; if (!geometry.IsEmpty) { (geometry as IPolygon).SimplifyPreserveFromTo(); System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; try { geometry.SpatialReference = this._context.FocusMap.SpatialReference; int num = this._subType; if (num != 0) { string str = System.IO.Path.GetTempPath() + "TempPersonGDB"; int num2 = 1; string path = str + ".mdb"; while (File.Exists(path)) { try { File.Delete(path); break; } catch { } num2++; path = str + " (" + num2.ToString() + ").mdb"; } IWorkspaceFactory workspaceFactory = new AccessWorkspaceFactory(); IWorkspaceName workspaceName = workspaceFactory.Create( System.IO.Path.GetDirectoryName(path), System.IO.Path.GetFileNameWithoutExtension(path), null, 0); IMap imap_ = new Map(); Clip.ExtractSpecifyHRegFeatures(workspaceName, this._context.FocusMap, geometry, imap_); new FormPrinterSetup(); CMapPrinter cMapPrinter; cMapPrinter = new CMapPrinter(imap_); cMapPrinter.showPrintUI("打印地图"); } else { frmOpenFile frmOpenFile = new frmOpenFile(); frmOpenFile.Text = "保存位置"; frmOpenFile.RemoveAllFilters(); frmOpenFile.AddFilter(new MyGxFilterWorkspaces(), true); if (frmOpenFile.DoModalSave() == System.Windows.Forms.DialogResult.OK) { IArray items = frmOpenFile.Items; if (items.Count == 0) { return; } System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; try { IWorkspaceName workspaceName = null; IGxObject gxObject = items.get_Element(0) as IGxObject; if (gxObject is IGxDatabase) { workspaceName = (gxObject.InternalObjectName as IWorkspaceName); } else if (gxObject is IGxFolder) { workspaceName = new WorkspaceName() as IWorkspaceName; workspaceName.WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory"; workspaceName.PathName = (gxObject.InternalObjectName as IFileName).Path; } if (workspaceName != null) { Clip.ExtractSpecifyHRegFeatures(workspaceName, this._context.FocusMap, geometry); } } catch { } System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default; } } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); } if (this._context.Hook is IApplication) { (this._context.Hook as IApplication).CurrentTool = null; } System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default; } } }