// user want to create a new point -> launch GPS Point form private void btnNew_Click(object sender, System.EventArgs e) { try { // if we cannot find the BCGS map layer we don't allow the user to edit if (LoadBCGSLayer() == false) { MessageBox.Show("The layer: '" + BCGSMAPLAYER + "' could not be found in the current map.\n" + "It is needed for creating and editing GPS points. " + "Please add it using normal means (e.g. TSAT Tools).","ISDUT"); return; } IPoint pPoint = new PointClass(); // TODO: //IMxDocument pMxDoc = (IMxDocument)m_pApp.Document; IActiveView pActiveView = (IActiveView)m_pISDUTExt.FocusMap; //pMxDoc.FocusMap; //util.Utils.Release(pMxDoc); pPoint.PutCoords(pActiveView.Extent.XMin + pActiveView.Extent.Width/2,pActiveView.Extent.YMin + pActiveView.Extent.Height/2); // m_frmGPSPoint = new GPSPointForm(m_pFeatureLayer,m_pFeatureLayerBCGS,-1,enumFormMode.newpoint,pPoint); GPSPointForm frmGPSPoint = new GPSPointForm(m_pFeatureLayer,m_pFeatureLayerBCGS,m_BCGSFields,-1,enumFormMode.newpoint,pPoint); //m_frmGPSPoint.NewGPSPoint_Event +=new GPSPoint_EventHandler(NewOrEditGPSPoint_EventHandler); //m_frmGPSPoint.ShowDialog(); if(frmGPSPoint.ShowDialog() != DialogResult.Cancel) { PopulateListView(); lvGPS.SelectedItems.Clear(); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography,null,null); } } catch(Exception ex) { util.Logger.Write(" Descrip : Makes sure we have access to the BCGS layer and then opens the GPS Point entry form. " + "\n Message : " + ex.Message + "\n StackTrc : " + ex.StackTrace,util.Logger.LogLevel.Debug); MessageBox.Show(ex.Message + "\n" + ex.StackTrace); Debug.WriteLine(ex.Message + "\n" + ex.StackTrace); } }
// user want to edit a single point private void btnEdit_Click(object sender, System.EventArgs e) { try { enumFormMode formmode = enumFormMode.editpoint; // // for either of these, we put the form into new mode; // if(m_canSI == true || m_canSUID == true) // { // formmode = enumFormMode.newpoint; // } // if we cannot find the BCGS map layer we don't allow the user INSERT or UPDATE if (LoadBCGSLayer() == false) { formmode = enumFormMode.viewpoint; } else if(m_canSUID == false) { formmode = enumFormMode.viewpoint; } IFeatureClass pFeatureClass = m_pFeatureLayer.FeatureClass; int OID = Convert.ToInt32(lvGPS.SelectedItems[0].Text); // create new instance of edit form -> put form into edit mode GPSPointForm frmGPSPoint = new GPSPointForm(m_pFeatureLayer,m_pFeatureLayerBCGS,m_BCGSFields,OID,formmode,null); // wire it up to the function that will handle insert of new point //frmGPSPoint.NewGPSPoint_Event +=new GPSPoint_EventHandler(NewOrEditGPSPoint_EventHandler); if(frmGPSPoint.ShowDialog() != DialogResult.Cancel) { PopulateListView(); lvGPS.SelectedItems.Clear(); // TODO: //IMxDocument pMxDoc = (IMxDocument)m_pApp.Document; IActiveView pActiveView = (IActiveView)m_pISDUTExt.FocusMap;// pMxDoc.FocusMap; //util.Utils.Release(pMxDoc); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography,null,null); } } catch(Exception ex) { util.Logger.Write(" Descrip : Gets the currently selected feature in the list and populates the GPS point entry form (then opens it). " + "\n Message : " + ex.Message + "\n StackTrc : " + ex.StackTrace,util.Logger.LogLevel.Debug); //MessageBox.Show(ex.Message + "\n" + ex.StackTrace); Debug.WriteLine(ex.Message + "\n" + ex.StackTrace); } }