public void DeleteLastSegment(SMPathOut firstSeg) { // Never delete the first one. SMPathSegment thisPathSeg = firstSeg.Next; int nSeg = 1; while (thisPathSeg != null) { if (thisPathSeg.Next == null) { // Delete this one SegmentCtl segCtl = GetSegmentCtl(thisPathSeg); if (segCtl != null) { _containerPanel.Controls.Remove(segCtl); segCtl.Dispose(); } thisPathSeg.Delete(); PreMoveIt(firstSeg); return; } thisPathSeg = thisPathSeg.Next; nSeg++; } }
private void DisposeSegment(SMPathSegment pathSeg) { if (pathSeg != null) { string segName = BuildSegName(pathSeg); if (_containerPanel.Controls.ContainsKey(segName)) { SegmentCtl segCtl = _containerPanel.Controls[segName] as SegmentCtl; _containerPanel.Controls.Remove(segCtl); segCtl.Dispose(); DisposeSegment(pathSeg.Next); } } }