private void button1_Click(object sender, EventArgs e) { if (this.textBox1.Text != null && this.textBox1.Text.Length >= 2) { try { IWorkspaceName workspaceName = new WorkspaceName() as IWorkspaceName; workspaceName.WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory"; workspaceName.PathName = this.textBox1.Text; if (!Directory.Exists(this.textBox1.Text)) { Directory.CreateDirectory(this.textBox1.Text); } Clip.ExtractSpecifyHRegFeatures(workspaceName, this.imap_0, this.igeometry_0); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } base.Close(); } }
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; } } }