private void OnSketchFinished() { IFeature pFeat = null; ISegmentCollection pSegColl = null; IEnumSegment pESeg = null; ISegment testSegment = null; ISegmentCollection segColTest = null; object Missing = null; try { // Send a shift-tab to hide the construction toolbar try { m_editor.StartOperation(); } catch { m_editor.AbortOperation(); m_editor.StartOperation(); } bool twoPoint = false; (ArcMap.Application.Document as IMxDocument).FocusMap.ClearSelection(); List <IFeature> pLstFeat = null; if (Control.ModifierKeys == Keys.Control) { twoPoint = CreateLineWithEndPoints.CreatePoints(ArcMap.Application, ConfigUtil.GetLinePointAtEndsConfig(), m_edSketch.Geometry as IPolyline, (IFeatureLayer)m_editor.CurrentTemplate.Layer, false, out pLstFeat); } else { twoPoint = CreateLineWithEndPoints.CreatePoints(ArcMap.Application, ConfigUtil.GetLinePointAtEndsConfig(), m_edSketch.Geometry as IPolyline, (IFeatureLayer)m_editor.CurrentTemplate.Layer, true, out pLstFeat); } if (twoPoint) { pSegColl = (ISegmentCollection)m_edSketch.Geometry; pESeg = pSegColl.EnumSegments; pESeg.Reset(); int partIndex = 0; int segmentIndex = 0; pESeg.Next(out testSegment, ref partIndex, ref segmentIndex); while (testSegment != null) { segColTest = new PolylineClass(); Missing = Type.Missing; segColTest.AddSegment(testSegment, ref Missing, ref Missing); pFeat = Globals.CreateFeature(segColTest as IGeometry, m_editor.CurrentTemplate, m_editor, ArcMap.Application, false, false, true); pFeat.Store(); pESeg.Next(out testSegment, ref partIndex, ref segmentIndex); } } else { pFeat = Globals.CreateFeature(m_edSketch.Geometry, m_editor.CurrentTemplate, m_editor, ArcMap.Application, false, false, true); pFeat.Store(); } foreach (IFeature pFt in pLstFeat) { pFt.Store(); } pLstFeat = null; m_editor.StopOperation(A4LGSharedFunctions.Localizer.GetString("CrtLnWithPts")); (ArcMap.Application.Document as IMxDocument).ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, null); } catch { } finally { pFeat = null; pSegColl = null; pESeg = null; testSegment = null; segColTest = null; Missing = null; } }
private void OnSketchFinished() { ConfigUtil.type = "gas"; IFeature pFeat = null; ISegmentCollection pSegColl = null; IEnumSegment pESeg = null; ISegment testSegment = null; ISegmentCollection segColTest = null; object Missing = null; try { // Send a shift-tab to hide the construction toolbar try { m_editor.StartOperation(); } catch { m_editor.AbortOperation(); m_editor.StartOperation(); } bool twoPoint = false; (ArcMap.Application.Document as IMxDocument).FocusMap.ClearSelection(); List <IFeature> pLstFeat = null; string storeOrder = ""; if (Control.ModifierKeys == Keys.Control) { twoPoint = CreateLineWithEndPoints.CreatePoints(ArcMap.Application, ConfigUtil.GetLinePointAtEndsConfig(), m_edSketch.Geometry as IPolyline, (IFeatureLayer)m_editor.CurrentTemplate.Layer, false, out pLstFeat, out storeOrder); } else { twoPoint = CreateLineWithEndPoints.CreatePoints(ArcMap.Application, ConfigUtil.GetLinePointAtEndsConfig(), m_edSketch.Geometry as IPolyline, (IFeatureLayer)m_editor.CurrentTemplate.Layer, true, out pLstFeat, out storeOrder); } if (storeOrder == null) { storeOrder = "Points"; } if (storeOrder.ToUpper() == "points".ToUpper()) { foreach (IFeature pFt in pLstFeat) { try { pFt.Store(); } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("errorOnIFeatureStore")); m_editor.AbortOperation(); return; } } } if (twoPoint) { pSegColl = (ISegmentCollection)m_edSketch.Geometry; pESeg = pSegColl.EnumSegments; pESeg.Reset(); int partIndex = 0; int segmentIndex = 0; pESeg.Next(out testSegment, ref partIndex, ref segmentIndex); while (testSegment != null) { segColTest = new PolylineClass(); Missing = Type.Missing; segColTest.AddSegment(testSegment, ref Missing, ref Missing); pFeat = Globals.CreateFeature(segColTest as IGeometry, m_editor.CurrentTemplate, m_editor, ArcMap.Application, false, false, true); try { pFeat.Store(); } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("errorOnIFeatureStore")); m_editor.AbortOperation(); return; } pESeg.Next(out testSegment, ref partIndex, ref segmentIndex); } } else { pFeat = Globals.CreateFeature(m_edSketch.Geometry, m_editor.CurrentTemplate, m_editor, ArcMap.Application, false, false, true); pFeat.Store(); } if (storeOrder.ToUpper() != "points".ToUpper()) { foreach (IFeature pFt in pLstFeat) { try { pFt.Store(); } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("errorOnIFeatureStore")); m_editor.AbortOperation(); return; } } } pLstFeat = null; m_editor.StopOperation("Create line with points"); } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ErrorInThe") + A4LGSharedFunctions.Localizer.GetString("CrtLnWithPts") + "\n" + ex.ToString()); m_editor.AbortOperation(); } finally { pFeat = null; pSegColl = null; pESeg = null; testSegment = null; segColTest = null; Missing = null; } }