public override void OnClick() { if (m_pAOIPanel.CurrentJob != null) { //show form AddressDialog pAddressDialog = new AddressDialog(); if (pAddressDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ILocatorManager pLocatorMgr = new LocatorManagerClass(); ILocatorWorkspace pLocatorWS = pLocatorMgr.GetLocatorWorkspaceFromPath(m_strWorkspace); IAddressGeocoding pLocator = (IAddressGeocoding)pLocatorWS.GetLocator(m_strLocator); IPropertySet addressProperties = new PropertySetClass(); addressProperties.SetProperty("Street", pAddressDialog.street); IPropertySet matchProperties = pLocator.MatchAddress(addressProperties); if (pLocator.MatchFields.FieldCount == 0) { System.Windows.Forms.MessageBox.Show("No address found"); return; } IPoint pPoint = null; for (int i = 0; i < pLocator.MatchFields.FieldCount; i++) { if (pLocator.MatchFields.get_Field(i).Type == esriFieldType.esriFieldTypeGeometry) { object pObject = matchProperties.GetProperty(pLocator.MatchFields.get_Field(i).Name); if (pObject is IPoint) { pPoint = (IPoint)pObject; } } } //calculate AOI ITopologicalOperator pTopo = (ITopologicalOperator)pPoint; IGeometry pGeom = pTopo.Buffer(100); IEnvelope pMyAOI = pGeom.Envelope; m_pAOIPanel.CurrentAOI = CreatePolyFromEnv(pMyAOI); IEnvelope pEnv = pGeom.Envelope; pEnv.Expand(2, 2, true); m_hookHelper.ActiveView.Extent = pEnv; m_hookHelper.ActiveView.Refresh(); } } }
public override void OnClick() { if (m_pAOIPanel.CurrentJob != null) { //show form AddressDialog pAddressDialog = new AddressDialog(); if (pAddressDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ILocatorManager pLocatorMgr = new LocatorManagerClass(); ILocatorWorkspace pLocatorWS = pLocatorMgr.GetLocatorWorkspaceFromPath(m_strWorkspace); IAddressGeocoding pLocator = (IAddressGeocoding)pLocatorWS.GetLocator(m_strLocator); IPropertySet addressProperties = new PropertySetClass(); addressProperties.SetProperty("Street", pAddressDialog.street); IPropertySet matchProperties = pLocator.MatchAddress(addressProperties); if(pLocator.MatchFields.FieldCount == 0) { System.Windows.Forms.MessageBox.Show("No address found"); return; } IPoint pPoint = null; for(int i = 0; i < pLocator.MatchFields.FieldCount; i++) { if(pLocator.MatchFields.get_Field(i).Type == esriFieldType.esriFieldTypeGeometry) { object pObject = matchProperties.GetProperty(pLocator.MatchFields.get_Field(i).Name); if(pObject is IPoint) pPoint = (IPoint) pObject; } } //calculate AOI ITopologicalOperator pTopo = (ITopologicalOperator)pPoint; IGeometry pGeom = pTopo.Buffer(100); IEnvelope pMyAOI = pGeom.Envelope; m_pAOIPanel.CurrentAOI = CreatePolyFromEnv(pMyAOI); IEnvelope pEnv = pGeom.Envelope; pEnv.Expand(2, 2, true); m_hookHelper.ActiveView.Extent = pEnv; m_hookHelper.ActiveView.Refresh(); } } }